0

I have a SessionScoped bean ProcessListBean having two methods startProcess and stopProcess like following

public void startProcess(){
timer.schedule(new TimerTask(){
public void run {
 //start after 10seconds
}
},10000);
}


public void stopProcess(){
timer.schedule(new TimerTask(){
public void run {
 //stop after 10seconds
}
},10000);
}

and ManagedBean class as;

@Component("processListBean")
@Scope("session")
public class ProcessListBean{

Timer timer;

//methods and other resources such as DAO

}

When I have push a start commandButton in JSF view processListBean->startProcess action is performed, after 10 seconds then when I have pushed stop commandButton in jSF view processlistStopProcess is executed. In that case (vise versa stop-start, start-stop), I am having timer already cancelled exception, I have not come across such exception in J2SE, I think something is wrong with session management in Spring Framework or I have missed some point.

I have also moved timer initializion into @PostConstruct but have not solved my problem.

Ahmet Karakaya
  • 9,899
  • 23
  • 86
  • 141
  • Eeeek, a `Timer` in a Java EE application? http://stackoverflow.com/questions/7499534/applicationscope-bean-that-uses-a-timertask-sheduler-good-or-bad/ – BalusC Dec 06 '13 at 10:50
  • Java EE7 comes with new features one of whose is Concurrency Utilities for Java EE. But since I am using weblogic 10.3 compliant with java EE 6, I cannot use these new features. So what kinf of executer thread I have to use? – Ahmet Karakaya Dec 14 '13 at 19:54

0 Answers0