2

我有一个带有一个 EJB ( mwf_ejb.jar) 和一个 WAR ( mwf_web.war) 的应用程序。如果我将它们打包在同一个 EAR 中,一切正常。有没有办法先部署 EJB,然后部署 WAR ?

如果我尝试一下,我的 EJB JAR 部署得很好,但是当我部署我的 WAR 时,我收到以下错误(在 JBoss AS 7.1.1 中):

MSC00001: Failed to start service jboss.deployment.unit."mwf_web.war".STRUCTURE:           org.jboss.msc.service.StartException in service jboss.deployment.unit."mwf_web.war".STRUCTURE: Failed to process phase STRUCTURE of deployment "mwf_web.war"
    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$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_31]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_31]
    at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_31]
Caused by: java.lang.IllegalArgumentException: Given parent is not an ancestor of this virtual file
    at org.jboss.vfs.VirtualFile.getPathNameRelativeTo(VirtualFile.java:116)
    at org.jboss.vfs.VirtualFile.getPathNameRelativeTo(VirtualFile.java:122)
    at org.jboss.vfs.VirtualFile.getPathNameRelativeTo(VirtualFile.java:122)
    at org.jboss.vfs.VirtualFile.getPathNameRelativeTo(VirtualFile.java:122)
    at org.jboss.vfs.VirtualFile.getPathNameRelativeTo(VirtualFile.java:122)
    at org.jboss.vfs.VirtualFile.getPathNameRelativeTo(VirtualFile.java:122)
    at org.jboss.vfs.VirtualFile.getPathNameRelativeTo(VirtualFile.java:122)
    at org.jboss.vfs.VirtualFile.getPathNameRelativeTo(VirtualFile.java:110)
    at org.jboss.as.server.deployment.module.ManifestClassPathProcessor.createAdditionalModule(ManifestClassPathProcessor.java:193) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.server.deployment.module.ManifestClassPathProcessor.handlingExistingClassPathEntry(ManifestClassPathProcessor.java:185) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.server.deployment.module.ManifestClassPathProcessor.deploy(ManifestClassPathProcessor.java:160) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    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

在 META-INF/MANIFEST.MF 中,我添加了一个“Class-Path”语句,以标准方式定义依赖关系:

Manifest-Version: 1.0
Dependencies: org.apache.log4j
Class-Path: mwf_ejb.jar
4

1 回答 1

3

我终于设法使它工作,这个MANIFEST.MF文件:

Manifest-Version: 1.0
Dependencies: org.apache.log4j, deployment.mwf_ejb.jar

另外,在我的@EJB注释中添加了一个查找属性(原来是空白的:@EJB):

@EJB(lookup="java:global/mwf_ejb/UserManager")

但是,我认为deployment.前缀对于 JBoss 是可以的,但对于其他应用程序服务器则不行。

于 2012-04-14T18:43:11.553 回答