используйте Quarkus и Hibernate с db2 / 400 - PullRequest
0 голосов
/ 11 марта 2020

Я пытаюсь использовать Quarkus Hibernate ORM с db2 на IBM i под управлением V7R3

При запуске Quarkus, похоже, не находит org.hibernate.dialect.DB2400V7R3Dialect. Он доступен как часть Hibernate * 1003. *

У меня есть jt400 в качестве зависимости в моем pom для источника данных DB2 / 400 JDB C.

Итак ... похоже, что Quarkus не поддерживает DB2 / 400 из коробки. Я что-то упустил?

Это мои application.properties

quarkus.datasource.driver=com.ibm.as400.access.AS400JDBCDataSource
quarkus.datasource.url=jdbc:as400://<my host>;prompt=false;translate binary=true;
quarkus.datasource.username=******
quarkus.datasource.password=******
quarkus.hibernate-orm.database.default-schema=<my schema>
quarkus.hibernate-orm.dialect=org.hibernate.dialect.DB2400V7R3Dialect
quarkus.hibernate-orm.log.sql=true

, когда я пытаюсь запустить quarkus

D:\dev\cmf\2e\api\workspace2\y2sy>.\mvnw compile quarkus:dev
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< com.cmfirsttech:y2sy >------------------------
[INFO] Building y2sy 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ y2sy ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ y2sy ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- quarkus-maven-plugin:1.2.1.Final:dev (default-cli) @ y2sy ---
Listening for transport dt_socket at address: 5005
16:31:10,396 INFO  [org.jbo.threads] JBoss Threads version 3.0.0.Final
16:31:10,564 INFO  [org.hib.jpa.boo.int.PersistenceXmlParser] HHH000318: Could not find any META-INF/persistence.xml file in the classpath
16:31:10,661 INFO  [org.hib.Version] HHH000412: Hibernate Core {5.4.10.Final}
16:31:11,723 INFO  [org.hib.ann.com.Version] HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
16:31:11,859 ERROR [io.qua.dev.DevModeMain] Failed to start Quarkus: java.lang.ExceptionInInitializerError
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:348)
        at io.quarkus.runner.RuntimeRunner.run(RuntimeRunner.java:153)
        at io.quarkus.dev.DevModeMain.doStart(DevModeMain.java:178)
        at io.quarkus.dev.DevModeMain.start(DevModeMain.java:96)
        at io.quarkus.dev.DevModeMain.main(DevModeMain.java:67)
Caused by: java.lang.RuntimeException: Failed to start quarkus
        at io.quarkus.runner.ApplicationImpl.<clinit>(ApplicationImpl.zig:432)
        ... 6 more
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:275)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
        at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:152)
        at io.quarkus.hibernate.orm.runtime.service.QuarkusMutableIdentifierGeneratorFactory.injectServices(QuarkusMutableIdentifierGeneratorFactory.java:80)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:286)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:243)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
        at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:175)
        at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:118)
        at io.quarkus.hibernate.orm.runtime.boot.FastBootMetadataBuilder.build(FastBootMetadataBuilder.java:342)
        at io.quarkus.hibernate.orm.runtime.PersistenceUnitsHolder.createMetadata(PersistenceUnitsHolder.java:111)
        at io.quarkus.hibernate.orm.runtime.PersistenceUnitsHolder.constructMetadataAdvance(PersistenceUnitsHolder.java:84)
        at io.quarkus.hibernate.orm.runtime.PersistenceUnitsHolder.initializeJpa(PersistenceUnitsHolder.java:47)
        at io.quarkus.hibernate.orm.runtime.HibernateOrmRecorder$4.created(HibernateOrmRecorder.java:75)
        at io.quarkus.arc.runtime.ArcRecorder.initBeanContainer(ArcRecorder.java:101)
        at io.quarkus.deployment.steps.ArcProcessor$generateResources25.deploy_0(ArcProcessor$generateResources25.zig:429)
        at io.quarkus.deployment.steps.ArcProcessor$generateResources25.deploy(ArcProcessor$generateResources25.zig:36)
        at io.quarkus.runner.ApplicationImpl.<clinit>(ApplicationImpl.zig:378)
        ... 6 more
Caused by: org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [org.hibernate.dialect.DB2400V7R3Dialect] as strategy [org.hibernate.dialect.Dialect]
        at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:133)
        at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.resolveStrategy(StrategySelectorImpl.java:212)
        at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.resolveDefaultableStrategy(StrategySelectorImpl.java:160)
        at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.resolveDefaultableStrategy(StrategySelectorImpl.java:147)
        at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.resolveStrategy(StrategySelectorImpl.java:141)
        at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.constructDialect(DialectFactoryImpl.java:74)
        at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:51)
        at io.quarkus.hibernate.orm.runtime.recording.RecordingDialectFactory.buildDialect(RecordingDialectFactory.java:20)
        at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:137)
        at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)
        at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:101)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263)
        ... 24 more
Caused by: org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [org.hibernate.dialect.DB2400V7R3Dialect]
        at io.quarkus.hibernate.orm.runtime.service.FlatClassLoaderService.classForName(FlatClassLoaderService.java:38)
        at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:129)
        ... 35 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.dialect.DB2400V7R3Dialect
        at io.quarkus.runner.RuntimeClassLoader.findClass(RuntimeClassLoader.java:242)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at io.quarkus.runner.RuntimeClassLoader.loadClass(RuntimeClassLoader.java:181)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:348)
        at io.quarkus.hibernate.orm.runtime.service.FlatClassLoaderService.classForName(FlatClassLoaderService.java:36)
        ... 36 more

мой pom

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.cmfirsttech</groupId>
  <artifactId>y2sy</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <properties>
    <compiler-plugin.version>3.8.1</compiler-plugin.version>
    <maven.compiler.parameters>true</maven.compiler.parameters>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <quarkus-plugin.version>1.2.1.Final</quarkus-plugin.version>
    <quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
    <quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
    <quarkus.platform.version>1.2.1.Final</quarkus.platform.version>
    <surefire-plugin.version>2.22.1</surefire-plugin.version>
  </properties>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>${quarkus.platform.group-id}</groupId>
        <artifactId>${quarkus.platform.artifact-id}</artifactId>
        <version>${quarkus.platform.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-resteasy</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-junit5</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.rest-assured</groupId>
      <artifactId>rest-assured</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-hibernate-validator</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-smallrye-openapi</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-jackson</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-resteasy-jackson</artifactId>
    </dependency>
    <dependency>
        <groupId>net.sf.jt400</groupId>
        <artifactId>jt400-jdk8</artifactId>
        <version>10.2</version>
    </dependency>
    <dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-hibernate-orm-panache</artifactId>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-maven-plugin</artifactId>
        <version>${quarkus-plugin.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>build</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${compiler-plugin.version}</version>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${surefire-plugin.version}</version>
        <configuration>
          <systemProperties>
            <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
          </systemProperties>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <profile>
      <id>native</id>
      <activation>
        <property>
          <name>native</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>${surefire-plugin.version}</version>
            <executions>
              <execution>
                <goals>
                  <goal>integration-test</goal>
                  <goal>verify</goal>
                </goals>
                <configuration>
                  <systemProperties>
                    <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
                  </systemProperties>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
      <properties>
        <quarkus.package.type>native</quarkus.package.type>
      </properties>
    </profile>
  </profiles>
</project>

Ответы [ 2 ]

1 голос
/ 13 марта 2020

DB2400V7R3Dialect еще не существует в спящем варианте, который использует quarkus. Не могли бы вы попробовать org.hibernate.dialect.DB2400Dialect?

Я создал небольшой проект для воспроизведения и протестировал его на моем db2 / as400. https://github.com/Postremus/quarkus-db-as400-test

Кажется, что работает.

Основные различия: я использую net.sf.jt400:jt400:8.5 в качестве драйвера, который немного старше вашей версии.

Мои application.properties выглядят немного иначе:

quarkus.datasource.url=jdbc url
quarkus.datasource.driver=com.ibm.as400.access.AS400JDBCDriver
quarkus.hibernate-orm.dialect=org.hibernate.dialect.DB2400Dialect
quarkus.datasource.min-size=0
quarkus.datasource.max-size=10
quarkus.hibernate-orm.database.generation=drop-and-create
0 голосов
/ 11 марта 2020

Попробуйте в приложении .dialect

...