我有一个包含一个 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
最佳答案
我终于成功地通过这个 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 来说是可以的,但对于其他应用程序服务器来说就不行。
关于java - JBoss AS 7 : how to make independant deployment of EJB and dependent WAR?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10152546/