* Company's web application uses JAAS login. Whenever I call my EJB's methods (scheduleJob and cancelJob ) that contains timerService.createTimer() or Timer.cancel(), I always get kicked out of web app as if I wasn't logged in, and have to relogin again.
* I do see the job is indeed scheduled after I relogin.
* Once a job is scheduled, it runs fine.
* there is no error msg/stacktrace from the console when submit new job or cancel.
* However, get list of timers (getScheduledJobs) works fine, without kicking me out.
What should I do so I can use Timer service functions without losing authentication?
I'm using JBoss 4.0.2.
public class TimedCommandHandlerServiceBean implements SessionBean, TimedObject {
public void scheduleJob(ScheduledJob job, Date initialTime){
TimerService timerService = ctx.getTimerService();
timerService.createTimer(initialTime,job);
}
public void cancelJob(ScheduledJob aJob){
TimerService timerService = ctx.getTimerService();
Collection timers = timerService.getTimers();
for(Iterator iter = timers.iterator(); iter.hasNext();){
Timer timer = (Timer)iter.next();
ScheduledJob job = (ScheduledJob)timer.getInfo();
if(job.getName().equals(aJob.getName())){
timer.cancel();
break;
}
}
}
public Collection getScheduledJobs(){
TimerService timerService = ctx.getTimerService();
Collection timers = timerService.getTimers();
Collection result = new ArrayList();
for(Iterator iter = timers.iterator(); iter.hasNext();){
Timer timer = (Timer)iter.next();
ScheduledJob job = (ScheduledJob)timer.getInfo();
result.add(job);
}
return result;
}
<jboss-web> <security-domain>java:/jaas/CompanyRealm</security-domain> </jboss-web>
<application-policy name="CompanyRealm"> <authentication> <login-module code="mycompany.jaas.jboss.JBossLoginModule" flag="required"> <module-option name="dsJndiName">java:MYDB</module-option> </login-module> </authentication> </application-policy>
Sorry, the cause was due to java server face page misconfiguration. Please ignore my previous post.