permaculture playing cards*
The moose likes EJB and other Java EE Technologies and the fly likes How to auto execute a session bean’s method on ear deployment? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How to auto execute a session bean’s method on ear deployment?" Watch "How to auto execute a session bean’s method on ear deployment?" New topic
Author

How to auto execute a session bean’s method on ear deployment?

Sib Pete
Greenhorn

Joined: Apr 27, 2009
Posts: 26
I need a way to have a session bean's method executed periodically every week at a certain time. I am thinking of using the quartz scheduler to do this. My question is, how do I start the scheduler to run from the moment the .ear file is deployed automatically? Is there any annotation that I can use on the stateless session bean calling the scheduler.start method such as @PostConstruct or something?
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30789
    
157

I know you can set a servlet to init/load automatically on ear deployment. Not sure how to do so for an EJB. You could always write a servlet which calls your EJB.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Sib Pete
Greenhorn

Joined: Apr 27, 2009
Posts: 26
How do you set up a servlet to load automatically on ear deployment?
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30789
    
157

Sib Pete wrote:How do you set up a servlet to load automatically on ear deployment?

In the web.xml. See this example
Sib Pete
Greenhorn

Joined: Apr 27, 2009
Posts: 26
If I cant auto execute an ejb method on deployment, then I will have to go with this I guess. Thanks. Really helps a lot.
Shane Lee
Ranch Hand

Joined: Mar 19, 2005
Posts: 63
Any update on this Sib?

My enterprise application only has a backend, and all ive found on the net is using servlet to initialise the scheduler.
My goal is to automate method invocation on one of my stateless session beans, periodically via cron trigger.

Any clues?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to auto execute a session bean’s method on ear deployment?