简体   繁体   中英

Issue moving ear from JBoss EAP 5.1 to 6.1

I'm trying to move an ear file from JBoss 5.1 EAP to 6.1. I'm getting this issue when I try to use an EJB:

NamingException JBAS011843: Failed instantiate InitialContextFactory com.sun.jndi.cosnaming.CNCtxFactory from classloader ModuleClassLoader for Module "deployment.my.ear.my.war:main" from Service Module Loader
13:34:14,304 INFO  [stdout]  javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory com.sun.jndi.cosnaming.CNCtxFactory from classloader ModuleClassLoader for Module "deployment.my.ear.my.war:main" from Service Module Loader
13:34:14,304 INFO  [stdout]          at org.jboss.as.naming.InitialContextFactoryBuilder.createInitialContextFactory(InitialContextFactoryBuilder.java:64)
13:34:14,304 INFO  [stdout]          at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:681)
13:34:14,305 INFO  [stdout]         

The code this error comes from is:

new InitialContext("{java.naming.provider.url=corbaloc::server:port, java.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory}");

This worked fine on JBoss 5.1, but not 6.1. I checked and that class exists on 6.1, not sure why I am getting this error.

EDIT: Also, this is moving from JDK 6 to JDK 7.

  • 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.

  • You 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> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM