2015-06-13 111 views
1

我试图用EJB,JPA和Web元素创建EAR项目。 我有连接到数据库,认为它工作正常。但是我无法从EJB项目中注入bean。如何使用JPA,EJB和CDI元素创建JBoss EAR项目

这里是我的配置: 在EAR项目EarContent/META-INF/application.xml中:

<?xml version="1.0" encoding="UTF-8"?> 
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd" id="Application_ID" version="7"> 
    <display-name>Fantasy</display-name> 
    <module> 
    <ejb>FantasyEjb.jar</ejb> 
    </module> 
    <module> 
    <web> 
     <web-uri>FantasyWeb.war</web-uri> 
     <context-root>FantasyWeb</context-root> 
    </web> 
    </module> 
</application> 

在EAR项目EarContent/WEB-INF/jboss的部署,structure.xml:

<?xml version="1.0"?> 
<jboss-deployment-structure> 
    <deployment> 
     <exclusions> 
      <module name="javax.faces.api" /> 
      <module name="com.sun.jsf-impl" /> 
     </exclusions> 
     <dependencies> 
      <module name="org.apache.log4j" /> 
      <module name="org.dom4j" /> 
      <module name="org.apache.commons.logging" /> 
      <module name="org.apache.commons.collections" /> 
      <module name="javax.faces.api" /> 
      <module name="com.sun.jsf-impl" /> 
     </dependencies> 
    </deployment> 
</jboss-deployment-structure> 

在JPA项目文件的persistence.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<persistence version="2.1" 
    xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> 
    <persistence-unit name="JPADB"> 
     <jta-data-source>java:jboss/datasources/AGHDS</jta-data-source> 
     <properties> 
      <property name="showSql" value="true"/> 
      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" /> 
      <property name="hibernate.hbm2ddl.auto" value="create-drop" /> 
     </properties> 
    </persistence-unit> 
</persistence> 

在EJB项目的ejbModule /META-INF/ejb-jar.xml

<?xml version="1.0" encoding="UTF-8"?> 
<ejb-jar version="3.2" xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/ejb-jar_3_2.xsd"> 
    <display-name>FantasyEjb</display-name> 
</ejb-jar> 

在WEB项目的WebContent/WEB-INF/beans.xml文件:

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" 
    bean-discovery-mode="all"> 
</beans> 

现在我已经在EJB项目TestBean.java一个bean:

package com.fantasy.beans; 

import java.io.Serializable; 
import java.util.List; 

import javax.ejb.Stateless; 
import javax.persistence.EntityManager; 
import javax.persistence.PersistenceContext; 
import javax.persistence.Query; 

import com.fantasy.db.model.Elfs; 

@Stateless 
public class TestBean implements Serializable{ 

    private static final long serialVersionUID = 1L; 

    @PersistenceContext(unitName = "JPADB") 
    private EntityManager em; 

    public List<Elfs> query() { 
     Query query = em.createQuery("FROM com.fantasy.db.model.Elfs"); 

     @SuppressWarnings("unchecked") 
     List <Elfs> list = query.getResultList(); 
     return list; 
    } 
} 

而在WEB项目我有类Producer.java哪想在JSF页面中使用:

package com.fantasy.web; 

import java.io.Serializable; 
import java.util.List; 

import javax.annotation.PostConstruct; 
import javax.enterprise.context.RequestScoped; 
import javax.enterprise.inject.Produces; 
import javax.inject.Inject; 
import javax.inject.Named; 

import com.fantasy.beans.TestBean; 
import com.fantasy.db.model.Elfs; 

@Named(value = "blogEntryBean") 
@RequestScoped 
public class Producer implements Serializable { 

    private static final long serialVersionUID = 1L; 

    @Inject 
    TestBean bean; 

    private List<Elfs> beans; 

    @Produces 
    @Named 
    public List<Elfs> getBeans() { 
     return beans; 
    } 

    public void setBeans(List<Elfs> beans) { 
     this.beans = beans; 
    } 

    @PostConstruct 
    public void retrieveAllSeatsOrderedByName() { 
     beans = bean.query(); 


    } 
} 

问题出在annoation @inject上。不显示错误 - 但我需要与我的ejb同步。我想我可能会错过一些依赖关系,但我不知道如何解决它。

登录:

01:14:02,294 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) HHH000227: Running hbm2ddl schema export 
01:14:02,390 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) HHH000230: Schema export complete 
01:14:03,033 SEVERE [javax.enterprise.resource.webcontainer.jsf.flow] (MSC service thread 1-3) Unable to obtain CDI 1.1 utilities for Mojarra 
01:14:03,044 SEVERE [javax.enterprise.resource.webcontainer.jsf.application.view] (MSC service thread 1-3) Unable to obtain CDI 1.1 utilities for Moja 
rra 
01:14:03,173 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000001: Failed to start service jboss.deployment.unit."Fantasy.ear".WeldSt 
artService: org.jboss.msc.service.StartException in service jboss.deployment.unit."Fantasy.ear".WeldStartService: Failed to start service 
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.2.Final.jar:1.2.2.Final] 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_67] 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_67] 
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_67] 
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type TestBean with qualifiers @Default 
    at injection point [BackedAnnotatedField] @Inject com.fantasy.web.Producer.bean 
    at com.fantasy.web.Producer.bean(Producer.java:0) 

    at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:372) 
    at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:293) 
    at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:134) 
    at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:167) 
    at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:531) 
    at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:68) 
    at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:66) 
    at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60) 
    at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:262) [rt.jar:1.7.0_67] 
    ... 3 more 

01:14:03,183 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("deploy") failed - address: ([("depl 
oyment" => "Fantasy.ear")]) - failure description: {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"Fantasy.ear\".WeldStartService" => "org 
.jboss.msc.service.StartException in service jboss.deployment.unit.\"Fantasy.ear\".WeldStartService: Failed to start service 
    Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type TestBean with qualifiers @Default 
    at injection point [BackedAnnotatedField] @Inject com.fantasy.web.Producer.bean 
    at com.fantasy.web.Producer.bean(Producer.java:0) 
"}} 
01:14:03,253 INFO [org.jboss.as.server] (ServerService Thread Pool -- 28) JBAS018559: Deployed "Fantasy.ear" (runtime-name : "Fantasy.ear") 
01:14:03,257 INFO [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report 
JBAS014777: Services which failed to start:  service jboss.deployment.unit."Fantasy.ear".WeldStartService: org.jboss.msc.service.StartException 
in service jboss.deployment.unit."Fantasy.ear".WeldStartService: Failed to start service 

01:14:03,355 INFO [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management 
01:14:03,356 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990 
01:14:03,356 ERROR [org.jboss.as] (Controller Boot Thread) JBAS015875: WildFly 8.2.0.Final "Tweek" started (with errors) in 7986ms - Started 385 of 47 
3 services (22 services failed or missing dependencies, 108 services are lazy, passive or on-demand) 
01:14:03,500 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 51) JBAS011410: Stopping Persistence Unit (phase 2 of 2) Service 'Fantasy.ear#JPAD 
B' 
01:14:03,501 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 51) HHH000227: Running hbm2ddl schema export 
01:14:03,544 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 51) HHH000230: Schema export complete 
01:14:03,546 INFO [org.jboss.weld.deployer] (MSC service thread 1-7) JBAS016009: Stopping weld service for deployment Fantasy.ear 
01:14:03,580 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 51) JBAS011410: Stopping Persistence Unit (phase 1 of 2) Service 'Fantasy.ear#JPAD 
B' 
01:14:03,587 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015974: Stopped subdeployment (runtime-name: FantasyEjb.jar) in 99ms 
01:14:03,587 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015974: Stopped subdeployment (runtime-name: FantasyWeb.war) in 99ms 
01:14:03,589 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015877: Stopped deployment Fantasy.ear (runtime-name: Fantasy.ear) in 
101ms 
01:14:03,699 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018558: Undeployed "Fantasy.ear" (runtime-name: "Fantasy.ear") 
01:14:03,704 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report 
JBAS014775: New missing/unsatisfied dependencies: 
     service jboss.deployment.subunit."Fantasy.ear"."FantasyEjb.jar".deploymentCompleteService (missing) dependents: [service jboss.deployment.unit." 
Fantasy.ear".deploymentCompleteService] 
     service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."com.sun.faces.config.ConfigureListener".CREATE (missing) dependents: 
[service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."com.sun.faces.config.ConfigureListener".START] 
     service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."com.sun.faces.config.ConfigureListener".START (missing) dependents: [ 
service jboss.undertow.deployment.default-server.default-host./FantasyWeb.UndertowDeploymentInfoService, service jboss.undertow.deployment.default-ser 
ver.default-host./FantasyWeb, service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".deploymentCompleteService] 
     service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."com.sun.faces.config.ConfigureListener".WeldInstantiator (missing) de 
pendents: [service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."com.sun.faces.config.ConfigureListener".START] 
     service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."javax.faces.webapp.FacesServlet".CREATE (missing) dependents: [servic 
e jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."javax.faces.webapp.FacesServlet".START] 
     service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."javax.faces.webapp.FacesServlet".START (missing) dependents: [service 
jboss.undertow.deployment.default-server.default-host./FantasyWeb.UndertowDeploymentInfoService, service jboss.undertow.deployment.default-server.def 
ault-host./FantasyWeb, service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".deploymentCompleteService] 
     service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."javax.faces.webapp.FacesServlet".WeldInstantiator (missing) dependent 
s: [service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."javax.faces.webapp.FacesServlet".START] 
     service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."javax.faces.webapp.FacetTag".CREATE (missing) dependents: [service jb 
oss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."javax.faces.webapp.FacetTag".START] 
     service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."javax.faces.webapp.FacetTag".START (missing) dependents: [service jbo 
ss.undertow.deployment.default-server.default-host./FantasyWeb.UndertowDeploymentInfoService, service jboss.undertow.deployment.default-server.default 
-host./FantasyWeb, service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".deploymentCompleteService] 
     service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."javax.faces.webapp.FacetTag".WeldInstantiator (missing) dependents: [ 
service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."javax.faces.webapp.FacetTag".START] 
     service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".CREATE (missing) depe 
ndents: [service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".START] 
     service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".START (missing) depen 
dents: [service jboss.undertow.deployment.default-server.default-host./FantasyWeb.UndertowDeploymentInfoService, service jboss.undertow.deployment.def 
ault-server.default-host./FantasyWeb, service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".deploymentCompleteService] 
     service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".WeldInstantiator (mis 
sing) dependents: [service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".START] 
     service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."javax.servlet.jsp.jstl.tlv.ScriptFreeTLV".CREATE (missing) dependents 
: [service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."javax.servlet.jsp.jstl.tlv.ScriptFreeTLV".START] 
     service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."javax.servlet.jsp.jstl.tlv.ScriptFreeTLV".START (missing) dependents: 
[service jboss.undertow.deployment.default-server.default-host./FantasyWeb.UndertowDeploymentInfoService, service jboss.undertow.deployment.default-s 
erver.default-host./FantasyWeb, service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".deploymentCompleteService] 
     service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."javax.servlet.jsp.jstl.tlv.ScriptFreeTLV".WeldInstantiator (missing) 
dependents: [service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."javax.servlet.jsp.jstl.tlv.ScriptFreeTLV".START] 
     service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."org.jboss.weld.servlet.WeldInitialListener".CREATE (missing) dependen 
ts: [service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."org.jboss.weld.servlet.WeldInitialListener".START] 
     service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."org.jboss.weld.servlet.WeldInitialListener".START (missing) dependent 
s: [service jboss.undertow.deployment.default-server.default-host./FantasyWeb.UndertowDeploymentInfoService, service jboss.undertow.deployment.default 
-server.default-host./FantasyWeb, service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".deploymentCompleteService] 
     service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."org.jboss.weld.servlet.WeldInitialListener".WeldInstantiator (missing 
) dependents: [service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."org.jboss.weld.servlet.WeldInitialListener".START] 
     service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."org.jboss.weld.servlet.WeldTerminalListener".CREATE (missing) depende 
nts: [service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."org.jboss.weld.servlet.WeldTerminalListener".START] 
     service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."org.jboss.weld.servlet.WeldTerminalListener".START (missing) dependen 
ts: [service jboss.undertow.deployment.default-server.default-host./FantasyWeb.UndertowDeploymentInfoService, service jboss.undertow.deployment.defaul 
t-server.default-host./FantasyWeb, service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".deploymentCompleteService] 
     service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."org.jboss.weld.servlet.WeldTerminalListener".WeldInstantiator (missin 
g) dependents: [service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."org.jboss.weld.servlet.WeldTerminalListener".START] 
     service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".deploymentCompleteService (missing) dependents: [service jboss.deployment.unit." 
Fantasy.ear".deploymentCompleteService] 
     service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".ee.ComponentRegistry (missing) dependents: [service jboss.undertow.deployment.de 
fault-server.default-host./FantasyWeb.UndertowDeploymentInfoService] 
     service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".jndiDependencyService (missing) dependents: [service jboss.deployment.subunit."F 
antasy.ear"."FantasyWeb.war".component."javax.faces.webapp.FacesServlet".START, service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".compon 
ent."javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".START, service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."org.jboss.weld. 
servlet.WeldInitialListener".START, service jboss.deployment.subunit."Fantasy.ear"."FantasyWeb.war".component."org.jboss.weld.servlet.WeldTerminalList 
ener".START, JBAS014799: ... and 4 more ] 
     service jboss.deployment.unit."Fantasy.ear".WeldBootstrapService (missing) dependents: [service jboss.deployment.unit."Fantasy.ear".CdiValidator 
FactoryService] 
     service jboss.deployment.unit."Fantasy.ear".WeldStartService (missing) dependents: [service jboss.deployment.unit."Fantasy.ear".CdiValidatorFact 
oryService] 
     service jboss.persistenceunit."Fantasy.ear#JPADB" (missing) dependents: [service jboss.deployment.unit."Fantasy.ear".deploymentCompleteService] 
     service jboss.undertow.deployment.default-server.default-host./FantasyWeb (missing) dependents: [service jboss.deployment.subunit."Fantasy.ear". 
"FantasyWeb.war".deploymentCompleteService] 
     service jboss.undertow.deployment.default-server.default-host./FantasyWeb.UndertowDeploymentInfoService (missing) dependents: [service jboss.und 
ertow.deployment.default-server.default-host./FantasyWeb] 
JBAS014777: Services which failed to start:  service jboss.deployment.unit."Fantasy.ear".WeldStartService 

01:14:08,291 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 2) JBAS015003: Found Fantasy.ear in deployment directory. To 
trigger deployment create a file called Fantasy.ear.dodeploy 
+0

对我来说,这看起来更像是一个Spring配置问题,所以我会建议添加Spring和Spring注释标记。 – hagrawal

+1

@hagrawal这不是一个春天的项目。这是一个Java EE项目。 –

+0

如果你用'@ EJB'而不是'@Inject'注入会发生什么?第二个建议:尝试在EJB jar中添加一个'beans.xml'。 –

回答

0

在Java EE 6(在JBoss AS 7.2),我通常解决此问题,通过在资源类创建EJB组件生产工作如下:

public class Resources { 
     @Produces 
     @EJB 
     private TestBean testBean; 
} 

这将允许你@Inject他们进一步下线。但是,Java EE 7中可能有更多优雅的解决方案。

0

我将您的代码复制并粘贴到多模块项目中并使用Maven构建它。

一旦部署到WildFly 8.2.0.Final,我得到:

22:38:17,236 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015876: Starting deployment of "FantasyEar.ear" (runtime-name: "FantasyEar.ear") 
22:38:17,291 INFO [org.jboss.as.server.deployment] (MSC service thread 1-10) JBAS015973: Starting subdeployment (runtime-name: "FantasyEjb.jar") 
22:38:17,291 INFO [org.jboss.as.server.deployment] (MSC service thread 1-6) JBAS015973: Starting subdeployment (runtime-name: "FantasyWeb.war") 
22:38:17,328 INFO [org.jboss.as.jpa] (MSC service thread 1-14) JBAS011401: Read persistence.xml for JPADB 
22:38:17,400 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 50) JBAS011409: Starting Persistence Unit (phase 1 of 2) Service 'FantasyEar.ear#JPADB' 
22:38:17,407 INFO [org.hibernate.jpa.internal.util.LogHelper] (ServerService Thread Pool -- 50) HHH000204: Processing PersistenceUnitInfo [ 
    name: JPADB 
    ...] 
22:38:17,450 INFO [org.hibernate.Version] (ServerService Thread Pool -- 50) HHH000412: Hibernate Core {4.3.7.Final} 
22:38:17,451 INFO [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 50) HHH000206: hibernate.properties not found 
22:38:17,452 INFO [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 50) HHH000021: Bytecode provider name : javassist 
22:38:17,496 INFO [org.jboss.weld.deployer] (MSC service thread 1-3) JBAS016002: Processing weld deployment FantasyEar.ear 
22:38:17,537 INFO [org.hibernate.validator.internal.util.Version] (MSC service thread 1-3) HV000001: Hibernate Validator 5.1.3.Final 
22:38:17,616 INFO [org.jboss.weld.deployer] (MSC service thread 1-4) JBAS016002: Processing weld deployment FantasyWeb.war 
22:38:17,617 INFO [org.jboss.weld.deployer] (MSC service thread 1-15) JBAS016002: Processing weld deployment FantasyEjb.jar 
22:38:17,621 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-15) JNDI bindings for session bean named TestBean in deployment unit subdeployment "FantasyEjb.jar" of deployment "FantasyEar.ear" are as follows: 

    java:global/FantasyEar/FantasyEjb/TestBean!com.fantasy.beans.TestBean 
    java:app/FantasyEjb/TestBean!com.fantasy.beans.TestBean 
    java:module/TestBean!com.fantasy.beans.TestBean 
    java:global/FantasyEar/FantasyEjb/TestBean 
    java:app/FantasyEjb/TestBean 
    java:module/TestBean 

22:38:17,668 INFO [org.jboss.weld.deployer] (MSC service thread 1-8) JBAS016005: Starting Services for CDI deployment: FantasyEar.ear 
22:38:17,690 INFO [org.jboss.weld.Version] (MSC service thread 1-8) WELD-000900: 2.2.6 (Final) 
22:38:17,700 INFO [org.jboss.weld.deployer] (MSC service thread 1-13) JBAS016008: Starting weld service for deployment FantasyEar.ear 
22:38:17,858 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 50) JBAS011409: Starting Persistence Unit (phase 2 of 2) Service 'FantasyEar.ear#JPADB' 
22:38:17,906 INFO [org.hibernate.annotations.common.Version] (ServerService Thread Pool -- 50) HCANN000001: Hibernate Commons Annotations {4.0.4.Final} 
22:38:18,198 INFO [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 50) HHH000400: Using dialect: org.hibernate.dialect.H2Dialect 
22:38:18,203 WARN [org.hibernate.dialect.H2Dialect] (ServerService Thread Pool -- 50) HHH000431: Unable to determine H2 database version, certain features may not work 
22:38:18,267 INFO [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (ServerService Thread Pool -- 50) HHH000397: Using ASTQueryTranslatorFactory 
22:38:18,466 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) HHH000227: Running hbm2ddl schema export 
22:38:18,471 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) HHH000389: Unsuccessful: drop sequence hibernate_sequence 
22:38:18,471 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) Sequence "HIBERNATE_SEQUENCE" not found; SQL statement: 
drop sequence hibernate_sequence [90036-173] 
22:38:18,472 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) HHH000230: Schema export complete 
22:38:18,962 INFO [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-7) Initializing Mojarra 2.2.8-jbossorg-1 20140822-1131 for context '/FantasyWeb' 
22:38:19,295 INFO [org.wildfly.extension.undertow] (MSC service thread 1-7) JBAS017534: Registered web context: /FantasyWeb 
22:38:19,335 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "FantasyEar.ear" (runtime-name : "FantasyEar.ear") 

我离开了唯一的办法就是在JBoss部署-structure.xml文件。此外,我确保每个部署描述符对于Java EE 7都是最新的。

http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd 
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd 
http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd 

并且没有beans.xml任何地方!

Fantasy.ear文件大小小于9kb。如果你的比这个大得多,那么你的罐子里就不需要它了。日志消息Unable to obtain CDI 1.1 utilities for Mojarra让我觉得你正在部署自己的JSF库。

为了繁荣,工作来源可以在https://github.com/sfcoy/fantasy-demo找到。

+0

所以也许我部署坏的库?问题是如何解决它? –

+0

移除每个包含** any **'javax。*'包中的类的jar。了解服务器将提供您需要的所有API和实现很重要。您需要针对它们进行编译,但不要将它们包含在可部署的工件中。 –

+0

@PrzemysławJasiński我在GitHub上发布了代码,仅供您使用;-) –