users@glassfish.java.net

Re: glassfish-embedded non-portable jndi

From: <forums_at_java.net>
Date: Wed, 8 Jun 2011 09:21:51 -0500 (CDT)

The preferred way is still to use portable global jndi names. 
GlassFish-specific JNDI names are only for remote EJB.  An example of
glassfish-ejb-jar.xml:

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE glassfish-ejb-jar PUBLIC
"-//GlassFish.org//DTD GlassFish Application Server 3.1 EJB 3.1//EN"
"http://glassfish.org/dtds/glassfish-ejb-jar_3_1-1.dtd"> <glassfish-ejb-jar>
<enterprise-beans>    <ejb>      <ejb-name>TestBean</ejb-name>     
<jndi-name>ejb/TestBean</jndi-name>    </ejb>    </enterprise-beans>
</glassfish-ejb-jar> EJBContainer container = null; try { container =
EJBContainer.createEJBContainer(); Context namingContext =
container.getContext(); // Test testBean = (Test) namingContext.lookup(
//                    "java:global/testApp/TestBean");
            Test testBean = (Test)
namingContext.lookup("ejb/TestBean");             String hi =
testBean.hello("client");            
System.out.println("testBean.hello method returned: " + hi);         }
finally {             if(container != null) {
                container.close();             }
        }

--
[Message sent by forum member 'cf126330']
View Post: http://forums.java.net/node/809993