You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Otavio Rodolfo Piske <an...@gmail.com> on 2011/11/08 14:03:38 UTC

Unable to access library in lib directory "NoClassDefFound"

Hello,

I am having problems making Karaf load the contents of a non-bundled
java library (Webpshere MQ client 6.0.2.4).

To have Karaf use them, I have added the following files to the lib directory:
- com.ibm.mq.jar
- ibm.mqjms.jar
- dhbcore.jar

After that, I modified the startup script so that it loaded those
files. Additionally, I configured the custom.properties file so that
they are accessible from outside:

org.osgi.framework.system.packages.extra=com.google.common.base,\
com.google.common.collect,sun.misc, com.ibm.mq, com.ibm.mq.jms,\
com.ibm.msg.client.jms,com.ibm.disthub2.*,com.google.common.collect.*

Even after doing that, when I deploy my bundle it stays in "resolved"
state and does nothing. When I bounce Karaf,  I get the following
exception:

ERROR: Bundle com.spcs.wsd [78] Error starting
file:/home/orpiske/environments/wsd-transaction-core-0.0.1-SNAPSHOT/deploy/service_manager-0.0.1-SNAPSHOT-bundle.jar
(org.osgi.framework.BundleException: Activator start error in bundle
com.spcs.wsd [78].
java.lang.NoClassDefFoundError: com/ibm/mq/jms/MQQueueConnectionFactory
	at com.spcs.wsd.camel.wmq.WmqJmsComponentBuilder.getMQQueueConnectionFactory(WmqJmsComponentBuilder.java:58)
	at com.spcs.wsd.camel.wmq.WmqJmsComponentBuilder.build(WmqJmsComponentBuilder.java:84)
	at com.spcs.wsd.service.manager.ServiceManager.registerNewComponent(ServiceManager.java:28)
	at com.spcs.wsd.service.manager.ServiceManager.<init>(ServiceManager.java:22)
	at com.spcs.wsd.service.manager.ServiceActivationManager.start(ServiceActivationManager.java:19)
	at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:629)
	at org.apache.felix.framework.Felix.activateBundle(Felix.java:1842)
	at org.apache.felix.framework.Felix.startBundle(Felix.java:1759)
	at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1163)
	at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
	at java.lang.Thread.run(Thread.java:662)


It looks like Karaf is not exposing or being able to expose the
contents of that package to other classes. I did a quick test,
following those steps, but exposing a simple hello-world jar and it
works flawlessly.

In addition to those steps, I also tried to run "osgi:install -w
wrap:file:lib/filename.jar" but it did not work either.

Would anyone know would prevent Karaf from accessing that library or
would have any idea of how to overcome this?

Regards
-- 
Otavio R. Piske
http://orpiske.net

Re: Unable to access library in lib directory "NoClassDefFound"

Posted by Achim Nierbeck <bc...@googlemail.com>.
Hi,

did you also add the package for this class com/ibm/mq/jms/
MQQueueConnectionFactory
into your import statement of your bundle. Cause with adding your libs you
just add them to the system bundle,
but you still need to import them.

regards, Achim

2011/11/8 Otavio Rodolfo Piske <an...@gmail.com>

> Hello,
>
> I am having problems making Karaf load the contents of a non-bundled
> java library (Webpshere MQ client 6.0.2.4).
>
> To have Karaf use them, I have added the following files to the lib
> directory:
> - com.ibm.mq.jar
> - ibm.mqjms.jar
> - dhbcore.jar
>
> After that, I modified the startup script so that it loaded those
> files. Additionally, I configured the custom.properties file so that
> they are accessible from outside:
>
> org.osgi.framework.system.packages.extra=com.google.common.base,\
> com.google.common.collect,sun.misc, com.ibm.mq, com.ibm.mq.jms,\
> com.ibm.msg.client.jms,com.ibm.disthub2.*,com.google.common.collect.*
>
> Even after doing that, when I deploy my bundle it stays in "resolved"
> state and does nothing. When I bounce Karaf,  I get the following
> exception:
>
> ERROR: Bundle com.spcs.wsd [78] Error starting
>
> file:/home/orpiske/environments/wsd-transaction-core-0.0.1-SNAPSHOT/deploy/service_manager-0.0.1-SNAPSHOT-bundle.jar
> (org.osgi.framework.BundleException: Activator start error in bundle
> com.spcs.wsd [78].
> java.lang.NoClassDefFoundError: com/ibm/mq/jms/MQQueueConnectionFactory
>        at
> com.spcs.wsd.camel.wmq.WmqJmsComponentBuilder.getMQQueueConnectionFactory(WmqJmsComponentBuilder.java:58)
>        at
> com.spcs.wsd.camel.wmq.WmqJmsComponentBuilder.build(WmqJmsComponentBuilder.java:84)
>        at
> com.spcs.wsd.service.manager.ServiceManager.registerNewComponent(ServiceManager.java:28)
>        at
> com.spcs.wsd.service.manager.ServiceManager.<init>(ServiceManager.java:22)
>        at
> com.spcs.wsd.service.manager.ServiceActivationManager.start(ServiceActivationManager.java:19)
>        at
> org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:629)
>        at org.apache.felix.framework.Felix.activateBundle(Felix.java:1842)
>        at org.apache.felix.framework.Felix.startBundle(Felix.java:1759)
>        at
> org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1163)
>        at
> org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
>        at java.lang.Thread.run(Thread.java:662)
>
>
> It looks like Karaf is not exposing or being able to expose the
> contents of that package to other classes. I did a quick test,
> following those steps, but exposing a simple hello-world jar and it
> works flawlessly.
>
> In addition to those steps, I also tried to run "osgi:install -w
> wrap:file:lib/filename.jar" but it did not work either.
>
> Would anyone know would prevent Karaf from accessing that library or
> would have any idea of how to overcome this?
>
> Regards
> --
> Otavio R. Piske
> http://orpiske.net
>



-- 
*Achim Nierbeck*

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

Re: Unable to access library in lib directory "NoClassDefFound"

Posted by Otavio Rodolfo Piske <an...@gmail.com>.
Declaring them on the import statement of the bundle seem to have
worked. Thank you all for the help and suggestions!

2011/11/8 Łukasz Dywicki <lu...@code-house.org>:
> Hey Otavio,
> You can verify what is exposed by two commands:
> packages:imports <bundle-id>
> packages:exports <bundle-id>
>
> Also if you library try to use Thread ContextClassLoader you may get these errors.
>
> Regards,
> Lukasz
>
>> Hello,
>>
>> I am having problems making Karaf load the contents of a non-bundled
>> java library (Webpshere MQ client 6.0.2.4).
>>
>> To have Karaf use them, I have added the following files to the lib directory:
>> - com.ibm.mq.jar
>> - ibm.mqjms.jar
>> - dhbcore.jar
>>
>> After that, I modified the startup script so that it loaded those
>> files. Additionally, I configured the custom.properties file so that
>> they are accessible from outside:
>>
>> org.osgi.framework.system.packages.extra=com.google.common.base,\
>> com.google.common.collect,sun.misc, com.ibm.mq, com.ibm.mq.jms,\
>> com.ibm.msg.client.jms,com.ibm.disthub2.*,com.google.common.collect.*
>>
>> Even after doing that, when I deploy my bundle it stays in "resolved"
>> state and does nothing. When I bounce Karaf,  I get the following
>> exception:
>>
>> ERROR: Bundle com.spcs.wsd [78] Error starting
>> file:/home/orpiske/environments/wsd-transaction-core-0.0.1-SNAPSHOT/deploy/service_manager-0.0.1-SNAPSHOT-bundle.jar
>> (org.osgi.framework.BundleException: Activator start error in bundle
>> com.spcs.wsd [78].
>> java.lang.NoClassDefFoundError: com/ibm/mq/jms/MQQueueConnectionFactory
>>       at com.spcs.wsd.camel.wmq.WmqJmsComponentBuilder.getMQQueueConnectionFactory(WmqJmsComponentBuilder.java:58)
>>       at com.spcs.wsd.camel.wmq.WmqJmsComponentBuilder.build(WmqJmsComponentBuilder.java:84)
>>       at com.spcs.wsd.service.manager.ServiceManager.registerNewComponent(ServiceManager.java:28)
>>       at com.spcs.wsd.service.manager.ServiceManager.<init>(ServiceManager.java:22)
>>       at com.spcs.wsd.service.manager.ServiceActivationManager.start(ServiceActivationManager.java:19)
>>       at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:629)
>>       at org.apache.felix.framework.Felix.activateBundle(Felix.java:1842)
>>       at org.apache.felix.framework.Felix.startBundle(Felix.java:1759)
>>       at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1163)
>>       at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
>>       at java.lang.Thread.run(Thread.java:662)
>>
>>
>> It looks like Karaf is not exposing or being able to expose the
>> contents of that package to other classes. I did a quick test,
>> following those steps, but exposing a simple hello-world jar and it
>> works flawlessly.
>>
>> In addition to those steps, I also tried to run "osgi:install -w
>> wrap:file:lib/filename.jar" but it did not work either.
>>
>> Would anyone know would prevent Karaf from accessing that library or
>> would have any idea of how to overcome this?
>>
>> Regards
>> --
>> Otavio R. Piske
>> http://orpiske.net
>
>



-- 
Otavio R. Piske
http://orpiske.net

Re: Unable to access library in lib directory "NoClassDefFound"

Posted by Łukasz Dywicki <lu...@code-house.org>.
Hey Otavio,
You can verify what is exposed by two commands:
packages:imports <bundle-id>
packages:exports <bundle-id>

Also if you library try to use Thread ContextClassLoader you may get these errors.

Regards,
Lukasz

> Hello,
> 
> I am having problems making Karaf load the contents of a non-bundled
> java library (Webpshere MQ client 6.0.2.4).
> 
> To have Karaf use them, I have added the following files to the lib directory:
> - com.ibm.mq.jar
> - ibm.mqjms.jar
> - dhbcore.jar
> 
> After that, I modified the startup script so that it loaded those
> files. Additionally, I configured the custom.properties file so that
> they are accessible from outside:
> 
> org.osgi.framework.system.packages.extra=com.google.common.base,\
> com.google.common.collect,sun.misc, com.ibm.mq, com.ibm.mq.jms,\
> com.ibm.msg.client.jms,com.ibm.disthub2.*,com.google.common.collect.*
> 
> Even after doing that, when I deploy my bundle it stays in "resolved"
> state and does nothing. When I bounce Karaf,  I get the following
> exception:
> 
> ERROR: Bundle com.spcs.wsd [78] Error starting
> file:/home/orpiske/environments/wsd-transaction-core-0.0.1-SNAPSHOT/deploy/service_manager-0.0.1-SNAPSHOT-bundle.jar
> (org.osgi.framework.BundleException: Activator start error in bundle
> com.spcs.wsd [78].
> java.lang.NoClassDefFoundError: com/ibm/mq/jms/MQQueueConnectionFactory
> 	at com.spcs.wsd.camel.wmq.WmqJmsComponentBuilder.getMQQueueConnectionFactory(WmqJmsComponentBuilder.java:58)
> 	at com.spcs.wsd.camel.wmq.WmqJmsComponentBuilder.build(WmqJmsComponentBuilder.java:84)
> 	at com.spcs.wsd.service.manager.ServiceManager.registerNewComponent(ServiceManager.java:28)
> 	at com.spcs.wsd.service.manager.ServiceManager.<init>(ServiceManager.java:22)
> 	at com.spcs.wsd.service.manager.ServiceActivationManager.start(ServiceActivationManager.java:19)
> 	at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:629)
> 	at org.apache.felix.framework.Felix.activateBundle(Felix.java:1842)
> 	at org.apache.felix.framework.Felix.startBundle(Felix.java:1759)
> 	at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1163)
> 	at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
> 	at java.lang.Thread.run(Thread.java:662)
> 
> 
> It looks like Karaf is not exposing or being able to expose the
> contents of that package to other classes. I did a quick test,
> following those steps, but exposing a simple hello-world jar and it
> works flawlessly.
> 
> In addition to those steps, I also tried to run "osgi:install -w
> wrap:file:lib/filename.jar" but it did not work either.
> 
> Would anyone know would prevent Karaf from accessing that library or
> would have any idea of how to overcome this?
> 
> Regards
> -- 
> Otavio R. Piske
> http://orpiske.net