jboss7.xejb-2.x

JBoss is not creating JNDI for EJB 2.0 project


Ejb-jar.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.1"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
<display-name>EjbEntity</display-name>
<enterprise-beans>
    <entity>
        <ejb-name>Demo</ejb-name>
        <home>com.trantor.iface.EmployeeHome</home>
        <remote>com.trantor.iface.EmployeeRemote</remote>
        <ejb-class>com.trantor.EmployeeBean</ejb-class>
        <persistence-type>Container</persistence-type>
        <prim-key-class>com.trantor.EmployeePK</prim-key-class>
        <reentrant>false</reentrant>
        <cmp-field>
            <field-name>empNo</field-name>
        </cmp-field>
        <cmp-field>
            <field-name>empName</field-name>
        </cmp-field>
        <cmp-field>
            <field-name>salary</field-name>
        </cmp-field>
        <primkey-field>empNo</primkey-field>
    </entity>
</enterprise-beans>
<assembly-descriptor>
    <container-transaction>
        <method>
            <ejb-name>Demo</ejb-name>
            <method-name>*</method-name>
        </method>
        <trans-attribute>Required</trans-attribute>
    </container-transaction>
</assembly-descriptor>
</ejb-jar>

When I am deploying it on JBoss then JBoss is not creating JNDI name for this..I tried hard but failed to resolve this issue..

When I am deploying this. It is getting deployed but JBoss is deploying it as a simple application. no jndi is created for the application.


Solution

  • JBoss deals with EJB 2.x very differently from the way it treats EJB 3.x. There is also a difference in the way it treats session vs entity beans

    You might need to create a jboss-ejb3.xml file and map res-ref-names to jndi-name.

    More details can be found here - https://docs.jboss.org/jbossas/docs/Server_Configuration_Guide/4/html/The_CMP_Engine-Entity_Beans.html

    You will also need to use standalone-full.xml rather than standalone.xml for entity beans to work.