java - JBoss AS 7 : how to make independant deployment of EJB and dependent WAR?

标签 java ejb classpath ejb-3.0 jboss7.x

我有一个包含一个 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/

相关文章:

java - 如何使用 Java 中的 SQL 修复已创建的表和值未显示在控制台中的问题?

java - 问题追踪网络 "stability"问题根源

jakarta-ee - 无状态 bean 不工作

java - 使用事务测试 EJB 而不将其部署到容器中?

android - java.lang.ClassNotFoundException : Didn't find class on DexPathList 异常

java - 在 JButton 中重写 PaintComponent() 会产生意外结果

java - 如何通过单击按钮选中所有复选框

java - 我的 EJB 抛出需要事务的异常,尽管另一个 EJB 以相同方式设置且具有相同持久性单元不会抛出任何异常

java - 将 jar 添加到简单 java 项目后出现 ClassDefNotFoundException

clojure - 是否可以将特定的 JAR 添加到 nrepl 服务器使用的 Clojure 类路径中?