0 Replies Latest reply on Jul 16, 2014 5:47 AM by petal1

    NameNotFoundException in JBoss 6.1 but not in 4.0.4

    petal1 Newbie

      Hello,

       

      I am migrating an application from JBoss 4.0.4 to JBoss 6.1. I have a jar that has some version 2.1 EJBs. One of the session beans has a static initializer that looks up an entity bean. That works ok in 4.0.4 but gives this error when starting JBoss 6.1 - "javax.naming.NameNotFoundException: mymod not bound".


      static

      {

          MyEntityBeanLocalHome lhpt = MyEntityBeanUtil.getLocalHome();

          Collection things = lhpt.findAll();

          populate a static HashMap with things

      }


      The exception is thrown at the getLocalHome line above, which does the following:


      InitialContext ic = new InitialContext(null);

      Object objRef = ic.lookup("ejb/mymod/MyEntityBeanLocal");          <-- fails here

      if (java.rmi.Remote.class.isAssignableFrom(MyEntityBeanLocalHome.class))

          return javax.rmi.PortableRemoteObject.narrow(objRef, MyEntityBeanLocalHome.class);

      else

          return objRef;


      I am a little surprised the code works in JBoss 4.0.4 - after all, why should the entity bean have been bound to JNDI at the point I try to look it up.


      What is the correct solution for this? Should I move the code in the static initializer to the ejbActivate method?


      Thank you. for any useful input.