Hey Achim,

right now I have one bundle that contains the Redis client classes
themselves but not the Apache Commons Pool classes. (I haven't figured
out how to install jedis as a separate bundle from maven yet, errors...)

Those classes are loaded using the import statement in the manifest:

Import-Package: org.osgi.framework, javax.naming, org.slf4j, javax.sql
 , javax.management, sun.net, org.apache.commons.pool2.proxy, org.apac
 he.commons.pool2.impl, org.apache.commons.pool2, com.mysql.jdbc,
 com.jolbox.bonecp, com.google.common.base,
 com.mysql.jdbc.jdbc2.optional

my list of installed bundles is as follows:

karaf@root()> list
START LEVEL 100 , List Threshold: 50
 ID | State     | Lvl | Version       | Name

----------------------------------------------------------------------------------
111 | Resolved  |  80 | 5.1.35        | Oracle Corporation's JDBC Driver
for MySQL
113 | Resolved  |  80 | 01.00.55      | Analyzer

131 | Resolved  |  80 | 0.8.0.RELEASE | BoneCP :: Core Library

134 | Resolved  |  80 | 15.0.0        | Guava: Google Core Libraries for
Java
142 | Installed |  80 | 2.3.0         | Apache Commons Pool


and the export list says this:

karaf@root()> package:exports | grep commons
org.apache.commons.logging.impl                | 1.0.4         | 3   |
org.ops4j.pax.logging.pax-logging-api
org.apache.commons.logging.impl                | 1.1.1         | 3   |
org.ops4j.pax.logging.pax-logging-api
org.apache.commons.logging                     | 1.0.4         | 3   |
org.ops4j.pax.logging.pax-logging-api
org.apache.commons.logging                     | 1.1.1         | 3   |
org.ops4j.pax.logging.pax-logging-api
org.apache.commons.pool2.impl                  | 2.3.0         | 142 |
org.apache.commons.pool2
org.apache.commons.pool2.proxy                 | 2.3.0         | 142 |
org.apache.commons.pool2
org.apache.commons.pool2                       | 2.3.0         | 142 |
org.apache.commons.pool2
org.objectweb.asm.commons                      | 5.0.3         | 8   |
org.objectweb.asm.all

The exception is this:

Caused by: java.lang.IllegalArgumentException: Unable to create
EvictionPolicy instance of type
org.apache.commons.pool2.impl.DefaultEvictionPolicy
        at
org.apache.commons.pool2.impl.BaseGenericObjectPool.setEvictionPolicyClassName(BaseGenericObjectPool.java:607)
        at
org.apache.commons.pool2.impl.GenericObjectPool.setConfig(GenericObjectPool.java:321)
        at
org.apache.commons.pool2.impl.GenericObjectPool.<init>(GenericObjectPool.java:117)
        at redis.clients.util.Pool.initPool(Pool.java:43)
        at redis.clients.util.Pool.<init>(Pool.java:31)
        at redis.clients.jedis.JedisPool.<init>(JedisPool.java:73)
        at redis.clients.jedis.JedisPool.<init>(JedisPool.java:54)
        at nl.redsocks.farm.common.services.Redis.createRedisPool(Redis.java:56)
        at nl.redsocks.farm.common.services.Redis.init(Redis.java:50)
        at nl.redsocks.farm.analyzer.core.Analyzer.start(Analyzer.java:258)
        at
org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
        at org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)
        ... 25 more
Caused by: java.lang.ClassNotFoundException:
org.apache.commons.pool2.impl.DefaultEvictionPolicy
        at java.net.URLClassLoader$1.run(URLClassLoader.java:372)[:1.8.0_25]
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)[:1.8.0_25]
        at java.security.AccessController.doPrivileged(Native Method)[:1.8.0_25]
        at java.net.URLClassLoader.findClass(URLClassLoader.java:360)[:1.8.0_25]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)[:1.8.0_25]
        at 
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)[:1.8.0_25]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)[:1.8.0_25]
        at java.lang.Class.forName0(Native Method)[:1.8.0_25]
        at java.lang.Class.forName(Class.java:344)[:1.8.0_25]
        at
org.apache.commons.pool2.impl.BaseGenericObjectPool.setEvictionPolicyClassName(BaseGenericObjectPool.java:598)
        ... 36 more

So my imports list all the packages that are exported by the Apache
Commons Pool library. Those packages also include the class that I'm
getting the load error for.

gr, Jurgen

On 04/28/2015 01:35 PM, Achim Nierbeck wrote:
> Hi Jurgen, 
> 
> do you have the right imports for it configured on your bundles?
> So which bundle doesn't start?
> Take a look at the bundle:headers ID of this bundle and check if it
> actually imports the package you are looking for. 
> If not, make sure the bundle does import it. 
> 
> regards, Achim 
> 
> 
> 2015-04-28 13:31 GMT+02:00 Jurgen Voorneveld
> <jurgen.voornev...@redsocks.nl <mailto:jurgen.voornev...@redsocks.nl>>:
> 
>     I couldn't get the Apache Commons Pool libary to load under Karaf so I
>     tried rewriting the app to  use BoneCP instead of HikariCP. Bone doesn't
>     have this dependency.
> 
>     This appears to work. BoneCP does want to load. Unfortunately I also
>     have a Redis database which also has the dependency on Apache Commons
>     Pool. So I'm back to the same error just one line down in my code.
> 
>     It doesn't look like there are any alternative connection pool libraries
>     for Redis.
> 
>     I want to be able to connect to my Redis db using a connection pool,
>     anyone know how to do that?
> 
>     On 04/23/2015 05:14 PM, Jurgen Voorneveld wrote:
>     > I got the maven install to work and installed a bunch of bundles:
>     >
>     > karaf@root()> list
>     > START LEVEL 100 , List Threshold: 50
>     >  ID | State    | Lvl | Version   | Name
>     >
>     >
>     
> -----------------------------------------------------------------------------
>     > 102 | Resolved |  80 | 2.3.0     | Apache Commons Pool
>     >
>     > 107 | Resolved |  80 | 2.3.6     | HikariCP
>     >
>     > 110 | Resolved |  80 | 3.19.0.GA <http://3.19.0.GA> | Javassist
>     >
>     > 111 | Resolved |  80 | 5.1.35    | Oracle Corporation's JDBC
>     Driver for
>     > MySQL
>     > 113 | Resolved |  80 | 01.00.46  | Analyzer
>     >
>     >
>     > Unfortunately this doesn't actually solve the problem. I'm still
>     getting
>     > the same error:
>     >
>     > Caused by: java.lang.ClassNotFoundException:
>     > org.apache.commons.pool2.impl.DefaultEvictionPolicy
>     >
>     > despite it existing in the exports list:
>     >
>     > karaf@root()> package:exports | grep commons
>     > org.apache.commons.pool2.impl                  | 2.3.0     | 102 |
>     > org.apache.commons.pool2
>     > org.apache.commons.pool2.proxy                 | 2.3.0     | 102 |
>     > org.apache.commons.pool2
>     > org.apache.commons.pool2                       | 2.3.0     | 102 |
>     > org.apache.commons.pool2
>     >
>     > and being included in the Import-Package in the manifest.
>     >
>     > running out of ideas...
>     >
>     > Jurgen
>     >
>     > On 04/23/2015 12:51 PM, Morgan Hautman wrote:
>     >> Sorry for the typo, it changed to "package" in Karaf 3.
>     >>
>     >> You should install one package that export this service too.
>     >>
>     >> Try this: install mvn:com.zaxxer/HikariCP/x.x.x (version you want
>     to use)
>     >>
>     >> Regards
>     >> Morgan
>     >>
>     >> On 23/04/2015 12:37, Jurgen Voorneveld wrote:
>     >>> Should have paid more attention.
>     >>>
>     >>> karaf@root()> package:exports | grep HikariConfig
>     >>>
>     >>> Returns empty. Which I guess makes sense; there is no library in
>     Karaf
>     >>> exporting these classes by default.
>     >>> But I don't see how that could make it fail. The class is
>     available in
>     >>> the bundle itself.
>     >>>
>     >>> For completeness this is the imports in the manifest:
>     >>>
>     >>> Import-Package: org.osgi.framework, javax.naming
>     >>>
>     >>> Jurgen
>     >>>
>     >>> On 04/23/2015 12:30 PM, Jurgen Voorneveld wrote:
>     >>>> Helo Morgan,
>     >>>>
>     >>>> I get this:
>     >>>>
>     >>>> karaf@root()> packages:exports | grep HikariConfig
>     >>>> pipe: org.apache.felix.gogo.runtime.CommandNotFoundException:
>     Command
>     >>>> not found: packages:exports
>     >>>>
>     >>>> I have no idea what this means.
>     >>>>
>     >>>> Jurgen
>     >>>>
>     >>>> On 04/23/2015 12:18 PM, Morgan Hautman wrote:
>     >>>>> Hello Jurgen,
>     >>>>>
>     >>>>> What do you get when you're doing a "packages:exports | grep
>     >>>>> HikariConfig"?
>     >>>>>
>     >>>>> Regards
>     >>>>> Morgan
>     >>>>>
>     >>>>> On 23/04/2015 11:58, Jurgen Voorneveld wrote:
>     >>>>>> Dear list,
>     >>>>>>
>     >>>>>> I have Apache Karaf installed on a production system here at
>     work and
>     >>>>>> I'm trying to install a bundle into it. This is fairly new to
>     me as
>     >>>>>> previously the code was simply running as standalone
>     applications.
>     >>>>>>
>     >>>>>> I'm getting an exception when I try to load the bundle:
>     >>>>>>
>     >>>>>> karaf@root()> list
>     >>>>>> START LEVEL 100 , List Threshold: 50
>     >>>>>> ID | State    | Lvl | Version  | Name
>     >>>>>> -----------------------------------------
>     >>>>>> 87 | Resolved |  80 | 01.00.27 | Analyzer
>     >>>>>> karaf@root()> start 87
>     >>>>>> Error executing command: Error executing command on bundles:
>     >>>>>>      Unable to execute command on bundle 87: Activator start
>     error in
>     >>>>>> bundle
>     >>>>>> nl.redsocks.farm.analyzer [87].
>     >>>>>> karaf@root()> log:display
>     >>>>>> 2015-04-23 11:48:28,700 | ERROR | h for user karaf | ShellUtil
>     >>>>>>                 | 25 - org.apache.karaf.shell.console - 3.0.3 |
>     >>>>>> Exception
>     >>>>>> caught while executing command
>     >>>>>> org.apache.karaf.shell.console.MultiException: Error
>     executing command
>     >>>>>> on bundles:
>     >>>>>>      Unable to execute command on bundle 87: Activator start
>     error in
>     >>>>>> bundle
>     >>>>>> nl.redsocks.farm.analyzer [87].
>     >>>>>>      at
>     >>>>>>
>     
> org.apache.karaf.shell.console.MultiException.throwIf(MultiException.java:92)
>     >>>>>>
>     >>>>>>
>     >>>>>>      at
>     >>>>>>
>     
> org.apache.karaf.bundle.command.BundlesCommandWithConfirmation.doExecute(BundlesCommandWithConfirmation.java:58)
>     >>>>>>
>     >>>>>>
>     >>>>>>      at
>     >>>>>>
>     
> org.apache.karaf.bundle.command.BundlesCommand.doExecute(BundlesCommand.java:50)
>     >>>>>>
>     >>>>>>
>     >>>>>>      at
>     >>>>>>
>     
> org.apache.karaf.bundle.command.BundlesCommandWithConfirmation.doExecute(BundlesCommandWithConfirmation.java:41)
>     >>>>>>
>     >>>>>>
>     >>>>>>      at
>     >>>>>>
>     
> org.apache.karaf.shell.console.AbstractAction.execute(AbstractAction.java:33)[25:org.apache.karaf.shell.console:3.0.3]
>     >>>>>>
>     >>>>>>
>     >>>>>>      at
>     >>>>>>
>     
> org.apache.karaf.shell.console.OsgiCommandSupport.execute(OsgiCommandSupport.java:39)[25:org.apache.karaf.shell.console:3.0.3]
>     >>>>>>
>     >>>>>>
>     >>>>>>      at
>     >>>>>>
>     
> org.apache.karaf.shell.commands.basic.AbstractCommand.execute(AbstractCommand.java:33)[25:org.apache.karaf.shell.console:3.0.3]
>     >>>>>>
>     >>>>>>
>     >>>>>>      at Proxy5f648166_9983_4f8f_acb1_23f0c1d1ea3b.execute(Unknown
>     >>>>>> Source)[:]
>     >>>>>>      at Proxy5f648166_9983_4f8f_acb1_23f0c1d1ea3b.execute(Unknown
>     >>>>>> Source)[:]
>     >>>>>>      at
>     >>>>>>
>     
> org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:78)[25:org.apache.karaf.shell.console:3.0.3]
>     >>>>>>
>     >>>>>>
>     >>>>>>      at
>     >>>>>>
>     
> org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)[25:org.apache.karaf.shell.console:3.0.3]
>     >>>>>>
>     >>>>>>
>     >>>>>>      at
>     >>>>>>
>     
> org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)[25:org.apache.karaf.shell.console:3.0.3]
>     >>>>>>
>     >>>>>>
>     >>>>>>      at
>     >>>>>>
>     
> org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[25:org.apache.karaf.shell.console:3.0.3]
>     >>>>>>
>     >>>>>>
>     >>>>>>      at
>     >>>>>>
>     
> org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)[25:org.apache.karaf.shell.console:3.0.3]
>     >>>>>>
>     >>>>>>
>     >>>>>>      at
>     >>>>>>
>     
> org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)[25:org.apache.karaf.shell.console:3.0.3]
>     >>>>>>
>     >>>>>>
>     >>>>>>      at
>     >>>>>>
>     
> org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:92)
>     >>>>>>
>     >>>>>>
>     >>>>>>      at
>     >>>>>>
>     
> org.apache.karaf.shell.console.impl.jline.ConsoleImpl.run(ConsoleImpl.java:208)
>     >>>>>>
>     >>>>>>
>     >>>>>>      at
>     >>>>>>
>     
> org.apache.karaf.shell.ssh.ShellFactoryImpl$ShellImpl$1.runConsole(ShellFactoryImpl.java:158)[52:org.apache.karaf.shell.ssh:3.0.3]
>     >>>>>>
>     >>>>>>
>     >>>>>>      at
>     >>>>>>
>     
> org.apache.karaf.shell.ssh.ShellFactoryImpl$ShellImpl$1$1.run(ShellFactoryImpl.java:133)
>     >>>>>>
>     >>>>>>
>     >>>>>>      at java.security.AccessController.doPrivileged(Native
>     >>>>>> Method)[:1.8.0_25]
>     >>>>>>      at
>     >>>>>>
>     
> org.apache.karaf.jaas.modules.JaasHelper.doAs(JaasHelper.java:57)[26:org.apache.karaf.jaas.modules:3.0.3]
>     >>>>>>
>     >>>>>>
>     >>>>>>      at
>     >>>>>>
>     
> org.apache.karaf.shell.ssh.ShellFactoryImpl$ShellImpl$1.run(ShellFactoryImpl.java:129)[52:org.apache.karaf.shell.ssh:3.0.3]
>     >>>>>>
>     >>>>>>
>     >>>>>> Caused by: java.lang.Exception: Unable to execute command on
>     bundle
>     >>>>>> 87:
>     >>>>>> Activator start error in bundle nl.redsocks.farm.analyzer [87].
>     >>>>>>      at
>     >>>>>>
>     
> org.apache.karaf.bundle.command.BundlesCommandWithConfirmation.doExecute(BundlesCommandWithConfirmation.java:55)
>     >>>>>>
>     >>>>>>
>     >>>>>>      ... 20 more
>     >>>>>> Caused by: org.osgi.framework.BundleException: Activator start
>     >>>>>> error in
>     >>>>>> bundle nl.redsocks.farm.analyzer [87].
>     >>>>>>      at
>     >>>>>> org.apache.felix.framework.Felix.activateBundle(Felix.java:2196)
>     >>>>>>      at
>     org.apache.felix.framework.Felix.startBundle(Felix.java:2064)
>     >>>>>>      at
>     >>>>>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
>     >>>>>>      at
>     >>>>>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
>     >>>>>>      at
>     >>>>>>
>     org.apache.karaf.bundle.command.Start.executeOnBundle(Start.java:27)
>     >>>>>>      at
>     >>>>>>
>     
> org.apache.karaf.bundle.command.BundlesCommandWithConfirmation.doExecute(BundlesCommandWithConfirmation.java:53)
>     >>>>>>
>     >>>>>>
>     >>>>>>      ... 20 more
>     >>>>>> Caused by: java.lang.NoClassDefFoundError: Could not
>     initialize class
>     >>>>>> com.zaxxer.hikari.HikariConfig
>     >>>>>>      at
>     nl.redsocks.farm.common.services.MySQL.init(MySQL.java:29)
>     >>>>>>      at
>     >>>>>> nl.redsocks.farm.analyzer.core.Analyzer.start(Analyzer.java:250)
>     >>>>>>      at
>     >>>>>>
>     
> org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
>     >>>>>>
>     >>>>>>
>     >>>>>>      at
>     >>>>>> org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)
>     >>>>>>      ... 25 more
>     >>>>>>
>     >>>>>> karaf@root()>
>     >>>>>>
>     >>>>>> sorry for the wrapping. It looks like the problem is with
>     HikariCP;
>     >>>>>> "Caused by: java.lang.NoClassDefFoundError: Could not
>     initialize class
>     >>>>>> com.zaxxer.hikari.HikariConfig"
>     >>>>>>
>     >>>>>> I checked the jar and this class is in there. And the code also
>     >>>>>> functions without problems when run standalone.
>     >>>>>>
>     >>>>>> Right now I'm creating bundles by creating one massive jar
>     with all
>     >>>>>> dependencies packaged together. Perhaps I should try installing
>     >>>>>> HikariCP
>     >>>>>> as a library inside its own bundle?
>     >>>>>>
>     >>>>>> How can I solve the problem?
>     >>>>>>
>     >>>>>> thanks
>     >>>>>> Jurgen
>     >>>>>>
>     >>>>>> versions:
>     >>>>>>
>     >>>>>> $ java -version
>     >>>>>> java version "1.8.0_25"
>     >>>>>> Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
>     >>>>>> Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
>     >>>>>>
>     >>>>>> $ uname -a
>     >>>>>> Linux farm 3.13.0-48-generic #80-Ubuntu SMP Thu Mar 12
>     11:16:15 UTC
>     >>>>>> 2015
>     >>>>>> x86_64 x86_64 x86_64 GNU/Linux
>     >>>>>>
>     >>>>>> $ awk 'NR>=17&&NR<=20{print}NR>=21{exit}' RELEASE-NOTES
>     >>>>>>
>     >>>>>>                       Apache Karaf 3.0.3
>     >>>>>>                       ==================
>     >>>>>>
>     >>>>>>
> 
> 
> 
> 
> -- 
> 
> Apache Member
> Apache Karaf <http://karaf.apache.org/> Committer & PMC
> OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer
> & Project Lead
> blog <http://notizblog.nierbeck.de/>
> Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>
> 
> Software Architect / Project Manager / Scrum Master 
> 

Reply via email to