gpt4 book ai didi

java - 从 Glassfish 迁移到 Wildfly/JBoss

转载 作者:行者123 更新时间:2023-11-29 18:58:19 25 4
gpt4 key购买 nike

我正在尝试在 JBoss (wildfly-10.1.0.Final) 中运行我的 .ear 应用程序。之前它在 Glassfish 4.1 上运行没有任何问题。在 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)

在这两种情况下,我都使用eclipselinkMySQL

我尝试使用与 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>

这些异常(exception)没有任何意义,因为相同的方法在 glassfish 上效果很好。这些异常的原因可能是什么?

最佳答案

出于某种原因,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>

关于java - 从 Glassfish 迁移到 Wildfly/JBoss,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44023894/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com