Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Not a Problem
    • Affects Version/s: None
    • Fix Version/s: 2.11.0
    • Component/s: None
    • Labels:
      None
    • Patch Info:
      Patch Available

      Description

      When running camel-components tests in Intellij IDEA you frequently run into

      java.lang.NoClassDefFoundError: org/apache/camel/core/xml/CamelJMXAgentDefinition
      	at org.apache.camel.spring.CamelBeanPostProcessor.canPostProcessBean(CamelBeanPostProcessor.java:209)
      	at org.apache.camel.spring.CamelBeanPostProcessor.postProcessBeforeInitialization(CamelBeanPostProcessor.java:89)
      	at org.apache.camel.test.junit4.CamelTestSupport.postProcessTest(CamelTestSupport.java:190)
      	at org.apache.camel.test.junit4.CamelTestSupport.setUp(CamelTestSupport.java:133)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
      	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
      	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
      	at org.junit.runners.Suite.runChild(Suite.java:128)
      	at org.junit.runners.Suite.runChild(Suite.java:24)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
      	at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
      	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:65)
      

      The following would handle the issue

      Index: components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java
      ===================================================================
      --- components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java	(revision 1065694)
      +++ components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java	(revision )
      @@ -192,6 +192,17 @@
            * @return true to process it
            */
           protected boolean canPostProcessBean(Object bean, String beanName) {
      +
      +         //Let us check if we can load this class...
      +        ClassLoader classLoader = getCamelContext().getClassResolver().getClass().getClassLoader();
      +
      +        try {
      +            Class aClass = classLoader.loadClass("org.apache.camel.core.xml.CamelJMXAgentDefinition");
      +            //Keep going.
      +        } catch (ClassNotFoundException e) {
      +           return false;
      +        }
      +
               // the JMXAgent is a bit strange and causes Spring issues if we let it being
               // post processed by this one. It does not need it anyway so we are good to go.
               if (bean instanceof CamelJMXAgentDefinition) {
      

        Activity

        Edstrom Johan created issue -
        Edstrom Johan made changes -
        Field Original Value New Value
        Assignee Edstrom Johan [ joed ]
        Claus Ibsen made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.11.0 [ 12321695 ]
        Resolution Not A Problem [ 8 ]

          People

          • Assignee:
            Edstrom Johan
            Reporter:
            Edstrom Johan
          • Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development