HHH000342: не удалось получить соединение с метаданными запроса: невозможно создать запрошенный диалект [org.hibernate.dialect.DB2400Dialect]

Моя сборка прошла успешно, но развертывание с использованием Wildfly 16 в Windows не удалось. На моем 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>

Трассировки стека

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'

1 ответ

Думаю, это проблема загрузки классов.

Прежде всего, Wildfly 16 использует версию 5.3.9.Final спящего режима, поэтому вам следует сменить свой pom на эту версию. Во-вторых, все эти jar-файлы для гибернации автоматически предоставляются Wildfly, поэтому они должны быть в области видимости.provided в вашем pom.xml потому что вы не должны включать их в свой окончательный файл 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>
Другие вопросы по тегам