11 Replies Latest reply on Apr 20, 2011 4:54 PM by wayn23

    NoSuchMethodError org.apache.felix.framework.ServiceReg with PaxExam

    wayn23

      I followed the setup instructions found on page

      http://fusesource.com/docs/esb/4.2/deploy_osgi/BestPractices-PaxExam.html

       

      and when I run the test the environment does not even properly start.

       

      java.lang.NoSuchMethodError: org.apache.felix.framework.ServiceRegistry.

      but still get the same error.

       

      How can I resolve this?

        • 1. Re: NoSuchMethodError org.apache.felix.framework.ServiceReg with PaxExam
          njiang

          Can you downgrade the  version of pax-exam-version to 1.2.1 and try again?

          If you upgrade the pax-exam-version, you may consider to upgrade the Karaf version at the same time.

           

          Willem

          • 2. Re: NoSuchMethodError org.apache.felix.framework.ServiceReg with PaxExam
            wayn23

            Downgrading to pax-exam version 1.2.1 yielded the same result.

            • 3. Re: NoSuchMethodError org.apache.felix.framework.ServiceReg with PaxExam
              wayn23

              I have looked at the source code for Felix Framework and found that the ServiceRegistry class constructor changed in Jun 2009.

               

              What version of Pax Exam do I need to match to it?

              • 4. Re: NoSuchMethodError org.apache.felix.framework.ServiceReg with PaxExam
                njiang

                Which version of Fuse ESB are you using?

                I did some test on the apache camel with Karaf 2.2.0 and PaxExam 1.6.1, everything looks good.

                 

                Willem

                • 5. Re: NoSuchMethodError org.apache.felix.framework.ServiceReg with PaxExam
                  wayn23

                  Thanks for trying it out and proving that it works for you. Now all I need to do is get the right versions so that it works for me.

                   

                  I started by using the versions as specified at http://fusesource.com/docs/esb/4.2/deploy_osgi/BestPractices-PaxExam.html which are;

                      <junit-version>4.4</junit-version>

                      <pax-exam-version>1.2.0</pax-exam-version>

                      <felix.karaf.version>1.4.0-fuse-01-00</felix.karaf.version>

                   

                  I then tried to use the highest version of each component that I could find. The highest version of Pax-Exam I can find is 1.2.4 located at repo1.maven.org/maven2.  I cannot find version 1.6.1 anywhere.  Please let me know what Maven repository I can find that in. 

                   

                  I have been browsing the source code for Pax-Exam at https://scm.ops4j.org/repos/ops4j/projects/pax/exam and cannot any version higher than 1.2.*, I also see the version 2 milestone and release candaidates but have not tried those yet.

                   

                  To me, it seems that there must be a newer version of pax-exam out there somewhere that matches the updates to the ServiceRegistry constructor change of Jun 2009 as that change was almost two years ago.

                  • 6. Re: NoSuchMethodError org.apache.felix.framework.ServiceReg with PaxExam
                    njiang

                    My mistake, the latest released PaxExam version is 1.2.4 which has the dependency of PaxRunner 1.6.0. But you may use the PaxRunner 1.6.1 which has the fix of slfj.

                     

                    Willem

                    • 7. Re: NoSuchMethodError org.apache.felix.framework.ServiceReg with PaxExam
                      wayn23

                      I tried with Pax-Runner 1.6.1 and even 1.7.1 and they both fail with the same NoSuchMethodError

                       

                      Here is the POM file I am using. The section in bold are the changes I made from the BestPractice page

                       

                      -


                       

                      -


                       

                      • 8. Re: NoSuchMethodError org.apache.felix.framework.ServiceReg with PaxExam
                        njiang

                        Can you try to use the latest released Karaf 2.2.0?

                        Please try to change this part

                        -<felix.karaf.version>1.4.0-fuse-02-00</felix.karaf.version>
                        +<karaf.version>2.2.0</karaf.version>
                        
                        
                        <!-- Apache Karaf integration -->
                        <dependency>
                        <groupId>org.apache.karaf.tooling</groupId>
                        <artifactId>org.apache.karaf.tooling.testing</artifactId>
                        <version>${karaf.version}</version>
                        <scope>test</scope>
                        </dependency>
                        
                        

                         

                        Willem

                        • 9. Re: NoSuchMethodError org.apache.felix.framework.ServiceReg with PaxExam
                          wayn23

                          I tried both

                              (Lorg/apache/felix/framework/Logger;)V

                               at org.ops4j.pax.runner.Run.createContext(Run.java:260)

                               at org.ops4j.pax.runner.Run.start(Run.java:213)

                               at org.ops4j.pax.runner.Run.start(Run.java:182)

                               at org.ops4j.pax.exam.container.def.internal.PaxRunnerTestContainer.start(PaxRunnerTestContainer.java:282)

                               at org.ops4j.pax.exam.junit.internal.JUnit4TestMethod.invoke(JUnit4TestMethod.java:142)

                               at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)

                               at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)

                               at org.ops4j.pax.exam.junit.internal.JUnit4MethodRoadie.runBeforesThenTestThenAfters(JUnit4MethodRoadie.java:60)

                               at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)

                               at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)

                               at org.ops4j.pax.exam.junit.JUnit4TestRunner.invokeTestMethod(JUnit4TestRunner.java:246)

                               at org.ops4j.pax.exam.junit.JUnit4TestRunner.runMethods(JUnit4TestRunner.java:196)

                               at org.ops4j.pax.exam.junit.JUnit4TestRunner$2.run(JUnit4TestRunner.java:186)

                               at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)

                               at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)

                               at org.ops4j.pax.exam.junit.JUnit4TestRunner.run(JUnit4TestRunner.java:182)

                               at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)

                               at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

                               at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

                               at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

                               at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

                               at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

                           

                          You previously mentioned that you had tested out Pax Exam and it worked for you.  Could you send me your pom file with the proper dependencies?

                           

                          Thanks

                          • 10. Re: NoSuchMethodError org.apache.felix.framework.ServiceReg with PaxExam
                            njiang

                            The pom that I mentioned is here[1],  you may consider to take a look at this test file[2].

                            Here are the dependency tree about pax-exam which may help you.

                            [INFO]+- org.ops4j.pax.exam:pax-exam:jar:1.2.4:test
                            [INFO] |  +- org.ops4j.base:ops4j-base-lang:jar:1.2.2:test
                            [INFO] |  \- org.ops4j.base:ops4j-base-store:jar:1.2.2:test
                            [INFO] +- org.ops4j.pax.exam:pax-exam-junit:jar:1.2.4:test
                            [INFO] |  +- org.ops4j.pax.exam:pax-exam-runtime:jar:1.2.4:test
                            [INFO] |  |  \- commons-discovery:commons-discovery:jar:0.4:test
                            [INFO] |  \- org.ops4j.pax.exam:pax-exam-junit-extender:jar:1.2.4:test
                            [INFO] +- org.ops4j.pax.runner:pax-runner-no-jcl:jar:1.6.1:test
                            [INFO] +- org.ops4j.pax.exam:pax-exam-container-default:jar:1.2.4:test
                            [INFO] |  +- org.ops4j.pax.exam:pax-exam-spi:jar:1.2.4:test
                            [INFO] |  +- org.ops4j.pax.exam:pax-exam-container-rbc-client:jar:1.2.4:test
                            [INFO] |  |  \- org.ops4j.pax.exam:pax-exam-container-rbc:jar:1.2.4:test
                            [INFO] |  \- org.ops4j.base:ops4j-base-net:jar:1.2.2:test
                            [INFO] |     \- org.ops4j.base:ops4j-base-monitors:jar:1.2.2:test
                            [INFO] +- org.ops4j.pax.exam:pax-exam-junit-extender-impl:jar:1.2.4:test
                            [INFO] |  +- org.ops4j.pax.swissbox:pax-swissbox-core:jar:1.3.1:test
                            [INFO] |  |  \- org.ops4j.pax.swissbox:pax-swissbox-lifecycle:jar:1.3.1:test
                            [INFO] |  \- org.ops4j.pax.swissbox:pax-swissbox-extender:jar:1.3.1:test
                            [INFO] |     \- org.ops4j.pax.swissbox:pax-swissbox-optional-jcl:jar:1.3.1:test
                            [INFO] +- org.ops4j.pax.swissbox:pax-swissbox-tinybundles:jar:1.2.0:test
                            [INFO] |  +- org.ops4j.base:ops4j-base-io:jar:1.2.1:test
                            [INFO] |  \- org.ops4j.pax.swissbox:pax-swissbox-bnd:jar:1.2.0:test
                            [INFO] |     \- biz.aQute:bndlib:jar:0.0.313:test
                            
                            

                            https://svn.apache.org/repos/asf/camel/trunk/tests/camel-itest-osgi/pom.xml

                            https://svn.apache.org/repos/asf/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationTestSupport.java

                             

                            Willem

                            • 11. Re: NoSuchMethodError org.apache.felix.framework.ServiceReg with PaxExam
                              wayn23

                              Thanks for the references. 

                               

                              I have tried to get the environment working by taking all the referenced dependencies and add them into my pom, but I consistently get the same error that the method cannot be found.

                               

                              I even deleted my local Maven repository and downloaded fresh, but that did not help.

                               

                              I followed the setup instructions found on page

                              http://fusesource.com/docs/esb/4.2/deploy_osgi/BestPractices-PaxExam.html

                              and cannot get it to work.  Could some else let me know if it works for them?

                               

                              I have spent too much time on this and will leave it for a while.