cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in using EJB 2.1 Timer Service

Former Member
0 Kudos

Hi all,

I need a method in my EJB to be called by the EJB container at regular intervals. For this I plan to use the EJB 2.1 Timer Service.

I did the following for implementing the Timer Service.

1. My bean class implements the TimedObject interface. Thus the method ejbTimeout(Timer t) will be called by the container according to the interval I define in the timer.

2. For defining a timer, I have created a business method in the EJB which creates a Timer object with the timer service.

public void registerTimer(){

// getting the timerService from the EJBContext

timerService = myContext.getTimerService();

// create a timer which times out after 5 seconds, and subsequently after every 10 seconds

t = timerService.createTimer(5000,10000,"my timer");

}

Q: Is this enough or do we have to configure the engine in some way, so that it calls the ejbTimeout() method ? Maybe I am missing out something.

If the above tasks are enough then according to my understanding, the timer is created and then the ejbTimeout(Timer arg0) should be called first after 5 seconds and then after every 10 seconds.

I have created a servlet which acts as a client to this EJB, by which I can see that the Timer object is created, but the ejbTimeout() is never fired .

What could be the reason behind this? Am I missing something? Do I need to configure the engine in some way?

Any input on the above will be most valuable.

Thanks and Regards,

Gagan Parhar.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

the thing you're missing is merely that Web AS 6.40 is J2EE 1.3 compliant (hence, supports EJB2.0!). EJB 2.1 is not supported in this release, that's why you have not Timer Service available!

Unfortunately, I can't suggest an alternative in this case!

Regards,

Ivo

Former Member
0 Kudos

Hi,

Thanks Ivo. That was very helpful. Though, now I have to find an alternate way.

Regards,

Gagan

Former Member
0 Kudos

Hi ,,

Go THru this article, sure it helps .

http://www.oracle.com/technology/sample_code/tutorials/fbs10g/fbs10gtoc.htm

Reg

VArun CN