HikiariCP & Karaf

340 views
Skip to first unread message

Tom Tom

unread,
Jul 6, 2017, 6:51:32 AM7/6/17
to HikariCP
Hi all,
I am using BoneCP as JDBC connection pool for a project in Apache ServiceMix 4.5.1 (Karaf), and would like to switch to an active connection pool implementation like HikariCP-java6.
So far, OSGI "dependency  hell" is a problem.
 Is it possible to use HikariCP in OSGI environment without Hibernate (as pure connection pool like BoneCP) ?
 
This are dependencies form pom.xml.
Compilation is OK - but runtime reports missing dependencies.


        <spring.osgi.version>1.2.1</spring.osgi.version>
        <spring.osgi.core.version>4.1.0</spring.osgi.core.version>
        <spring.version>3.0.7.RELEASE</spring.version>
        <org.springframework.jdbc.version>3.0.7.RELEASE</org.springframework.jdbc.version>   
        <amq.version>5.7.0</amq.version>
        <jdbc.version>3.7</jdbc.version>
        <camel.core.version>2.10.4</camel.core.version>
        <equinox.ver>3.2.2</equinox.ver>
        <spring.maven.artifact.version>2.5.6.SEC01</spring.maven.artifact.version>
        <guava.version>15.0</guava.version>
        <maven.bundle.plugin.version>2.3.7</maven.bundle.plugin.version>
        <junit.version>4.11</junit.version>
        <mockito.version>1.9.5</mockito.version>
        <maven.compiler.plugin.version>2.5.1</maven.compiler.plugin.version>
        <maven.compiler.source.version>1.6</maven.compiler.source.version>
        <maven.compiler.target.version>1.6</maven.compiler.target.version>

<dependencies>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.5</version>
        </dependency>
      
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.core</artifactId>
            <version>${spring.osgi.core.version}</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>org.springframework.jdbc</artifactId>
            <version>${org.springframework.jdbc.version}</version>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>com.ibm.informix</groupId>
            <artifactId>ifxjdbc</artifactId>
            <version>${jdbc.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.ibm.informix</groupId>
            <artifactId>jdbc</artifactId>
            <version>${jdbc.version}</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.18.2-GA</version>
        </dependency>

        <dependency>
            <groupId>com.zaxxer</groupId>
            <artifactId>HikariCP-java6</artifactId>
            <version>2.3.13</version>
        </dependency>

        <dependency>
            <groupId>com.google.code.findbugs</groupId>
            <artifactId>annotations</artifactId>
            <version>2.0.0</version>
        </dependency>

Brett Wooldridge

unread,
Jul 6, 2017, 7:06:14 AM7/6/17
to HikariCP
What are the reported missing runtime dependencies?

Tom Tom

unread,
Jul 6, 2017, 7:51:40 AM7/6/17
to HikariCP
First one missing is javassist

When that one is set as embedded then com.sun.jdi pops up

Here is relevant part in pom.xml

<plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>${maven.bundle.plugin.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <obrRepository>NONE</obrRepository>
                    <instructions>
                        <Export-Package>!hr.com.mips.modules.database.internal,hr.com.mips.modules.database.external.*</Export-Package>
                        <Import-Package>!netscape.security,!com.codahale.*,*,com.informix.*,hr.com.mips.commons.*,org.slf4j;version=1.6.4,hr.com.mips.test.*</Import-Package>
                        <Private-Package>hr.com.mips.modules.database.internal.*</Private-Package>
                        <Embed-Dependency>HikariCP-java6|javassist|jdbc|ifxjdbc;scope=compile|runtime</Embed-Dependency>
                        <DynamicImport-Package>com.informix,com.zaxxer</DynamicImport-Package>
                        <!--<Include-Resource> -->
                        <!--{maven-resources}, {maven-dependencies} -->
                        <!--</Include-Resource> -->
                    </instructions>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <executions>
                    <execution>
                        <id>bundle-manifest</id>
                        <phase>package</phase>
                        <goals>
                            <goal>bundle</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

Brett Wooldridge

unread,
Jul 6, 2017, 3:51:25 PM7/6/17
to hika...@googlegroups.com
Somewhere you should have an etc/config.properties file similar to this one that lists com.sun.* in the org.osgi.framework.bootdelegation property.  That instructs OSGi to resolve referents to the com.sun.* packages via the AppClassLoader.  If it is already there, you need to add it to the Import-Package.

Also, HikariCP is already an OSGi bundle, and javassist is no longer required at runtime ... though it appears to be in the OSGi manifest as an import.  You can try cloning the repository, check out the 2.3.x branch, and edit the pom.xml to remove that dependency.  If that works, I can make that same change and cut a new Java 6 artifact release.

EDIT: By the way, I'm not sure where you are getting that Hibernate is a dependency.  It is marked as optional in the OSGi manifest.

-Brett

      

Kevin Schmidt

unread,
Jul 7, 2017, 2:07:05 AM7/7/17
to HikariCP
We've been using HikariCP in Karaf for awhile now, but it isn't the Java6 binary.  We haven't had to do anything special, just install the HikariCP jar as a bundle and install our JDBC drivers and configure a datasource specifying HikariCP as the pool.

Brett Wooldridge

unread,
Jul 7, 2017, 7:19:48 AM7/7/17
to HikariCP
Tom, given Kevin's feedback, I suggest downloading the Java 7 artifact and comparing the OSGi manifest with the Java 6 artifact. I would do it myself but I am swamped with work this week.

Tom Tom

unread,
Jul 7, 2017, 11:54:39 AM7/7/17
to HikariCP

@Kevin, @Brett: Thanks for help.

Will fork 2.3.x branch and recompile it with Java6. Hopefully, with little modifications, I can make it work.
Results will be posted back here. Thanks!

Kevin Schmidt

unread,
Jul 7, 2017, 12:00:43 PM7/7/17
to hika...@googlegroups.com
Just curious, why do you need to use Java 6?  What version of Karaf are you using?  You know of course that Java 6 ceased getting public updates several years ago.

We were using Karaf 3.x with Java 7 then Java 8, and are now starting to use Karaf 4 with Java 8 so that is where it has worked for us very easily.

--
You received this message because you are subscribed to a topic in the Google Groups "HikariCP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hikari-cp/X3JB6_TDygA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to hikari-cp+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/hikari-cp.
For more options, visit https://groups.google.com/d/optout.

Tom Tom

unread,
Jul 7, 2017, 12:12:07 PM7/7/17
to HikariCP

It is a legacy product form 2013., based on Java 6 and Apache ServiceMix 4.5.1 (Karaf 2.2.10)
There are plans to migrate to Java8 and ServiceMix 6.1.3 (Karaf 3.0.8), but that has yet to be done.


On Friday, July 7, 2017 at 6:00:43 PM UTC+2, Kevin Schmidt wrote:
Just curious, why do you need to use Java 6?  What version of Karaf are you using?  You know of course that Java 6 ceased getting public updates several years ago.

We were using Karaf 3.x with Java 7 then Java 8, and are now starting to use Karaf 4 with Java 8 so that is where it has worked for us very easily.
On Fri, Jul 7, 2017 at 8:54 AM, Tom Tom <gond...@gmail.com> wrote:

@Kevin, @Brett: Thanks for help.

Will fork 2.3.x branch and recompile it with Java6. Hopefully, with little modifications, I can make it work.
Results will be posted back here. Thanks!


On Friday, July 7, 2017 at 1:19:48 PM UTC+2, Brett Wooldridge wrote:
Tom, given Kevin's feedback, I suggest downloading the Java 7 artifact and comparing the OSGi manifest with the Java 6 artifact.  I would do it myself but I am swamped with work this week.

--
You received this message because you are subscribed to a topic in the Google Groups "HikariCP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hikari-cp/X3JB6_TDygA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to hikari-cp+...@googlegroups.com.

Tom Tom

unread,
Jul 11, 2017, 4:23:24 AM7/11/17
to HikariCP
Thanks to all of you for help.
I have finally managed to make it work under Karaf.

HikariCP is a bundle and ready to be deployed in OSGI.
I was trying to embed HikariCP-java6 as jar in my bundle using <Embed-Dependency> and that was a wrong way to do it.
It works but everything has to be done OSGI way, all the way.

Kevin Schmidt

unread,
Jul 11, 2017, 10:38:53 AM7/11/17
to hika...@googlegroups.com
Yeah, when using Karaf, if at all possible do things the "OSGi" way and avoid embedding dependencies.  We haven't been able to eliminate embedded dependencies completely, but life is a lot simpler (and bundles are smaller) when we don't have them.

--
You received this message because you are subscribed to a topic in the Google Groups "HikariCP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hikari-cp/X3JB6_TDygA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to hikari-cp+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages