2017-05-17 203 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>