I'm calling my session bean from servlet, which approach is better:
1) every time when I process request I should create InitialContext, do lookup, and home.create() than use the bean
2) in servlet init(...) method create InitialContext, do lookup, and home.create() and when servlet is being requested just use that bean
Please, do not ignore this question if it looks stupid to you -- I'm new to EJB programming.
We have used a singleton approach to cache bean homes.It works pretty good.Instantiate all ur ejb homes in a singleton ; and just call getEJBXXHome() to get the homes.
What u said is correct . i am also using the same.
I would do what the others have said, cache the home ref. If it's a stateless session bean you can cache the remote ref. too.