HikariConfig ClassNotFoundException

5,872 views
Skip to first unread message

br...@us.sendgine.com

unread,
Dec 9, 2013, 6:05:02 PM12/9/13
to hika...@googlegroups.com
Just found this library today and am trying to implement it.  I'm seeing the following exception when newing up a new instance of HikariConfig:


Caused by: java.lang.ClassNotFoundException: com.zaxxer.hikari.HikariConfig
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 7 more


I have included the JRE7 version of tools.jar in the lib directory of the project but I can't get passed this.  In a different debugger, I'm getting ClassNotFoundException on com.sun.tools.attach.VirtualMachine.

Thoughts?

Brett Wooldridge

unread,
Dec 9, 2013, 8:40:46 PM12/9/13
to
What OS and what Java JDK version are you running?

For Mac OS X, this thread is worth reading:


For all versions, it is also essential that JAVA_HOME be set correctly.

See also this thread:


Brett

br...@us.sendgine.com

unread,
Dec 9, 2013, 8:43:48 PM12/9/13
to hika...@googlegroups.com
I'm on Windows 7 and my JAVA_HOME path is set to JAVA_HOME=C:\Program Files\Java\jdk1.7.0_45

I'll read that thread.  After further reading since my post, I'm sure this is not related to HikariCP.  It's something to do with my project settings.

br...@us.sendgine.com

unread,
Dec 10, 2013, 11:05:35 AM12/10/13
to hika...@googlegroups.com
Ok... I believe that I've gotten my maven pom set up properly and my IntelliJ projects set up properly.  Now I'm getting an exception inside of Hikari.  

Pom dependencies:

<dependencies>
        <dependency>
            <groupId>com.zaxxer</groupId>
            <artifactId>HikariCP</artifactId>
            <version>1.2.1</version>
        </dependency>
        <dependency>
            <groupId>com.zaxxer</groupId>
            <artifactId>HikariCP-agent</artifactId>
            <version>1.2.1</version>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.2-1003-jdbc4</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.5</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>2.3.0</version>
        </dependency>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk</artifactId>
            <version>1.6.7</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.5</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-parent</artifactId>
            <version>1.7.5</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.7.5</version>
        </dependency>
        <dependency>
            <groupId>org.javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.18.1-GA</version>
        </dependency>
    </dependencies>


Exception:

[main] WARN com.zaxxer.hikari.javassist.HikariClassScanner - Instrumentation agent could not be loaded.  Please report at http://github.com/brettwooldridge/HikariCP.
com.sun.tools.attach.AgentLoadException: Agent JAR not found or no Agent-Class attribute
at sun.tools.attach.HotSpotVirtualMachine.loadAgent(HotSpotVirtualMachine.java:117)
at com.sun.tools.attach.VirtualMachine.loadAgent(VirtualMachine.java:526)
at com.zaxxer.hikari.javassist.AgentRegistrationElf.registerInstrumentation(AgentRegistrationElf.java:121)
at com.zaxxer.hikari.javassist.AgentRegistrationElf.loadTransformerAgent(AgentRegistrationElf.java:58)
at com.zaxxer.hikari.HikariPool.<init>(HikariPool.java:84)
at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:50)
at Tester.main(Tester.java:67)
[main] INFO com.zaxxer.hikari.HikariPool - Using Javassist delegate-based proxies.
Disconnected from the target VM, address: '127.0.0.1:5179', transport: 'socket'
[main] ERROR com.zaxxer.hikari.util.PropertyBeanSetter - Property url is does not exist on target class class org.postgresql.ds.PGSimpleDataSource
Exception in thread "main" java.lang.RuntimeException: Could not create datasource class: org.postgresql.ds.PGSimpleDataSource
at com.zaxxer.hikari.HikariPool.<init>(HikariPool.java:96)
at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:50)
at Tester.main(Tester.java:67)
Caused by: java.lang.RuntimeException: java.beans.IntrospectionException: Method not found: setUrl
at com.zaxxer.hikari.util.PropertyBeanSetter.setProperty(PropertyBeanSetter.java:89)
at com.zaxxer.hikari.util.PropertyBeanSetter.setTargetFromProperties(PropertyBeanSetter.java:56)
at com.zaxxer.hikari.HikariPool.<init>(HikariPool.java:92)
... 2 more
Caused by: java.beans.IntrospectionException: Method not found: setUrl
at java.beans.PropertyDescriptor.<init>(PropertyDescriptor.java:110)
at com.zaxxer.hikari.util.PropertyBeanSetter.setProperty(PropertyBeanSetter.java:66)
... 4 more

br...@us.sendgine.com

unread,
Dec 10, 2013, 11:14:11 AM12/10/13
to hika...@googlegroups.com
Brice asked what the result was when I disabled instrumentation.  Here is the exception that I get when doing that:

[main] INFO com.zaxxer.hikari.HikariPool - Using Javassist delegate-based proxies.
[main] ERROR com.zaxxer.hikari.util.PropertyBeanSetter - Property url is does not exist on target class class org.postgresql.ds.PGSimpleDataSource
Exception in thread "main" java.lang.RuntimeException: Could not create datasource class: org.postgresql.ds.PGSimpleDataSource
at com.zaxxer.hikari.HikariPool.<init>(HikariPool.java:96)
at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:50)
at Tester.main(Tester.java:67)
Caused by: java.lang.RuntimeException: java.beans.IntrospectionException: Method not found: setUrl
at com.zaxxer.hikari.util.PropertyBeanSetter.setProperty(PropertyBeanSetter.java:89)
at com.zaxxer.hikari.util.PropertyBeanSetter.setTargetFromProperties(PropertyBeanSetter.java:56)
at com.zaxxer.hikari.HikariPool.<init>(HikariPool.java:92)
... 2 more
Caused by: java.beans.IntrospectionException: Method not found: setUrl
at java.beans.PropertyDescriptor.<init>(PropertyDescriptor.java:110)
at com.zaxxer.hikari.util.PropertyBeanSetter.setProperty(PropertyBeanSetter.java:66)
... 4 more


I also just realized that I haven't posted anything regrading how i'm instantiating the objects.  Here is that:

        HikariConfig config = new HikariConfig();
        config.setMinimumPoolSize(10);
        config.setMaximumPoolSize(100);
        config.setDataSourceClassName("org.postgresql.ds.PGSimpleDataSource");
        config.addDataSourceProperty("url", "test");
        config.addDataSourceProperty("user", "blah");
        config.addDataSourceProperty("password", "blah");
        config.setUseInstrumentation(false);

        HikariDataSource ds = new HikariDataSource(config);

br...@us.sendgine.com

unread,
Dec 10, 2013, 2:01:23 PM12/10/13
to hika...@googlegroups.com
I got everything working when 'setUseInstrumentation(false);' is called.

Thanks for the help Brice and Brett.  

Brett Wooldridge

unread,
Dec 10, 2013, 7:34:23 PM12/10/13
to hika...@googlegroups.com
I'm glad that you got it working.  I assume you got rid of the "url" parameter, as it is not used by the PGSimpleDataSource.

I am curious what is going on with the instrumentation mode.  Would you mind helping me investigate it a little further?  If not here is what I need you to do:

cd HikariCP
git checkout dev
mvn install

That will build HikariCP and install HikariCP-1.2.2-SNAPSHOT.jar and HikariCP-agent 1.2.2-SNAPSHOT.jar into your local maven repository.  1.2.2-SNAPSHOT has an additional log message for instrumentation that looks like:

[main] WARN com.zaxxer.hikari.javassist.HikariClassScanner - Using HikariCP agent jar found at: <some path>

I'm curious what this shows in your environment.

You'll need to adjust your pom temporarily like this:

        <dependency>
            <groupId>com.zaxxer</groupId>
            <artifactId>HikariCP</artifactId>
            <version>1.2.2-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.zaxxer</groupId>
            <artifactId>HikariCP-agent</artifactId>
            <version>1.2.2-SNAPSHOT</version>
        </dependency>

Thanks,
Brett

Brett Wooldridge

unread,
Dec 11, 2013, 5:00:19 AM12/11/13
to hika...@googlegroups.com
Are you by chance shading the HikariCP-agent jar using the maven-shade-plugin?  If so, the agent jar cannot be shaded in order to function correctly.

Brett
Reply all
Reply to author
Forward
0 new messages