从JBoss EAP 5.1发布移动耳机到6.1

时间:2013-08-16 17:44:14

标签: java jboss ejb jboss-eap-6

我正在尝试将一个ear文件从JBoss 5.1 EAP移到6.1。当我尝试使用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]         

此错误来自的代码是:

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

这在JBoss 5.1上运行良好,但不是6.1。我检查过该类存在于6.1,不知道为什么我收到此错误。

编辑:此外,这是从JDK 6转移到JDK 7.

1 个答案:

答案 0 :(得分:1)

  • 由于EAP是如此模块化,以至于有时甚至没有拿起jre库。我们需要在jboss-deployment-structure.xml中提及它,以便应用程序在部署时不会失败。

  • 您需要使用以下内容在EAR_Name \ META-INF中创建jboss-deployment-structure.xml:

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