在jboss 7.1中,两个在不同EAR项目中具有相同名称的ejb jar文件相互冲突

D.R*_*.R. 0 ejb pom.xml jboss5.x maven jboss7.x

我正在将项目迁移Jboss 5.1jboss 7.1

我有两个EAR,运行在同一个Jboss上.它们包含内部的ejb项目,并且services.jar由于finalname标记而调用了两个ejb jar文件 EJB_PROJECT/pom.xml

    <build>
        <finalName>services</finalName>
            .....
    </build>
Run Code Online (Sandbox Code Playgroud)

在Jboss 5.1上它工作正常,但现在我得到错误:

    18:07:16,858 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC00001: Failed to start service jboss.deployment.subunit."my1.ear"."services.jar".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.subunit."my1.ear"."services.jar".INSTALL: Failed to process phase INSTALL of subdeployment "services.jar" of deployment "my1.ear"  
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]  
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]  
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]  
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_45]  
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_45]  
    at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_45]  
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS018027: Failed to add JBoss Web deployment service  
    at org.jboss.as.web.deployment.WarDeploymentProcessor.processDeployment(WarDeploymentProcessor.java:320)  
    at org.jboss.as.web.deployment.WarDeploymentProcessor.deploy(WarDeploymentProcessor.java:114)  
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]  
    ... 5 more  
Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.web.deployment.default-host./services.realm is already registered  
    at org.jboss.msc.service.ServiceRegistrationImpl.setInstance(ServiceRegistrationImpl.java:154) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]  
    at org.jboss.msc.service.ServiceControllerImpl.startInstallation(ServiceControllerImpl.java:227) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]  
    at org.jboss.msc.service.ServiceContainerImpl.install(ServiceContainerImpl.java:560) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]  
    at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:201) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]  
    at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2228) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]  
    at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:201) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]  
    at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2228) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]  
    at org.jboss.msc.service.ServiceBuilderImpl.install(ServiceBuilderImpl.java:307) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]  
    at org.jboss.as.web.deployment.WarDeploymentProcessor.processDeployment(WarDeploymentProcessor.java:269)  
    ... 7 more  
Run Code Online (Sandbox Code Playgroud)

有没有办法在不改变finalname标签价值的情况下完成这项工作?如果我更改它,然后我的应用程序的URL更改,我不希望这样.

eis*_*eis 5

尝试在EJB的META-INF/ejb-jar.xml中使用它:

<?xml version="1.0" encoding="UTF-8"?>
<javaee:ejb-jar version="3.1"
    xmlns:javaee="http://java.sun.com/xml/ns/javaee"
    xmlns:xml="http://www.w3.org/XML/1998/namespace"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
        http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd">

    <javaee:module-name>some-name-you-want-for-your-ejb</javaee:module-name>
</javaee:ejb-jar>
Run Code Online (Sandbox Code Playgroud)

根据EJB规范,它应该覆盖JNDI的文件名.例如,在EJB FAQ中阐明了这一点:

<module-name>默认为ejb-jar文件的非限定名称或定义EJB组件的.war文件,减去文件扩展名.可以使用ejb-jar.xml的<module-name>元素(对于ejb-jars)或web.xml(对于.wars中定义的EJB组件)显式指定<module-name>.