Discussions

EJB programming & troubleshooting: How to cache the EJBObject in client(servlet container)?

  1. I am writing an J2EE application, I use Weblogic server 7.0 as application server and tomcat as servlet container. so when I need to access the EJB in servlet, I should use JNDI lookup to look up the EJB's Home Object and then create the EJBObject.

    I read in some artical who said that the JNDI lookup is very slow and should cache the EJBObject in the servlet container, I do this and it works fine.

    But the problem is, when I re-deploy the EJB in weblogic server, the original EJBObject cached in servlet container seems to be garbage colleted by weblogic server but the servlet container has no idea to know this so that I have no chance to refresh the cache

    Anybody can help me?

    Thanks a lot
  2. Cache the homeObject and always create the ejbObject. That may be less effecient but will solve your problem.
  3. I cached the Home Object and the same thing happen, It seems that the Home Object will be garbage collected too when redeploy the EJB.


    Help me, please!
  4. get a handle to the EJBObject - this handle will be valid even if the app server is restarted.......
  5. Are you sure the EJBObject handle can do this? I tried in my application, when I redeploy the EJB, the handle seems unavailable temporary, after redeploy finished, the handle will available and can be used to connect to the EJB again
  6. yes, if the bean is deployed, the handle can be used to get the EJB object for it.
  7. But when the re-deployment is in progress, the EJB Object handle can not get the EJB object, for a 24x7 application, this is not enough.
  8. Anybody can help me?
  9. up