How to call Session bean's method at application startup in EJB3?

How to call Session bean's method at application startup in EJB3? I am using EJB 3 and Websphere 7.0. I do not want to use web components like servlet etc.
NilkanthRAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mr_ItCommented:
Websphere has something called "startup beans". Maybe that will help?

I don't think you can do this in a "standard" way with EJB 3 and without a servlet. In EJB 3.1 you will be able to do this with a Timer on startup, if I'm correct.

Regards
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Gibu GeorgeChief Technology OfficerCommented:
One way to do this is to add a servlet and in it init look up the ejab and call the method. set the load onstartup variable for the servlet. EJB 3.1(The EJB 3.1 specification is not yet final ), there a type of bean called Singleton. Singletons have an @Startup annotation which can be applied to the bean class. When used, the Container will instantiate the Singleton instance eagerly when the application starts up, otherwise the Container will instantiate the Singleton instance lazily when the bean is first accessed.
0
Gibu GeorgeChief Technology OfficerCommented:
0
NilkanthRAuthor Commented:
My project do not have any web component so I do not want to add servlets just to invoke an EJB.
Websphere startup Beans are based on EJB 2.1 specification. Although we can have EJB2.1 and EJB 3.0 work together, but this will violet specifications of my project.
There is yet another workaround as follows
1) use <start-at-app-start> websphere extention for the session bean. This instructs container to instantiate the sesstion bean when application start.
2) From the construtor of the seesion bean invoke other method.

But this implementation has dependancy on IBM vendor.
I need pure J2EE based solution.
Any help will be appriciated.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.