8 Replies Latest reply on Jul 4, 2008 11:05 AM by jaikiran

    EJB not bound :

    madalvi

      We migrated our application from Jboss 3.2.5 to 4.0.2.
      All EJBs in application are local, Added <ejb-local-ref> in web.xml
      and all JNDI names are java:comp/env/xyzEJB

      For all other EJBs, application is working fine except following one and gives error :
      "NameNotFoundException: CustomerEJB not bound" error.


      I checked the http://localhost:8080/jmx-console/

       "Global JNDI Namespace"
       +- local (class: org.jnp.interfaces.NamingContext)
       | +- CustomerEJB@29336323 (proxy: $Proxy103 implements interface com.xyz.customer.LocalCustomerHome)
      

      So this indicates that ejb-ref for CustomerEJB is fine.
      Then why am I getting NameNotFoundException

      Thanks in advance.


        • 1. Re: EJB not bound :
          jaikiran
          • 2. Re: EJB not bound :
            madalvi

            I already have the chages mentioned in the link you sent.
            Still no luck...
            It just this one entity bean which is having problem, for the rest of the Entity & Session beans project is working fine.

            Thanks is advance.

            • 3. Re: EJB not bound :
              jaikiran

              Post your ejb-jar.xml and jboss.xml and if possible, the code, where this bean is being accessed.

              • 4. Re: EJB not bound :
                madalvi

                I am getting this error when I started migrating my project from JBoss 3.2.5 to 4.0.2
                All the EJBs in the application are local.

                In JBoss 3.2.5

                JNDI name
                public static final String CUST_LOCAL_HOME = "local/CustomerEJB";
                
                ejb-jar.xml
                <entity>
                 <description>CUSTOMER table</description>
                 <ejb-name>CustomerEJB</ejb-name>
                 <local-home>com.xyz.components.customer.LocalCustomerHome</local-home>
                 <local>com.xyz.components.customer.LocalCustomer</local>
                 <ejb-class>com.xyz.components.customer.CustomerEJB</ejb-class>
                 <persistence-type>Container</persistence-type>
                 <prim-key-class>java.lang.String</prim-key-class>
                 <reentrant>-1</reentrant>
                 <cmp-version>2.x</cmp-version>
                 <abstract-schema-name>Customer</abstract-schema-name>
                 <cmp-field><field-name>CustID</field-name></cmp-field>
                 ....
                 ....
                 <primkey-field>CustID</primkey-field>
                 </entity>
                
                 No JBoss.xml
                
                
                 EJB Access code:
                 LocalCustomerHome custHome = (LocalCustomerHome)servicelocator.getLocalHome(JNDINames.CUST_LOCAL_HOME);
                 LocalCustomer custObj = custHome.create(myCustVO);
                
                

                For project we have xyzEJB.jar with all EJB and related classes
                xyz.war has all classes in xyzEJB.jar + web stuff such as JSP,.html, tld,etc.


                I made following changes for JBoss 4.0.2

                JNDI name
                public static final String CUST_LOCAL_HOME = "java:comp/env/CustomerEJB";
                
                ejb-jar.xml same as above
                
                No JBoss.xml
                
                Added following in web.xml for each EJB
                <ejb-local-ref>
                 <ejb-ref-name>CustomerEJB</ejb-ref-name>
                 <ejb-ref-type>Entity</ejb-ref-type>
                 <local-home>com.xyz.components.customer.LocalCustomerHome</local-home>
                 <local>com.xyz.components.customer.LocalCustomer</local>
                 <ejb-link>CustomerEJB</ejb-link>
                 </ejb-local-ref>
                
                EJB Access code:
                same as above.
                



                For JBoss 4.0.2, I excluded all the EJBs (3 files for each EJB) from xyz.war file.
                So xyz.war will not have any EJBs now.
                Somebody told me that we can get these kinds of errors if:
                1) we have duplicate classes in xyz.war & xyzEJB.jar file (I checked that I don't have any)
                2) some classes which should be xhyEJB.jar are in xyz.jar instead.
                e.g.in CustomerEJB create() has myCustVO , so CustVo.class should be in xyzEJB.jar not in zyz.jar.

                I haven't tried the option 2 yet.

                Thanks in advance.







                • 5. Re: EJB not bound :
                  madalvi

                  The issue was resolved.Didn't realized that it was case of EJB calling EJB.
                  The code was:
                  SomeEJB.someMethod() --> DAO.getCustomer() --> CustomerEJB

                  So I put <ejb-local-ref> element in ejb-jar.xml for "SomeEJB" and error was gone.

                  Thanks for all replies.

                  • 6. Re: EJB not bound :
                    anirban.gupta4

                    Hi, I'm trying to call a stateless session bean from another stateless sessino bean, using remote lookup, but while while looking up the called ejb jndi tree from the calling ejb, i'm getting an exception .......ejb not bound. please help

                    • 7. Re: EJB not bound :
                      arvind_mv

                      Hi All,

                      I know that many have posted the same query but i followed some steps based on this post. But still i am unable to resolve the issue.

                      My test program is as shown below:

                      nitialContext iniCtx= null;
                      Context ejbCtx = null;
                      CryptoHome home=null;
                      Properties props = null;
                      //MyBeanLocal local = null;
                      Object ref = null;
                      CryptoHome cryptoHome=null;
                      try {

                      /* iniCtx = new InitialContext();
                      //ejbCtx = (Context) iniCtx.lookup("java:comp/env/ejb/Crypto");
                      //home = (CryptoHome) iniCtx.lookup("Crypto"); //java:comp/env/
                      home = (CryptoHome) new InitialContext().lookup("java:comp/env/ejb/Crypto"); */
                      props = new Properties();
                      props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
                      props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interface");
                      props.put(Context.PROVIDER_URL, "jnp://localhost:1099");
                      // I have tried "localhost:1099", 127.0.0.1, etc as well

                      Context ctx= new InitialContext(props);
                      // *never makes it here, exception NameNotFoundException*

                      //Object ref = ctx.lookup("MyBeanLocal");
                      cryptoHome = (CryptoHome)ctx.lookup("java:comp/env/Crypto");
                      //local = cryptoHome.create();
                      } catch (NamingException e1) {
                      // TODO Auto-generated catch block
                      e1.printStackTrace();
                      }


                      At the crypto home it is throwing the nullpointer exception, is it right way of mentioning the JNDI name. In the Jboss console it shows javax.naming.NameNotFoundException: Crypto not bound

                      Please let me know the solution.

                      Thanks,
                      Arvind

                      • 8. Re: EJB not bound :
                        jaikiran

                         

                        In the Jboss console it shows javax.naming.NameNotFoundException: Crypto not bound


                        Follow the steps mentioned at http://wiki.jboss.org/wiki/DisplayTheJNDITreeWithTheJMXConsole and find the jndi-name of your bean. Then use that jndi-name for looking up the bean.