Skip to Content
0
Former Member
Apr 21, 2015 at 06:53 AM

Cron job is creating different JaloSession

185 Views

Hi Experts,

I am executing a cronjob fron my class, where in cronjob i am setting some values in the session. The problem is when i tried to get the session values it returned null. Then i compared the session ids of both the sessions and got to know that both sessions are different (My class session and cornjob session).

So how can i get the same session which is creating in the cronjon...

Please find the sample code below...

 public void processMail(final JaloSession session, final String dataDir)
 {       
            
     final CronJobModel dynamicCJ = cronJobService.getCronJob("sampleCronJob");

     //Executing the sampleCronJob
     cronJobService.performCronJob(dynamicCJ, true);

     final String testString = (String) session.getAttribute("sessionTest"); // Returning "null"    

     System.out.println("Session ID in processMail() ::::::     " + session.getSessionID());        //Different session id 

 }


 //sampleCronJob 
 public PerformResult perform(final CronJobModel cronJob)
 {

     final Date date = cronJob.getModifiedtime();

     final JaloSession session = serviceUtil.getJaloSession();
     
     session.setAttribute("sessionTest", "Hello Session String");

     System.out.println("Session ID in Perform() ::::::     " + session.getSessionID());
                 
 }

Regards,