与CDI交叉库依赖

时间:2015-03-06 10:31:21

标签: java jpa jboss7.x ejb-3.0 cdi

我做了很多'在过去48小时内谷歌搜索这个,我仍然空白,所以我希望这里的问题可能会有所帮助。

我正在开发一个switchyard服务(实际上我将开发一整套它们,因此这种方法)我希望将基于JPA的dao代码和实体放在一个单独的jar中,以及作为其他DTO /接口的另一个jar。

这两个其他jar包含CDI bean和beans.xmls,DAO jar包含一个有效的persistence.xml,它连接到我的JBoss应用服务器中的JDNI数据源。

我最初的想法是将两个罐装入EE模块,因为这似乎是一个明智的事情,这给我带来了CDI注入的问题,因为我的开关站应用程序看不到豆子,但我意识到只是module.xml没有配置适当的依赖关系以允许焊接加载CDI bean。

之后,我无法将持久性单元加载到DAO中。无论我在模块中还是在switchyard app中都有persistence.xml,实体管理器都会保持null。 (我在module.xml中确实有javax.persistence)

有些人阅读模块让我相信JPA不会对这种方法有所帮助(如果有人能指出我如何使其工作,那将回答这个问题!)

所以我切换到试图将我的switchyard服务罐与其他两个罐子捆绑在EAR中。

我的耳朵结构是:

+-
  sw-service.jar
  dao.jar
  dto.jar
  +-META-INF
    application.xml

我的application.xml包含

<application>
    <module>
        <java>sw-service.jar</java>
    </module>
    <module>
        <ejb>dao.jar</ejb>
    </module>
    <module>
        <ejb>dto.jar</ejb>
    </module>
</application>

当我尝试部署时,我收到以下错误:

10:00:51,794 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015876: Starting deployment of "sy-service-ear-deployment-assembly-0.0.1-SNAPSHOT.ear" (runtime-name: "sy-service-ear-deployment-assembly-0.0.1-SNAPSHOT.ear") 10:00:51,880 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "null" (runtime-name: "sy-service-0.0.1-SNAPSHOT.jar") 10:00:51,880 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015876: Starting deployment of "null" (runtime-name: "dao-0.0.1-SNAPSHOT.jar") 10:00:51,880 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of "null" (runtime-name: "dto-0.0.1-SNAPSHOT.jar") 10:00:51,905 INFO  [org.jboss.as.jpa] (MSC service thread 1-3) JBAS011401: Read persistence.xml for my_pu 10:00:51,974 INFO  [org.jboss.weld.deployer] (MSC service thread 1-5) JBAS016002: Processing weld deployment sy-service-ear-deployment-assembly-0.0.1-SNAPSHOT.ear 10:00:51,984 INFO  [org.jboss.weld.deployer] (MSC service thread 1-5) JBAS016002: Processing weld deployment sy-service-0.0.1-SNAPSHOT.jar 10:00:51,993 INFO  [org.jboss.weld.deployer] (MSC service thread 1-6) JBAS016002: Processing weld deployment dao-0.0.1-SNAPSHOT.jar 10:00:51,985 INFO  [org.jboss.weld.deployer] (MSC service thread 1-3) JBAS016002: Processing weld deployment dto-0.0.1-SNAPSHOT.jar 10:00:52,026 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-6) JNDI bindings for session bean named ActivitiesDAO in deployment unit subdeployment "dao-0.0.1-SNAPSHOT.jar" of deployment "sy-service-ear-deployment-assembly-0.0.1-SNAPSHOT.ear" are as follows:

        java:global/sy-service-ear-deployment-assembly-0.0.1-SNAPSHOT/dao-0.0.1-SNAPSHOT/ActivitiesDAO!org.test.rich.dao.ActivitiesDAO
        java:app/dao-0.0.1-SNAPSHOT/ActivitiesDAO!org.test.rich.dao.ActivitiesDAO
        java:module/ActivitiesDAO!org.test.rich.dao.ActivitiesDAO
        java:global/sy-service-ear-deployment-assembly-0.0.1-SNAPSHOT/dao-0.0.1-SNAPSHOT/ActivitiesDAO
        java:app/dao-0.0.1-SNAPSHOT/ActivitiesDAO
        java:module/ActivitiesDAO   10:00:52,076 INFO  [org.jboss.weld.deployer] (MSC service thread 1-6) JBAS016005: Starting Services for CDI deployment: sy-service-ear-deployment-assembly-0.0.1-SNAPSHOT.ear 10:00:52,102 INFO  [org.jboss.weld.deployer] (MSC service thread 1-4) JBAS016008: Starting weld service for deployment sy-service-ear-deployment-assembly-0.0.1-SNAPSHOT.ear 10:00:52,103 INFO  [org.switchyard] (MSC service thread 1-1) Deploying SwitchYard application 'sy-service-0.0.1-SNAPSHOT.jar' 10:00:52,233 INFO  [org.switchyard] (MSC service thread 1-6) Deploying SwitchYard application 'dao-0.0.1-SNAPSHOT.jar' 10:00:52,239 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-6) MSC000001: Failed to start service jboss.deployment.subunit."sy-service-ear-deployment-assembly-0.0.1-SNAPSHOT.ear"."dao-0.0.1-SNAPSHOT.jar".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.subunit."sy-service-ear-deployment-assembly-0.0.1-SNAPSHOT.ear"."dao-0.0.1-SNAPSHOT.jar".INSTALL: JBAS 018733: Failed to process phase INSTALL of subdeployment "dao-0.0.1-SNAPSHOT.jar" of deployment "sy-service-ear-deployment-assembly-0.0.1-SNAPSHOT.ear"
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:127) [jboss-as-server-7.2.1.Final-redhat-10.jar:7.2.1.Final-redhat-10]
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_75]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_75]
        at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_75] Caused by: java.lang.NullPointerException
        at org.switchyard.as7.extension.deployment.SwitchYardDeploymentProcessor.deploy(SwitchYardDeploymentProcessor.java:119)
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:120) [jboss-as-server-7.2.1.Final-redhat-10.jar:7.2.1.Final-redhat-10]
        ... 5 more   10:00:52,485 ERROR [org.jboss.as.server] (DeploymentScanner-threads - 1) JBAS015870: Deploy of deployment "sy-service-ear-deployment-assembly-0.0.1-SNAPSHOT.ear" was rolled back with the following failure message: {
    "JBAS014671: Failed services" => {"jboss.deployment.subunit.\"sy-service-ear-deployment-assembly-0.0.1-SNAPSHOT.ear\".\"dao-0.0.1-SNAPSHOT.jar\".INSTALL"
=> "org.jboss.msc.service.StartException in service jboss.deployment.subunit.\"sy-service-ear-deployment-assembly-0.0.1-SNAPSHOT.ear\".\"dao-0.0.1-SNAPSHOT.jar\".INSTALL: JBAS018733: Failed to process phase INSTALL of subdeployment\"dao-0.0.1-SNAPSHOT.jar\" of deployment \"sy-service-ear-deployment-assembly-0.0.1-SNAPSHOT.ear\"
    Caused by: java.lang.NullPointerException"},
    "JBAS014771: Services with missing/unavailable dependencies" => [
        "jboss.deployment.unit.\"sy-service-ear-deployment-assembly-0.0.1-SNAPSHOT.ear\".deploymentCompleteService is missing [jboss.deployment.subunit.\"sy-service-ear-deployment-assembly-0.0.1-SNAPSHOT.ear\".\"dao-0.0.1-SNAPSHOT.jar\".deploymentCompleteService]",
        "jboss.deployment.unit.\"sy-service-ear-deployment-assembly-0.0.1-SNAPSHOT.ear\".WeldStartService is missing [jboss.persistenceunit.\"sy-service-ear-deployment-assembly-0.0.1-SNAPSHOT.ear/dao-0.0.1-SNAPSHOT.jar#my_pu\"]",
        "jboss.naming.context.java.comp.\"sy-service-ear-deployment-assembly-0.0.1-SNAPSHOT\".\"dao-0.0.1-SNAPSHOT\".ActivitiesDAO.Validator is missing [jboss.naming.context.java.comp.\"sy-service-ear-deployment-assembly-0.0.1-SNAPSHOT\".\"dao-0.0.1-SNAPSHOT\".ActivitiesDAO]",
        "jboss.naming.context.java.comp.\"sy-service-ear-deployment-assembly-0.0.1-SNAPSHOT\".\"dao-0.0.1-SNAPSHOT\".ActivitiesDAO.ValidatorFactory is missing [jboss.naming.context.java.comp.\"sy-service-ear-deployment-assembly-0.0.1-SNAPSHOT\".\"dao-0.0.1-SNAPSHOT\".ActivitiesDAO]"
    ] } 10:00:52,496 INFO  [org.jboss.weld.deployer] (MSC service thread 1-1) JBAS016009: Stopping weld service for deployment sy-service-ear-deployment-assembly-0.0.1-SNAPSHOT.ear 10:00:52,560 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015877: Stopped deployment null (runtime-name: dto-0.0.1-SNAPSHOT.jar) in 74ms 10:00:52,562 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015877: Stopped deployment null (runtime-name: dao-0.0.1-SNAPSHOT.jar) in 76ms 10:00:52,561 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015877: Stopped deployment null (runtime-name: sy-service-0.0.1-SNAPSHOT.jar) in 75ms 10:00:52,578 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015877: Stopped deployment sy-service-ear-deployment-assembly-0.0.1-SNAPSHOT.ear (runtime-name: sy-service-ear-deployment-assembly-0.0.1-SNAPSHOT.ear) in 92ms

任何人都可以让我知道如何让切换器服务和JBoss模块之间的持久性单元,或者我在EAR文件中遗漏的内容,因为我完全不知道这个一个?

0 个答案:

没有答案