I try to start a thread in Singleton EJB, but it java.lang.IllegalStateExceptionthrows. This is my (cut) class:
Singleton
@LocalBean
@Startup
public class WatcherEJB {
@Resource(name = "concurrent/masterActionsThreadFactor")
ManagedThreadFactory threadFactory;
Thread watcherThread;
@PostConstruct
public void startUp() {
watcherThread = threadFactory.newThread(new Runnable() {
@Override
public void run() {
}
});
watcherThread.start();
}
}
I assume there is a problem with when I try to run a Thread object or does Java EE 7 not allow managed threads at single points?
source
share