HHH000342:无法获得与查询元数据的连接:无法构造请求的方言[org.hibernate.方言.DB2400对话]



我的构建成功,但在Windows上使用Wildfly 16进行部署失败。在我的macbook上它是有效的。

Windows OpenJDK 1.8.0_252。Macbook OpenJDK 1.8.0_251

Wildfly 16配置,例如Windows和我的Mac上的驱动程序是相等的。

这里有人知道线索吗?我错过了什么。

提前感谢您的关注。非常感谢你的帮助。

applicationContext.xml

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="YYY" />
<property name="persistenceXmlLocation" value="classpath:persistence.xml" />
<property name="dataSource" ref="yyyDataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="false" />
<property name="generateDdl" value="false" />
<property name="databasePlatform" value="org.hibernate.dialect.DB2400Dialect" />
</bean>
</property>
<property name="loadTimeWeaver">
<bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
</property>
</bean>

persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="YYY" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/jdbc/xxx/YYYDB</jta-data-source>
<class>nl.xxxx.xx.xxx.xxx</class>
<class>nl.xxxx.xx.xxx.xxx</class>
<properties>
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.dialect" value="org.hibernate.dialect.DB2400Dialect" />
<!--<property name="javax.persistence.sharedCache.mode" value="ALL"/> -->
</properties>
</persistence-unit>
</persistence>

pom.xml

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.1.3.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.1.3.Final</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.2.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.2.4.RELEASE</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.2.4.RELEASE</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws</artifactId>
<version>2.1.4.RELEASE</version>
<classifier>all</classifier>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
<version>2.2.2.RELEASE</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
<exclusion>
<artifactId>spring-beans</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-aop</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>4.2.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>4.2.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>4.2.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>4.3.2.RELEASE</version>
</dependency>

standalone.xml

<datasource jta="true" jndi-name="java:/jdbc/xxx/YYYDB" pool-name="YYYDB" enabled="true" use-ccm="false">
<connection-url>jdbc:db2://xxxxxx.xxx.net:xxxx/xxxxx</connection-url>
<driver-class>com.ibm.db2.jcc.DB2Driver</driver-class>
<driver>db2</driver>
<new-connection-sql>SELECT current date FROM sysibm.sysdummy1</new-connection-sql>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<pool>
<max-pool-size>5</max-pool-size>
</pool>
<security>
<user-name>yyy02</user-name>
<password>${VAULT::vault::yyy02::1}</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>

Stacktrace

09:27:44,076 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 1) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "xxxx-services-ear.ear")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.subunit."xxxx-services-ear.ear"."xxxxx-services-xxx.war".undertow-deployment" => "java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [config/spring/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Caused by: java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [config/spring/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [config/spring/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Caused by: org.hibernate.HibernateException: Unable to construct requested dialect [org.hibernate.dialect.DB2400Dialect]
Caused by: java.lang.ClassCastException: org.hibernate.dialect.DB2400Dialect cannot be cast to org.hibernate.dialect.Dialect"}}
09:27:44,077 ERROR [org.jboss.as.server] (management-handler-thread - 1) WFLYSRV0021: Deploy of deployment "xxxx-services-ear.ear" was rolled back with the following failure message: 
{"WFLYCTL0080: Failed services" => {"jboss.deployment.subunit."xxxx-services-ear.ear"."xxxx-services-xxx.war".undertow-deployment" => "java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [config/spring/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Caused by: java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [config/spring/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [config/spring/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Caused by: org.hibernate.HibernateException: Unable to construct requested dialect [org.hibernate.dialect.DB2400Dialect]
Caused by: java.lang.ClassCastException: org.hibernate.dialect.DB2400Dialect cannot be cast to org.hibernate.dialect.Dialect"}}
09:27:44,089 DEBUG [org.jboss.as.ejb3.deployment] (MSC service thread 1-8) unRegistering EJB client context for classloader ModuleClassLoader for Module "deployment.xxxx-services-ear.ear" from Service Module Loader
09:27:44,091 DEBUG [org.jboss.as.ejb3.deployment] (MSC service thread 1-5) unRegistering EJB client context for classloader ModuleClassLoader for Module "deployment.xxxx-services-ear.ear.xxxx-services-xxx.war" from Service Module Loader
09:27:44,095 DEBUG [org.wildfly.extension.batch] (MSC service thread 1-1) Removing batch environment; ModuleClassLoader for Module "deployment.xxxx-services-ear-.ear.xxxx-services-xxx.war" from Service Module Loader
09:27:44,111 DEBUG [org.infinispan.manager.DefaultCacheManager] (MSC service thread 1-7) Stopping cache manager null on null
09:27:44,118 DEBUG [org.infinispan.manager.DefaultCacheManager] (MSC service thread 1-7) Stopped cache manager null
09:27:44,118 DEBUG [org.jboss.as.clustering.infinispan] (MSC service thread 1-7) frontend-services-cache cache container stopped
09:27:44,462 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0208: Stopped subdeployment (runtime-name: xxxx-services-xxx.war) in 383ms
09:27:44,951 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0028: Stopped deployment xxxx-services-ear.ear (runtime-name: frontend-services-ear-2.21.0-SNAPSHOT.ear) in 873ms
[2020-07-28 09:27:45,090] Artifact xxxxx-services-ear:ear: Error during artifact deployment. See server log for details.
[2020-07-28 09:27:45,091] Artifact xxxxx-services-ear.ear: java.lang.Exception: {"WFLYCTL0080: Failed services" => {"jboss.deployment.subunit."xxxxx-services-ear.ear"."xxxx-services-xxx.war".undertow-deployment" => "java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [config/spring/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Caused by: java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [config/spring/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [config/spring/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Caused by: org.hibernate.HibernateException: Unable to construct requested dialect [org.hibernate.dialect.DB2400Dialect]
Caused by: java.lang.ClassCastException: org.hibernate.dialect.DB2400Dialect cannot be cast to org.hibernate.dialect.Dialect"}}
09:27:52,669 INFO  [org.jboss.as.server] (management-handler-thread - 1) WFLYSRV0272: Suspending server
09:27:52,677 INFO  [org.jboss.as.ejb3] (management-handler-thread - 1) WFLYEJB0493: EJB subsystem suspension complete
09:27:52,680 DEBUG [org.jboss.remoting.remote.connection] (management I/O-2) JBREM000200: Remote connection failed: java.io.IOException: An existing connection was forcibly closed by the remote host
09:27:52,682 INFO  [org.jboss.as.server] (Management Triggered Shutdown) WFLYSRV0241: Shutting down in response to management operation 'shutdown'

我认为这是一个类加载问题。

首先,Wildfly 16使用5.3.9.hibernate的最终版本,因此您应该将pom更改为此版本。其次,所有这些hibernate jar都是由Wildfly自动提供的,所以它们的作用域应该是pom.xml中的provided,因为不应该将它们包含在最终的war/ear文件中。

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.3.9.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.3.9.Final</version>
<scope>provided</scope>
</dependency>
<dependency>

相关内容

最新更新