Search code examples
javahibernatejboss7.xwildfly-8hikaricp

HikariConnectionProvider ClassNotFoundException when deploying to JBoss Application Server 7.1


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.

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.

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

http://pastebin.com/qQh5EW1N

Here is the persistence.xml confgured in the 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

<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?

Thank you Best regards

Giulio


Solution

  • 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.