It's not a secret anymore!
The moose likes EJB and other Java EE Technologies and the fly likes Setting Cron Expression in EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Setting Cron Expression in EJB" Watch "Setting Cron Expression in EJB" New topic

Setting Cron Expression in EJB

balaji anatha padmanaban

Joined: Jun 18, 2008
Posts: 19
I need to set the cron expression to run a method present in a Stateless bean for every 5 min.
Before i used servlet form there I called.
Now I need to do without using the servlet only ejb is there .There is no front end.It s a seperate process.
So, can you please help me in how to set the cron expression and it should start when the ejb.jar is installed.
Where I need to add the code

Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Any reason why you don't just use an EJB Timer?

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Jair Rillo Junior
Ranch Hand

Joined: Aug 27, 2008
Posts: 114
I agree with Paul. EJB Timer Service is really great for that.

I have been using EJB Timer Service since EJB2 and it works fine (in EJB3 it's much easier).

You can set a duration, initial date and interval. Also, even the server crash, the EJB Timer keeps registered. When the server backs, the EJB Timer back automatically, very useful.

Just pay attention if you have more than one Timers Service. In this case, the order is not guaranteed.

Regards, Jair Rillo Junior, SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 5.0, IBM SOA Associate (Test 664).
I agree. Here's the link:
subject: Setting Cron Expression in EJB
jQuery in Action, 3rd edition