Do not use local JNDI names

In WebLogic and JBoss applications, the <local-jndi-name> element defines the JNDI name for the local home of the bean in the global JNDI tree. It is defined in the weblogic-ejb-jar.xml or the jboss.xml file.

WebSphere(R) does not allow the mapping of local homes to JNDI names in the global JNDI tree. Instead, they are mapped into the JNDI tree of the local container. For that reason, programmers must access local enterprise beans using a JNDI reference in the local namespace; not the JNDI name in the global namespace.

This rule is triggered when a <local-jndi-name> element is found in weblogic-ejb-jar.xml or in jboss.xml. The automated fix will processes Java files, deployment descriptors, and bindings to enable these references to work on WebSphere.

All packages related to the application in which the <local-jndi-name> element is found are processed. If your application EAR project is not found or is not associated with the EJB project found, only the EJB project is processed. It is important to have your related projects defined correctly.

When the automated fix is available and has been applied, it will scan all the Java files in the application where the <local-jndi-name> is found. It scans for direct context lookups to the local JNDI name, and it scans for lookups of the EJB reference to that name.

For example, if the local JNDI name is ejb/myBeanLocalHome , the following code examples trigger updates to code, deployment descriptors and bindings, or both.

Java lookup examples:

ctx.lookup("ejb/myBeanLocalHome");

ctx.lookup("java:comp/ejb/myBeanLocalHome");

ctx.lookup(myBeanLocalHomeNameVariable);

The Java code is changed in the first example to ctx.lookup("java:comp/ejb/myBeanLocalHome") so that an EJB reference lookup is done. The other two Java examples remain unchanged. In all three cases, the automated fix will update the deployment descriptors and bindings for the project.

When a lookup to the specific local JNDI name is detected for a project and when a variable is used and the lookup cannot be determined, the web.xml file or the ejb-jar.xml file is modified to include an <ejb-local-ref> for the bean that defined the local JNDI name. In the case of an EJB project, the <ejb-local-ref> element is added to each bean that is defined in the ejb-jar.xml. In the case of the web.xml file, one reference is added for the bean that defined the local JNDI name. For both of these, the <ejb-local-ref> JNDI name is added to the bindings file for the project.