I have an EJB2 application running on JBOSS 4.2.3GA and the look up is working fine using: java:comp/env/ejb/MyEJB
.
When moving to JBOSS AS 6.1.Final, it suddenly broke with exception NameNotFoundException.
JNDI View does show the EJB being bound to the correct tree. Putting a breakpoint before lookup I was able to watch and confirm that it is bound. Using context.list("java:comp/env/ejb")
, I was able to see MyEJB in the iterator. Using context.lookup("java:comp/env/ejb")
also works. However context.lookup("java:comp/env/ejb/MyEJB")
shows NamingException on the watch window (and NameNotFoundException when running the actual code).
Is there anything changed that I do not know about? It's very difficult to find information on this EJB stuff and any information I found suggest either confirms what I'm doing it right or says to use ejb/MyEJB
which doesn't work at all.
Thanks in advance. I appreciate your help.
ejb-jar.xml:
<session>
<ejb-name>AdminSessionEJB</ejb-name>
<local-home>com.admin.ejb.business.AdminSessionHome</local-home>
<local>com.admin.ejb.business.AdminSession</local>
<ejb-class>com.admin.ejb.business.AdminSessionEJB</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<ejb-local-ref>
<ejb-ref-name>ejb/UserEJB</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>com.admin.ejb.entity.UserHome</local-home>
<local>com.admin.ejb.entity.User</local>
<ejb-link>UserEJB</ejb-link>
</ejb-local-ref>
<ejb-local-ref>
<ejb-ref-name>ejb/UniqueKeyEJB</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>com.framework.ejb.entity.UniqueKeyHome</local-home>
<local>com.framework.ejb.entity.UniqueKey</local>
<ejb-link>UniqueKeyEJB</ejb-link>
</ejb-local-ref>
<ejb-local-ref>
<ejb-ref-name>ejb/UserGroupEJB</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>com.admin.ejb.entity.UserGroupHome</local-home>
<local>com.admin.ejb.entity.UserGroup</local>
<ejb-link>UserGroupEJB</ejb-link>
</ejb-local-ref>
</session>
jboss.xml:
<enterprise-beans>
<entity>
<ejb-name>UserEJB</ejb-name>
<local-jndi-name>ejb/UserHome</local-jndi-name>
<read-only>false</read-only>
<configuration-name>UserEJB Container Configuration</configuration-name>
<ejb-local-ref>
<ejb-ref-name>ejb/UserGroupEJB</ejb-ref-name>
<local-jndi-name>ejb/UserGroupHome</local-jndi-name>
</ejb-local-ref>
</entity>
</enterprise-beans>
It looks like the newer JBoss/WildFly versions don't cope with old deployment descriptors very well.
If you update the ejb-jar.xml schema from:
<ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"
version="2.1">
to at least:
<ejb-jar 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"
version="3.0">
then it should work as advertised.
You can find a working example on GitHub at javaee14-ejb-demo