1 Reply Latest reply on Jun 15, 2004 6:44 AM by jamesstrachan

    jndi lookup/referencing question

    nano_uhe Newbie


      I have a Servlet/Applet, which, changes very seldom that I worked on about a year ago and maintain. Usually when I develop the beans that I reference do not change, but in this case my servlet receives data from another bean which is frequently updated by another developer in our organization. A problem that we've been running into, is that every time he updates his bean, my Servlet breaks. All I have to do to fix it is to re-deploy it, so I'm fairly certain that there must be a subtle problem with either the way I'm looking this bean up or with our jboss configuration. I can't find anything written on this, so I'm sure it must be a quirk with our stuff. Does anyone have any ideas about this?

      Here's how I'm doing the lookup in the servlet:
      public void init() throws ServletException
      jndiContext = new InitialContext();
      Object ref = jndiContext.lookup("java:comp/env/ejb/Jdbcnan");
      jdbcboardhome = (JdbcboardHome) PortableRemoteObject.narrow(ref, JdbcboardHome.class);
      jdbcboard = jdbcboardhome.create();
      catch(Exception e)

      Here's my web.xml
      <!-- ### Servlets -->




      And here is my jboss-web.xml:

      Thank You,


        • 1. Re: jndi lookup/referencing question
          jamesstrachan Newbie


          I have just had to deal with a very similar problem in another application server.

          I would suspect that your home reference, which you get as you initialise the servlet, contains internal information which becomes out of date when your colleague does a hot deploy.

          This will then lead to an error when you try to use the home interface to get the remote interface.

          A suggested cure is to check for exceptions when you access the remote, and to close and reopen the home interface if an error occurs. It would be best to put this in a loop with a retry limit so that it will fail after two or three times if other errors occur.

          See sample code below :-

           while ( remoteFound == false && retryAttempts < retriesLimit ) {
           try {
           // Test for existing home connection. Retry if life expired.
           if ( home == null ) {
           remote = home.create();
           remoteFound = true;
           catch ( Exception e ) {
           fatalException = e;
           home = null;

          The variable fatalException will be used to report other errors if the remote could nott be found.