Forum Home » Fuse Distributions » Fuse ESB

Thread: ClassNotFoundException: org.apache.activemq.xbean.XBeanBrokerService

 
This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 11 - Last Post: Apr 16, 2012 4:58 PM Last Post By: barryr
barryr

Posts: 8
Registered: 04/13/12
ClassNotFoundException: org.apache.activemq.xbean.XBeanBrokerService
Posted: Apr 13, 2012 7:40 PM
 
  Click to reply to this thread Reply
Hello,

I have a camel route that has org.apache.camel dependencies at version 2.9.1

When I try to install in fuse esb I get an error (because camel features are all at version 2.8.0)

So when I rebuild the bundle with 2.8.0 components and try to install I now get:

java.lang.ClassNotFoundException: org.apache.activemq.xbean.XBeanBrokerService not found by org.apache.xbean.spring 87;

Can anybody advise how to fix this?

thanks.
ffang

Posts: 1,320
Registered: 12/24/07
Re: ClassNotFoundException: org.apache.activemq.xbean.XBeanBrokerService
Posted: Apr 13, 2012 11:00 PM   in response to: barryr in response to: barryr
 
  Click to reply to this thread Reply
Hi,

Did you camel router bundle already import org.apache.activemq.xbean package?

Freeman
barryr

Posts: 8
Registered: 04/13/12
Re: ClassNotFoundException: org.apache.activemq.xbean.XBeanBrokerService
Posted: Apr 14, 2012 7:49 AM   in response to: ffang in response to: ffang
 
  Click to reply to this thread Reply
Hi Freeman, thanks for replying.

No my bundle does not have org.apache.activemq.xbean in its dependencies - it runs fine in the Eclipse IDE - its only when I deploy it to servicemix that I see this dependency?
barryr

Posts: 8
Registered: 04/13/12
Re: ClassNotFoundException: org.apache.activemq.xbean.XBeanBrokerService
Posted: Apr 14, 2012 8:03 AM   in response to: barryr in response to: barryr
 
  Click to reply to this thread Reply
OK , ISWYM

I added the dependency that contains the XBeanBrokerService class:

<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-core</artifactId>
<version>5.5.1</version>
<type>bundle</type>
<scope>compile</scope>
</dependency>

But I'm still getting exactly the same ClassNotFound exception in Servicemix?
ffang

Posts: 1,320
Registered: 12/24/07
Re: ClassNotFoundException: org.apache.activemq.xbean.XBeanBrokerService
Posted: Apr 14, 2012 10:17 AM   in response to: barryr in response to: barryr
 
  Click to reply to this thread Reply
Hi,

You need import org.apache.activemq.xbean package in maven-bundle-plugin, add the dependency doesn't mean it will import such package.

Freeman
barryr

Posts: 8
Registered: 04/13/12
Re: ClassNotFoundException: org.apache.activemq.xbean.XBeanBrokerService
Posted: Apr 15, 2012 8:28 AM   in response to: ffang in response to: ffang
 
  Click to reply to this thread Reply
Hi Freeman, many thanks your post; it was a great help and much appreciated.

I added the following configuration:

<configuration>
<instructions>
<Export-Package>org.apache.activemq.xbean</Export-Package>
<Include-Resource>{maven-resources}, {maven-dependencies}</Include-Resource>
</instructions>
</configuration>

Which solved the XBeanBrokerService issue.

But then I was getting message exchange errors due to:

Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Appender

So I added log4j to the Exported Packages:

<Export-Package>org.apache.log4j,org.apache.log4j.config,org.apache.log4j.helpers,
* org.apache.log4j.or,org.apache.log4j.pattern</Export-Package>*

But I'm now getting:

karaf@root> osgi:start 295
Error executing command: Unable to resolve module xxx.CamelTestJMS http://295.0 because it is exposed to package 'org.apache.log4j' f
rom xxx.CamelTestJMS http://295.0 and org.ops4j.pax.logging.pax-logging-api http://3.0 via two dependency chains.

Chain 1:
xxx.CamelTestJMS http://295.0
import: (&(package=org.apache.log4j)(version>=0.0.0)(!(version>=1.0.0)))
|
export: package=org.apache.log4j
xxx.CamelTestJMS http://295.0

Chain 2:
xxx.CamelTestJMS http://295.0
import: (package=org.apache.log4j.spi)
|
export: package=org.apache.log4j.spi; uses:=org.apache.log4j
export: package=org.apache.log4j
org.ops4j.pax.logging.pax-logging-api http://3.0

I Have these dependencies in my pom.xml:

<dependency>

  • <groupId>org.slf4j</groupId>*
  • <artifactId>slf4j-api</artifactId>*
  • <version>1.6.1</version>*
  • </dependency>*
  • <dependency>*
  • <groupId>org.slf4j</groupId>*
  • <artifactId>slf4j-log4j12</artifactId>*
  • <version>1.6.1</version>*
  • </dependency>*
  • <dependency>*
  • <groupId>log4j</groupId>*
  • <artifactId>log4j</artifactId>*
  • <version>1.2.16</version>*
  • </dependency>*

Any ideas ?

Many thanks.

Barry.
ffang

Posts: 1,320
Registered: 12/24/07
Re: ClassNotFoundException: org.apache.activemq.xbean.XBeanBrokerService
Posted: Apr 15, 2012 8:48 AM   in response to: barryr in response to: barryr
 
  Click to reply to this thread Reply
You need Import-Package but not Export-Package for log4j packages

Freeman
barryr

Posts: 8
Registered: 04/13/12
Re: ClassNotFoundException: org.apache.activemq.xbean.XBeanBrokerService
Posted: Apr 15, 2012 10:03 AM   in response to: ffang in response to: ffang
 
  Click to reply to this thread Reply
Thanks Freeman, apologies for what these must be basic questions.

I changed the log4j to Import-Package but then got an error when building in eclipse:

ERROR Bundle xxx:CamelTestJMS:bundle:0.0.23-SNAPSHOT : Unresolved references to http://com.test.a.api, javax.annotation, javax.xml.namespace, javax.xml.parsers, javax.xml.xpath, org.apache.activemq.broker, org.apache.activemq.camel.component, org.apache.activemq.store, org.apache.activemq.store.kahadb.plist, org.apache.activemq.usage, org.apache.activemq.util, org.apache.camel, org.apache.camel.builder, org.apache.camel.model, org.apache.camel.spring, org.apache.xbean.spring.context, org.apache.xbean.spring.context.impl, org.slf4j, org.springframework.beans, org.springframework.beans.factory, org.springframework.beans.factory.xml, org.springframework.context, org.springframework.context.support, org.springframework.core.io, org.springframework.util, org.w3c.dom, org.xml.sax by class(es) on the Bundle-ClasspathJar:dot: http://org/apache/activemq/xbean/XBeanBrokerFactory.class, org/apache/activemq/xbean/XBeanBrokerFactory$1.class, com/test/integrator/server/Rx/Connection.class, xxx/CamelTestJMS/util/XML2Rx.class, xxx/CamelTestJMS/MyProcessor.class, org/apache/activemq/xbean/BrokerFactoryBean.class, com/test/integrator/server/Rx/RxSender.class, xxx/CamelTestJMS/util/XML2RxTest.class, org/apache/activemq/xbean/XBeanBrokerService.class, org/apache/camel/example/client/CamelClient.class, com/test/integrator/server/routes/MyRouteBuilder.class
barryr

Posts: 8
Registered: 04/13/12
Re: ClassNotFoundException: org.apache.activemq.xbean.XBeanBrokerService
Posted: Apr 15, 2012 10:14 AM   in response to: barryr in response to: barryr
 
  Click to reply to this thread Reply
Got it, default behaviour is * so I need ,* after log4j packages.
barryr

Posts: 8
Registered: 04/13/12
Re: ClassNotFoundException: org.apache.activemq.xbean.XBeanBrokerService
Posted: Apr 15, 2012 10:16 AM   in response to: ffang in response to: ffang
 
  Click to reply to this thread Reply
Hi Freeman,

When I use Import-Package for log4j I now get:

org.osgi.framework.BundleException: Unresolved constraint in bundle xxx.CamelTestJMS 311: Unable to resolve 311.1: missing req
uirement http://311.1 package; (&(package=org.apache.log4j)(version>=0.0.0)(!(version>=1.0.0)))
at org.apache.felix.framework.Felix.resolveBundle(Felix.java:3466)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1739)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1168)
at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
at java.lang.Thread.run(Thread.java:662)
ffang

Posts: 1,320
Registered: 12/24/07
Re: ClassNotFoundException: org.apache.activemq.xbean.XBeanBrokerService
Posted: Apr 15, 2012 11:09 PM   in response to: barryr in response to: barryr
 
  Click to reply to this thread Reply
Hi,

The log4j package version available in the OSGi container is 1.2.15, so you need import log4j package with correct version range accordingly. Currently the version range is http://0.0.0, 1.0.0, that's why you see such exception.

Freeman
barryr

Posts: 8
Registered: 04/13/12
Re: ClassNotFoundException: org.apache.activemq.xbean.XBeanBrokerService
Posted: Apr 16, 2012 4:58 PM   in response to: ffang in response to: ffang
 
  Click to reply to this thread Reply
Hi Freeman,

I tried:

<Import-Package>org.apache.activemq.xbean,org.apache.log4j,org.apache.activemq.broker,
org.apache.log4j.config; org.apache.log4j.helpers; org.apache.log4j.or; org.apache.log4j.pattern; version="1.2.15", *</Import-Package>

But still get this error when I start the bundle:

karaf@root> osgi:start 366
Error executing command: Unresolved constraint in bundle xxx.CamelTestJMS 366: Unable to resolve 366.0: missing requirement [3
66.0] package; (&(package=org.apache.log4j.config)(version>=1.2.15))

Is my syntax incorrect for Import-Package ?

thanks,
Barry.