0

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

gvdm
  • 3,006
  • 5
  • 35
  • 73
  • Can you take a look in classpath of your jboss, if you can find `HikariCP.jar` ? – Jens Jul 02 '14 at 13:52
  • Hi @Jens. I extracted the .war file of the web app and found the HicariCP-1.4.0jar library in the WEB-INF/lib folder – gvdm Jul 02 '14 at 13:55
  • Is the class that is missing in the HicariCP-1.4.0.jar (the missing dot is a copy/paste error? – Jens Jul 02 '14 at 13:58
  • (Yes, it was a typo) Yes, the HikariConnectionProvider class is contained in the HikariCP-1.4.0.jar library – gvdm Jul 02 '14 at 14:03
  • Is spring also in your war? – Jens Jul 02 '14 at 18:10
  • I'm not using Spring in my web app, so ther's no reason why I should see Spring's jar in my web application's lib folder – gvdm Jul 03 '14 at 06:46
  • Sorry my fault. Is the `hibernate-core.jar` also in your war file? or in a lib directory of your jboss? – Jens Jul 03 '14 at 07:06
  • Yes, I have the hibernate-core-4.2.0.Final.jar library in the lib folder of the deployed web app. In the modules/system/layers/base/org/hibernate folder of jboss AS I can also find the hibernate-core-4.3.1.Final.jar library – gvdm Jul 03 '14 at 07:20
  • Thats it. You have a problem with the classloader. Try to removen the `hibernate-core-4.3.1.Final.jar ` from the jboss lib directory or add the to this directory and remove it from you war. – Jens Jul 03 '14 at 07:25

1 Answers1

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.

brettw
  • 10,664
  • 2
  • 42
  • 59