1 Reply Latest reply on Dec 26, 2007 3:30 PM by wayne baylor

    Still having problems with java:comp/env lookups

    Magnus Sandberg Novice

      Hi,

      I still have problems with getting my local beans into java:comp/env.

      In my application I have annotated Local beans in an ear - I will deploy the ear more than one time so I need my beans in the 'ear-name/' global-namespace.

      I must also do some dynamic-lookups (non-annotated) using the EJBObject.lookup(..) (right?) when doing this the local beans needs to be in java:comp/env (right?)

      I still haven't been able to figure out how to achieve this ...

      any pointers or examples would be very appreciated!

      /Magnus

        • 1. Re: Still having problems with java:comp/env lookups
          wayne baylor Apprentice

          ejb-jar.xml declares the ejbs and the jboss.xml maps them to their global jndi name.

          ejb-jar.xml:

          <ejb-jar version="3.0" 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://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">
          
           <enterprise-beans>
          
           <session>
           <ejb-name>MyBean</ejb-name>
           <local>com.example.MyLocal</local>
           <ejb-class>com.example.MyBean</ejb-class>
           </session>
          
           </enterprise-beans>
          
          </ejb-jar>


          jboss.xml:
          <!DOCTYPE jboss PUBLIC
           "-//JBoss//DTD JBOSS 3.2//EN"
           "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd">
          <jboss>
           <enterprise-beans>
           <session>
           <ejb-name>MyBean</ejb-name>
           <local-jndi-name>com.example.MyBean/local</local-jndi-name>
           </session>
           </enterprise-beans>
          </jboss>


          with these you can use the following to look up the ejb:

          MyLocal bean = (MyLocal)new InitialContext().lookup("com.example.MyBean/local");