2017-05-17 151 views
0

我试图运行我的.ear应用程序JBoss(wildfly-10.1.0.Final)。 此前它与Glassfish 4.1没有任何问题。 在JBoss上,我成功部署了它,但是它抛出了很多例外。从Glassfish迁移到Wildfly/JBoss

例如:

2017-05-17 13:42:00,911 ERROR [org.jboss.as.ejb3.invocation] (default task-18) WFLYEJB0034: EJB Invocation failed on component VersionDao for method public abstract java.util.List com.valor.anthillprodashboard.db.dao.VersionDaoLocal.getAllVersions(): javax.ejb.EJBTransactionRolledbackException: NamedQuery of name: Version.findAll not found. 
      at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleInCallerTx(CMTTxInterceptor.java:159) 

2017-05-17 13:40:03,504 ERROR [org.jboss.as.ejb3.invocation] (default task-110) WFLYEJB0034: EJB Invocation failed on component DataAccessFacade for method public abstract java.util.List com.valor.anthillprodashboard.bl.da.DataAccessFacadeLocal.getAllVersions(): javax.ejb.EJBTransactionRolledbackException: NamedQuery of name: Version.findAll not found. 
    at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleInCallerTx(CMTTxInterceptor.java:159) 

在这两种情况下,我使用的EclipseLink & 的MySQL

我试着用Glassfish中的相同参数配置JBoss。

Glassfish的配置:

  • JDBC资源:JDBC Resource
  • JDBC连接池:JDBC Connection Pool

JBoss的配置(从standalone.xml):

<datasources> 
    <datasource jta="true" jndi-name="java:/jdbc/anthillprodashboard" pool-name="mysql_anthillprodashboard_rootPool" enabled="true" use-java-context="true" use-ccm="true"> 
     <connection-url>jdbc:mysql://localhost:3306/anthillprodashboard?zeroDateTimeBehavior=convertToNull</connection-url> 
     <driver>mysql</driver> 
     <security> 
      <user-name>****</user-name> 
      <password>****</password> 
     </security> 
     <statement> 
      <prepared-statement-cache-size>100</prepared-statement-cache-size> 
      <share-prepared-statements>true</share-prepared-statements> 
     </statement> 
    </datasource> 
    <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true"> 
     <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url> 
     <driver>h2</driver> 
     <security> 
      <user-name>sa</user-name> 
      <password>sa</password> 
     </security> 
    </datasource> 
    <drivers> 
     <driver name="mysql" module="com.mysql"/> 
     <driver name="h2" module="com.h2database.h2"> 
      <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class> 
     </driver> 
    </drivers> 
</datasources> 

我的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="AnthillProDashboard-ejbPU" transaction-type="JTA"> 
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> 
    <jta-data-source>jdbc/anthillprodashboard</jta-data-source> 
    <exclude-unlisted-classes>false</exclude-unlisted-classes> 
    <shared-cache-mode>NONE</shared-cache-mode> 
    <properties> 
     <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyDialect"/> 
    </properties> 
    </persistence-unit> 
</persistence> 

例外的没有任何意义,因为同样的方法在GlassFish上工作得很好。 这些例外的原因是什么?

回答

0

出于某种原因,JBoss的无法识别的实体,我不得不在的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="AnthillProDashboard-ejbPU" transaction-type="JTA"> 
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> 
    <jta-data-source>jdbc/anthillprodashboard</jta-data-source> 
    <exclude-unlisted-classes>false</exclude-unlisted-classes> 
    <shared-cache-mode>NONE</shared-cache-mode> 
    <class>com.valor.anthillprodashboard.db.entity.Build</class> 
    <class>com.valor.anthillprodashboard.db.entity.Commit</class> 
    <class>com.valor.anthillprodashboard.db.entity.Project</class> 
    <class>com.valor.anthillprodashboard.db.entity.ProjectVersion</class> 
    <class>com.valor.anthillprodashboard.db.entity.ProjectVersionPK</class> 
    <class>com.valor.anthillprodashboard.db.entity.Status</class> 
    <class>com.valor.anthillprodashboard.db.entity.TestSet</class> 
    <class>com.valor.anthillprodashboard.db.entity.TestSetUpdate</class> 
    <class>com.valor.anthillprodashboard.db.entity.TestStatus</class> 
    <class>com.valor.anthillprodashboard.db.entity.Version</class> 
    <class>com.valor.anthillprodashboard.db.entity.Workflow</class> 

    <properties> 
     <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyDialect"/> 
    </properties> 
    </persistence-unit> 
</persistence>