Jahia Template Forum > scheduled job

0 (0 Good)
0 (0 Bad)

scheduled job

by  mariocauwe »  2011/06/07 20:03

Hi,

I try to schedule a Job in Jahia 4.

Problem is that i get a nullpointerexception on ctnService.loadContainer :
[code:3vd96gla]JahiaContainersService ctnService =

ServicesRegistry#46;getInstance()
  • scheduled job
    2011/06/07 20:03

    mariocauwe Hi,<br/><br/>I try to schedule a Job in Jahia 4.<br/><br/>Problem is that i get a nullpointerexception on ctnService.loadContainer : <br/>[code:3vd96gla]JahiaContainersService ctnService = <br/><br/>ServicesRegistry#46;getInstance()

  • Number of messages  20
    Registration date Jun 7, 2011
    0 (0 Good)
    0 (0 Bad)

    Re: scheduled job

    by  shyrkov »  2011/06/07 20:03

    Hello Mario,

    could you, please, post the code, you use for scheduling the job as well as the complete stacktrace of the exception, you get?

    Kind regards
    Sergiy
  • Re: scheduled job
    2011/06/07 20:03

    shyrkov Hello Mario,<br/><br/>could you, please, post the code, you use for scheduling the job as well as the complete stacktrace of the exception, you get?<br/><br/>Kind regards<br/>Sergiy

  • Number of messages  407
    Registration date Jun 7, 2011
    0 (0 Good)
    0 (0 Bad)

    Re: scheduled job

    by  mariocauwe »  2011/06/07 20:03

    This is the stacktrace:
    [code:192c79sr]#91;18/01/10 14
  • Re: scheduled job
    2011/06/07 20:03

    mariocauwe This is the stacktrace:<br/>[code:192c79sr]#91;18/01/10 14

  • Number of messages  20
    Registration date Jun 7, 2011
    0 (0 Good)
    0 (0 Bad)

    Re: scheduled job

    by  wassek »  2011/06/07 20:03

    Hello Mario,


    I see your problem.
    Do you use a wrong loadContainer Method. In this case if you want to load the container you need a ParamBean object.


    ParamBean jParam = new ParamBean(
    ServletResources.getCurrentRequest(),
    ServletResources.getCurrentResponse(),
    ServletResources.getCurrentConfig().getServletContext(),
    Jahia.getSettings(),
    System.currentTimeMillis(),
    ParamBean.GET_METHOD);
    JahiaContainer jc = ctnService.loadContainer(id, LoadFlags.ALL, jParams);


    The ServletResources class returns request, reesponse and a Context of the current Thread. That you can create a ParamBean Object.

    When you have no ParamBean object to read a Jahiacontainer you get this NullPointerException (your used method is deprecated).

    best regards
    Werner

    Werner Assek (wassek)

    Number of messages  26
    Registration date
    0 (0 Good)
    0 (0 Bad)

    Re: scheduled job

    by  mariocauwe »  2011/06/07 20:03

    Thanks for your replies.

    The isssue is that I can't access a servlet context, nor request and response objects.
    This is a scheduled job, so it's not the result of browsing to a page, hence these objects are not present.
    (ServletResources.getCurrentRequest == null)

    Probably I just put my job initialisation in the wrong place. I think it should not be started from my own jsp anyway (because this causes duplicate jobs for instance when visitors access the page).

    So I keep wondering how to access containerlists and items when running inside a quartz job, without having access to a valid ParamBean object.

    Regards,
    Mario
  • Re: scheduled job
    2011/06/07 20:03

    mariocauwe Thanks for your replies.<br/><br/>The isssue is that I can't access a servlet context, nor request and response objects.<br/>This is a scheduled job, so it's not the result of browsing to a page, hence these objects are not present.<br/>(ServletResources.getCurrentRequest == null)<br/><br/>Probably I just put my job initialisation in the wrong place. I think it should not be started from my own jsp anyway (because this causes duplicate jobs for instance when visitors access the page).<br/><br/>So I keep wondering how to access containerlists and items when running inside a quartz job, without having access to a valid ParamBean object.<br/><br/>Regards,<br/>Mario

  • Number of messages  20
    Registration date Jun 7, 2011
    Contact
    Share
    Feedback

    Get in touch

    Whether you are a current user or if you are just evaluating Jahia, we are here to help.

    Contact us

    Share this page