[
https://issues.apache.org/jira/browse/CAMEL-3625?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13044604#comment-13044604
]
Richard Kettelerij edited comment on CAMEL-3625 at 6/5/11 7:51 PM:
-------------------------------------------------------------------
I've encountered this issue multiple times in IntelliJ (v10.0.3 CE on OSX
10.6.7 with JDK 10.6.24). Pretty annoying.
Johan's fix resolves it, but I'm a little hesitant to commit the fix because it
doesn't take Camel's {{ClassResolver}} abstracting into account. Sure it calls
{{getCamelContext().getClassResolver().getClass().getClassLoader()}} but this
isn't any different from {{this.getClass().getClassLoader()}}. Perhaps we can
introduce a system property that devs can enable in their IntelliJ
configuration:
{code} //Let us check if we can load this class...
if (System.getProperty("camel.enableIntellijWorkaround") != null) {
ClassLoader classLoader = getClass().getClassLoader();
try {
Class aClass =
classLoader.loadClass("org.apache.camel.core.xml.CamelJMXAgentDefinition");
//Keep going.
} catch (ClassNotFoundException e) {
return false;
}
}
{code}
Of course all of this won't be necessary if someone know the root cause...
was (Author: rkettelerij):
I've encountered this issue multiple times in IntelliJ (v10.0.3 CE on OSX
10.6.7 with JDK 10.6.24). Pretty annoying.
Johan's fix resolves it, but I'm a little hesitant to commit the fix because it
doesn't take Camel's {{ClassResolver}} abstracting into account. Sure it calls
{{getCamelContext().getClassResolver().getClass().getClassLoader()}} but this
isn't any different from {{this.getClass().getClassLoader()}}. Perhaps we can
introduce a system property that devs can enable in their IntelliJ
configuration:
{code} //Let us check if we can load this class...
if (System.getProperty("camel.enableIntellijWorkaround") != null) {
ClassLoader classLoader = getClass().getClassLoader();
try {
Class aClass =
classLoader.loadClass("org.apache.camel.core.xml.CamelJMXAgentDefinition");
//Keep going.
} catch (ClassNotFoundException e) {
return false;
}
}
{code}
> Testing in Intellij IDEA
> ------------------------
>
> Key: CAMEL-3625
> URL: https://issues.apache.org/jira/browse/CAMEL-3625
> Project: Camel
> Issue Type: Improvement
> Reporter: Edstrom Johan
> Assignee: Edstrom Johan
> Priority: Minor
>
> When running camel-components tests in Intellij IDEA you frequently run into
> {code}
> 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)
> {code}
> The following would handle the issue
> {code}
> 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) {
> {code}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira