jboss 7 has a new jndi lookup way.Every JBoss AS instance has it's own local JNDI namespace (java:) which is unique per JVM.The layout of this namespace is primarily governed by the Java EE specification. which detail:JNDI Reference - JBoss AS 7.1 - Project Documentation Editor
When the jboss 7 previous versions,like jboss 5.we only use:
initContext = new InitialContext();
initContext.lookup(JNDIName);
the jndi name only is service name,like xxxxxService,but in jboss 7 we can't use it to lookup ejb .it will be like :java:global/Test/JndiTest/EjbTest!com.test.EjbTestService
If your do not want to modify the lookup name or you use some framework which you can't modify lookup name ,you can use the naming subsystem configuration.
<subsystem xmlns="urn:jboss:domain:naming:1.3">
<bindings>
<lookup name="java:/EjbTest" lookup="java:global/Test/JndiTest/EjbTest!com.test.EjbTestService" />
</bindings>
</subsystem>
add
<lookup name="java:/EjbTest" lookup="java:global/Test/JndiTest/EjbTest!com.test.EjbTestService" />
so you can use initContext .lookup("EjbTest") to lookup ejb which like the jboss 7 previous versions.
Attachment is the test code
Comments