I use web profile and it does not allow to use Java EE @Schedule functionality. So, I have several ways to solve the problem:
- reinstall the server to use full profile. Problems: it’s risky (functionality/performance) for my production and burdensome
- Use other scheduling functionality like Spring. Problems: I don’t know how to link Spring with JavaEE as I want to use CDI beans in my scheduler. Seam-spring module could help me (http://sfwk.org/Seam3/SpringModule) but its documentation is not available at the moment and I don’t really know the status of it.
So, which is the best way to enable scheduling inside my glassfish app?
Thanks
Ok, I managed to do this using spring module. Would be better to use embedded Scheduler J2EE functionality, but this is not included into Glassfish web profile, only to full (WTF??). As my project is in prod, I don’t want to upgrade to full one, especially as there is no flexible way to do this upgrade. Only full server substitute. Very poor JavaEE….
So, first, we need to define some functionality, which will be run at schedule:
Second, we should create the spring configuration file with the following configuration:
That’s all. I define EJB beans and use “aop:scoped-proxy” to initialize my scheduler by them. Spring schedule is included into core spring module, so only core spring dependency is necessary