当部署到JBoss应用服务器7.1时,HikariConnectionProvider ClassNotFoundException。

时间:2023-01-20 21:26:17

I built a DAL jar library which uses HikariCP as the connection provider. This jar is then included (as a Maven dependency) in a web application.

我构建了一个DAL jar库,它使用HikariCP作为连接提供程序。这个jar在web应用程序中被包括(作为Maven的依赖项)。

I tested this web application onto a Wildfly 8.0.0 application server and all works as expected: the deployment process ends without problems and I can access the DB with the web app.

我在一个Wildfly 8.0.0应用服务器上测试了这个web应用程序,所有的工作都和预期的一样:部署过程没有问题,我可以通过web应用程序访问数据库。

The problem raises when I run the same web application onto a JBoss Application Server 7.1. In fact, the deployment process ends with the following exception stack

当我将同一个web应用程序运行到JBoss应用程序服务器7.1时,问题就出现了。实际上,部署过程以下面的异常堆栈结束。

http://pastebin.com/qQh5EW1N

http://pastebin.com/qQh5EW1N

Here is the persistence.xml confgured in the DAL

这是持久性。xml在DAL中被混淆。

<?xml version="1.0" encoding="UTF-8"?>
<persistence 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"
             version="2.0">

    <persistence-unit name="DALPersistenceUnit" transaction-type="JTA">

        <provider>org.hibernate.ejb.HibernatePersistence</provider>

        <shared-cache-mode>NONE</shared-cache-mode>

        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>
            <property name="hibernate.connection.provider_class" value="com.zaxxer.hikari.hibernate.HikariConnectionProvider"/>
            <property name="hibernate.hikari.maximumPoolSize" value="100"/>
            <property name="hibernate.hikari.minimumIdle" value="20"/>
            <property name="hibernate.hikari.idleTimeout" value="30000"/>
            <property name="hibernate.hikari.dataSourceClassName" value="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"/>
            <property name="hibernate.hikari.dataSource.url" value="jdbc:mysql://URL:3306/DB"/>
            <property name="hibernate.hikari.dataSource.user" value="user"/>
            <property name="hibernate.hikari.dataSource.password" value="pwd"/>

            <property name="hibernate.archive.autodetection" value="class" />

        </properties>
    </persistence-unit>
</persistence>

And here is the pom.xml of the DAL

这是pom。xml的木豆

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>my.dal</groupId>
    <artifactId>dal</artifactId>
    <version>0.0.4-SNAPSHOT</version>
    <packaging>jar</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.7</java.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>com.mysema.querydsl</groupId>
            <artifactId>querydsl-core</artifactId>
            <version>3.3.2</version>
        </dependency>
        <dependency>
            <groupId>com.mysema.querydsl</groupId>
            <artifactId>querydsl-apt</artifactId>
            <version>3.3.2</version>
        </dependency>
        <dependency>
            <groupId>com.mysema.querydsl</groupId>
            <artifactId>querydsl-jpa</artifactId>
            <version>3.3.2</version>
        </dependency>       
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.16</version>
        </dependency>
        <dependency>
            <groupId>org.jglue.cdi-unit</groupId>
            <artifactId>cdi-unit</artifactId>
            <version>3.0.1</version>
            <scope>test</scope>
        </dependency>       
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
        </dependency>       
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>6.0</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.3.5.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate.common</groupId>
            <artifactId>hibernate-commons-annotations</artifactId>
            <version>4.0.4.Final</version>
        </dependency>

        <dependency>
            <groupId>javax.enterprise</groupId>
            <artifactId>cdi-api</artifactId>
            <version>1.1</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.1-api</artifactId>
            <version>1.0.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>4.3.5.Final</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.30</version>
        </dependency>       
        <dependency>
            <groupId>com.zaxxer</groupId>
            <artifactId>HikariCP</artifactId>
            <version>1.4.0</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>

    <build>
        <finalName>DAL</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>

            <plugin>
              <groupId>com.mysema.maven</groupId>
              <artifactId>apt-maven-plugin</artifactId>
              <version>1.0.9</version>
              <executions>
                <execution>
                  <goals>
                    <goal>process</goal>
                  </goals>
                  <configuration>
                    <outputDirectory>target/generated-sources/java</outputDirectory>
                    <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
                  </configuration>
                </execution>
              </executions>
            </plugin>

        </plugins>
    </build>

</project>

What do you think the problem can be? Is it a known issue of HikariCP? Is HikariCP supported in JBoss AS 7.1?

你认为问题会是什么?这是HikariCP的已知问题吗?JBoss支持的HikariCP是7.1吗?

Thank you Best regards

谢谢你最好的祝福

Giulio

朱里奥

1 个解决方案

#1


1  

HikariCP failed to load because the class org.hibernate.engine.jdbc.connections.spi.ConnectionProvider could not be found, at least according to the stacktrace. I would validate that Hibernate is the correct version (the same as is being used in Wildfly). Also, note that Hibernate now includes their own HikariConnectionProvider now, so I recommend switching over to that one.

HikariCP没有加载,因为类org.hibernate.engine.jdbc.connections.spi。无法找到ConnectionProvider,至少根据stacktrace。我将验证Hibernate是正确的版本(与在Wildfly中使用的一样)。另外,注意Hibernate现在也包含了它们自己的HikariConnectionProvider,所以我建议切换到它。

#1


1  

HikariCP failed to load because the class org.hibernate.engine.jdbc.connections.spi.ConnectionProvider could not be found, at least according to the stacktrace. I would validate that Hibernate is the correct version (the same as is being used in Wildfly). Also, note that Hibernate now includes their own HikariConnectionProvider now, so I recommend switching over to that one.

HikariCP没有加载,因为类org.hibernate.engine.jdbc.connections.spi。无法找到ConnectionProvider,至少根据stacktrace。我将验证Hibernate是正确的版本(与在Wildfly中使用的一样)。另外,注意Hibernate现在也包含了它们自己的HikariConnectionProvider,所以我建议切换到它。