How to migrate your application from JBoss v2.4 to JOnAS v2.4 | ||
---|---|---|
Prev | Chapter 2. Migrating your deployment descriptors | Next |
This section explains how to declare references between beans that are packaged in the same jar.
With both JBoss and JOnAS you have to declare an ejb-ref element in the ejb-jar.xml. With JBoss you must also declare an ejb-link attribute in the ejb-ref element of the bean. There is nothing to add in the JBoss specific descriptors. JOnAS does not need the ejb-link attribute but you won't get any errors if you have one so you don't have to remove those attributes from your ejb-jar.xml file. In jonas-ejb-jar.xml, you must also declare a jonas-ejb-ref element. In the following example the session bean SB_BrowseRegions calls methods on the Region entity bean. So for SB_BrowseRegions you need an ejb-ref element in the ejb-jar.xml file and a jonas-ejb-ref element in the jonas-ejb-jar.xml file that references the bean Region:
Common ejb-jar.xml file for SB_BrowseRegions:
<ejb-jar> <enterprise-beans> <session> <description>Deployment descriptor for SB_BrowseRegions Bean</description> <ejb-ref> <description>This is the reference to the region bean</description> <ejb-ref-name>ejb/Region</ejb-ref-name> <ejb-ref-type>Entity</ejb-ref-type> <ejb-link>Region</ejb-link> <home>edu.rice.rubis.beans.RegionHome</home> <remote>edu.rice.rubis.beans.Region</remote> </ejb-ref> <session> <enterprise-beans> <ejb-jar>
jonas-ejb-jar.xml file for SB_BrowseRegions:
<jonas-ejb-jar> <jonas-session> <ejb-name>SB_BrowseRegions</ejb-name> <jonas-ejb-ref> <ejb-ref-name>ejb/Region</ejb-ref-name> <jndi-name>RegionHome</jndi-name> </jonas-ejb-ref> </jonas-session> </jonas-ejb-jar>
This section explains how to declare references between beans that are packaged in different jars.
With both JBoss and JOnAS you have to declare an ejb-ref element in the ejb-jar.xml but unlike when beans are in the same jar, you don't have to declare an ejb-link attribute. With JBoss you have to declare an ejb-ref element in jboss.xml and provide the full JNDI name of the bean. With JOnAS, inter-jars EJB references are declared the same way as intra-jar references. So you have to declare a jonas-ejb-ref element in jonas-ejb-jar.xml that contains the JNDI name of the referenced bean home interface.
In the following example the session bean SB_BrowseRegions calls methods on the Region entity bean but the beans are packaged in different jars. So for SB_BrowseRegions you need an ejb-ref element in the ejb-jar.xml file and a jonas-ejb-ref element in the jonas-ejb-jar.xml file that references the bean Region instead of an ejb-ref elment in the the jboss.xml:
Common ejb-jar.xml file for SB_BrowseRegions:
<ejb-jar> <enterprise-beans> <session> <description>Deployment descriptor for SB_BrowseRegions Bean</description> <ejb-ref> <description>This is the reference to the region bean</description> <ejb-ref-name>ejb/Region</ejb-ref-name> <ejb-ref-type>Entity</ejb-ref-type> <home>edu.rice.rubis.beans.RegionHome</home> <remote>edu.rice.rubis.beans.Region</remote> </ejb-ref> <session> <enterprise-beans> <ejb-jar>
Example of jboss.xml file for SB_BrowseRegions:
<jboss> <session> <ejb-name>SB_BrowseRegions</ejb-name> <ejb-ref> <ejb-ref-name>ejb/Region</ejb-ref-name> <jndi-name>protocol://serverName/directory/RegionHome</jndi-name> </ejb-ref> </session> </jboss>
Here is the equivalent jonas-ejb-jar.xml file for SB_BrowseRegions:
<jonas-ejb-jar> <jonas-session> <ejb-name>SB_BrowseRegions</ejb-name> <jonas-ejb-ref> <ejb-ref-name>ejb/Region</ejb-ref-name> <jndi-name>RegionHome</jndi-name> </jonas-ejb-ref> </jonas-session> </jonas-ejb-jar>