javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory in EAP 6
Environment
- JBoss Enterprise Application Support (EAP)
- 6 Beta
Issue
- While deploying an ear which contains a war file, the following exception is thrown:
javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory com.sun.jndi.rmi.registry.RegistryContextFactory from classloader ModuleClassLoader for Module "deployment.EAR_Name.ear.WAR_Name.war:main"
Resolution
- Need to create jboss-deployment-structure.xml in EAR_Name\META-INF with the following content:
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
<sub-deployment name="WAR_Name.war">
<exclusions>
<module name="org.apache.log4j" />
</exclusions>
<dependencies>
<system>
<paths>
<path name="com/sun/org/apache/xerces/internal/jaxp/datatype"/>
<path name="com/sun/jndi/rmi" />
<path name="com/sun/jndi/rmi/registry"/>
</paths>
</system>
</dependencies>
</sub-deployment>
</jboss-deployment-structure>
Root Cause
- Since EAP is so modularized that sometimes it does not even pick up the jre libraries. We need to mention it in jboss-deployment-structure.xml so that the application does not fail while deploying.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments