File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes EJB Timer Services Query 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 "EJB Timer Services Query" Watch "EJB Timer Services Query" New topic

EJB Timer Services Query

Ankit Garg

Joined: Aug 03, 2008
Posts: 9465

Well I have a few questions on EJB Timer Services. I hope someone can help me. I searched on google and in this forum but didn't find any solutions. So these are my questions

1. I have jBoss as my application server where I need to start a timer service. Now I just created a stateless session bean and injected the timer service into it and I am calling the timer service on application startup by using a servlet which is loaded on startup to make a call to the timer service bean. There is no exception in the timer service startup but the timeout method is not getting called. Do I need some extra configurations to implement the timer service??

2. Can I make my timeout method private or protected??

3. Also I don't want the timer service to be persisted because I am starting the service on application startup already. I have not made any configurations for this so I think that the timer service will not sustain a server shutdown but still I want to confirm it.

4. If I set the first occurrence of the timer service to a time that has passed like 2 minutes ago, then will the timer service be called or not??

This is my code for the timer service

Now I can see "timer service started" on the jboss console but "starting work" doesn't get displayed meaning that timer service is not started.

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Mayur Somani

Joined: Apr 14, 2008
Posts: 26
Although I don't know much about it, still IMHO, this may help-


2. From the docs,
A Timeout method can have public, private, protected, or package level access. A Timeout method must not be
declared as final or static.


4. No (I think).
Ankit Garg

Joined: Aug 03, 2008
Posts: 9465

Someone just give me a kick in my butt . cal2.getTimeInMillis() + 15000 was creating the problem. If you provide the first argument as milliseconds, then it is the delay in milliseconds from the current time to the first timeout. So my timeout would come after about 39 years (i.e. the time between 1Jan 1970 to 2009).

Thanks mayur for the help . For the fourth one I tried my timer with a past date and it fired a timeout right when I called createTimer so if you provide a timeout time which has expired, then the timeout event will occur. I still can't believe I made such a silly mistake. Anyways thanks again mayur...
jQuery in Action, 3rd edition
subject: EJB Timer Services Query
It's not a secret anymore!