Junos Space Developer
Reply
Contributor
Ar2r
Posts: 42
Registered: ‎11-29-2011
0

job scheduling issue

Hi,

 

I'm investigating Job Management in Junos Space. I wrote a sample of schedulable method and tried to execute it.

 

The sample method:

 

 

@Stateless(name = "HelloWorldEJB")
@Remote({ HelloWorld.class, JOBResultHandler.class })
public class HelloWorldImpl extends JobWorker implements HelloWorld, JOBResultHandler {

	private static Logger logger = Logger.getLogger(HelloWorldImpl.class);
	private static JobManager jobMgr = JxServiceLocator.lookup("cmp.JobManagerEJB");
	
	@Schedulable
	public JobInfoTO fooBar(ScheduleContext scheduleCtx) throws IOException {
		
		InternalScheduleContext iSctx = (InternalScheduleContext) scheduleCtx;
		int jobInstanceId = iSctx.getJobInstanceId(); // sets -1
		
		// do stuff here
		
		jobMgr.setJobInstanceResult(jobInstanceId, 
"Success", JobStatus.SUCCESS, null); // throws java.lang.NullPointerException exception return null; }
}

 

 Job starting method:

 

public String fooFooBar() {
	Date scheduleTime = new Date(System.currentTimeMillis() + 30000);
	ScheduleTO scheduleTo = new ScheduleTO();
	scheduleTo.setStartTime(scheduleTime);
	scheduleTo.setRepeatInterval("60000");
	scheduleTo.setRepetitionsLeft(5);
	ScheduleContext sCtx = new InternalScheduleContext();
	sCtx.setSchedule(scheduleTo);
	try {
		fooBar(sCtx);
	} catch (IOException e) {
		e.printStackTrace();
	}
	return "Done";
}

 

 When the job status is being set, the java.lang.NullPointerException is occurred.

 

Caused by: java.lang.NullPointerException
        at net.juniper.jmp.cmp.jobManager.ejb.JobManagerBean.setJobInstanceResultInternal(JobManagerBean.java:1826)        at net.juniper.jmp.cmp.jobManager.ejb.JobManagerBean.setJobInstanceResult(JobManagerBean.java:1787)
        at net.juniper.jmp.cmp.jobManager.ejb.JobManagerBean.setJobInstanceResult(JobManagerBean.java:1776)

 

Also, I figured out that jobMgr.updateJobInstanceProgress() method is deprecated, but it is in Junos Space SDK documentation (Implementing Asynchronous Services (LRR)) and is represented in samples. Where could I find the updated documentation?

 

Is it possible to create cron tasks and cancel them using JobManager?

Recognized Expert
Yesh
Posts: 456
Registered: ‎09-29-2009
0

Re: job scheduling issue

Hi,

 

I think its best for you to look at the code for the HelloWorld Sample App to overcome the null pointer exception.

 

Thanks

Yesh

Copyright© 1999-2013 Juniper Networks, Inc. All rights reserved.