11 Replies Latest reply on Apr 16, 2012 12:58 PM by barryr

    ClassNotFoundException: org.apache.activemq.xbean.XBeanBrokerService

    barryr

      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 ;

       

      Can anybody advise how to fix this?

       

      thanks.

        • 1. Re: ClassNotFoundException: org.apache.activemq.xbean.XBeanBrokerService
          ffang

          Hi,

           

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

           

          Freeman

          • 2. Re: ClassNotFoundException: org.apache.activemq.xbean.XBeanBrokerService
            barryr

            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?

            • 3. Re: ClassNotFoundException: org.apache.activemq.xbean.XBeanBrokerService
              barryr

              OK , ISWYM

               

              I added the dependency that contains the XBeanBrokerService class:

               

                         

               

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

              • 4. Re: ClassNotFoundException: org.apache.activemq.xbean.XBeanBrokerService
                ffang

                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

                • 5. Re: ClassNotFoundException: org.apache.activemq.xbean.XBeanBrokerService
                  barryr

                  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 because it is exposed to package 'org.apache.log4j' f

                  rom xxx.CamelTestJMS and org.ops4j.pax.logging.pax-logging-api via two dependency chains.

                   

                  Chain 1:

                    xxx.CamelTestJMS

                      import: (&(package=org.apache.log4j)(version>=0.0.0)(!(version>=1.0.0)))

                       |

                      export: package=org.apache.log4j

                    xxx.CamelTestJMS

                   

                  Chain 2:

                    xxx.CamelTestJMS

                      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

                   

                   

                  I Have these dependencies in my pom.xml:

                   

                            <dependency>

                  *               *

                   

                  Any ideas ?

                   

                  Many thanks.

                   

                  Barry.

                  • 6. Re: ClassNotFoundException: org.apache.activemq.xbean.XBeanBrokerService
                    ffang

                    You need Import-Package but not Export-Package for log4j packages

                     

                    Freeman

                    • 7. Re: ClassNotFoundException: org.apache.activemq.xbean.XBeanBrokerService
                      barryr

                      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:

                       

                      Bundle xxx:CamelTestJMS:bundle:0.0.23-SNAPSHOT : Unresolved references to by class(es) on the Bundle-Classpath[Jar:dot]:

                      • 8. Re: ClassNotFoundException: org.apache.activemq.xbean.XBeanBrokerService
                        barryr

                        Got it, default behaviour is * so I need ,* after log4j packages.

                        • 9. Re: ClassNotFoundException: org.apache.activemq.xbean.XBeanBrokerService
                          barryr

                          Hi Freeman,

                           

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

                           

                          org.osgi.framework.BundleException: Unresolved constraint in bundle xxx.CamelTestJMS : Unable to resolve 311.1: missing req

                          uirement 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)

                          • 10. Re: ClassNotFoundException: org.apache.activemq.xbean.XBeanBrokerService
                            ffang

                            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 , that's why you see such exception.

                             

                            Freeman

                            • 11. Re: ClassNotFoundException: org.apache.activemq.xbean.XBeanBrokerService
                              barryr

                              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 : 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.