2 Replies Latest reply on Aug 30, 2006 10:25 AM by tshuynh

    java:comp NameSpace in EJB 3.0

    tshuynh

      Hi

      I am using JBoss 4.0.4GA with EJB 3.0 and having a problem of looking up a EJB reference defined in jboss.xml using

      ctx.lookup("java:comp/env/ejb/MyEJB");

      When I used the JBoss MBean service JNDIView, I recon that all the EJBs version 3.0 don't have a java:comp namespace section. Only EJBs version 2.X have it.

      Is it normal that EJBs 3.0 don't have that namespace anymore?

      Thank you.

        • 1. Re: java:comp NameSpace in EJB 3.0
          bill.burke

          we changed the ENC implementation for EJB3 to be ThreadLocal based instead of keyed by classloader. We can't change the implementation for java:comp for JBoss 4, so there is a new java:comp namespace for now:

          "java:comp.ejb3"


          You can get this as a constant via org.jboss.ejb3.Container.ENC_CTX_NAME

          we'll change the value of this constant back to java:comp for JBoss 5.

          • 2. Re: java:comp NameSpace in EJB 3.0
            tshuynh

            Thanks for your quick reply.

            The question now is how to add a EJB Ref to that namespace (java:comp.ejb3). I have 2 EJBs: myEjb1 and myEjb2. The myEjb1 has a ref to myEJB2 like this:

            <?xml version="1.0" encoding="UTF-8"?>
            <jboss xmlns="http://java.sun.com/xml/ns/javaee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss_5_0.xsd"
             version="3.0">
            
             <enterprise-beans>
             <session>
             <ejb-name>MyBean1</ejb-name>
             <local-jndi-name>ejb/myEJB1</local-jndi-name>
             <ejb-local-ref>
             <ejb-ref-name>ejb/myEJB2</ejb-ref-name>
             <local-jndi-name>ejb/myEJB2</local-jndi-name>
             </ejb-local-ref>
             </session>
             </enterprise-beans>
             <resource-managers></resource-managers>
            </jboss>
            
            


            And the MyBean2 binds to the JNDI name 'ejb/myEJB2'.
            When I deploy both EJBs in a EAR file to JBoss 4.0.4GA/EJB3.0, I get the exception:

            javax.naming.NamingException: Could not bind statless proxy with ejb name MyBean1 into JNDI under jndiName: /ejb/myEJB2 [Root exception is javax.naming.NameAlreadyBoundException]
            


            And in the JNDIView, it shows that the MyBean2 was already bound to 'ejb/myEJB2'.

            I don't understand why.

            Thank you