Failed to define class

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Failed to define class

Sam Thomas
Hi guys!

Through the Instrumentation object that I receive when I register an agent I can obtain all the loaded classes.

Now each of these loaded classes (Class objects) I use getClasses() and getDeclaredClasses() to get the list of classes that are referred to within the loaded class as well as the Method equivalents to get methods of that loaded class.
The thing is those methods fail sometimes for reasons I am not sure of. I catch the NoClassDefFoundError in my code, but Jboss still dumps a warn message in console for the same. 
How can I prevent Jboss from dumping this log - since this error was already caught by my code - or is there a way of avoiding this somehow.

As an example,
On the class object for org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator when I call getClasses(), it fails with the below stack  - which I do catch for NoClassDefFoundError.

java.lang.NoClassDefFoundError: Failed to link org/springframework/aop/aspectj/autoproxy/AspectJAwareAdvisorAutoProxyCreator$PartiallyComparableAdvisorHolder (Module "deployment.spring-greeter.war" from Service Module Loader): org/aspectj/util/PartialOrder$PartialComparable

        at java.lang.ClassLoader.defineClass1(Native Method)

        at java.lang.ClassLoader.defineClass(ClassLoader.java:763)

        at java.lang.ClassLoader.defineClass(ClassLoader.java:839)

        at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:424)

        at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:519)

        at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:339)

        at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:126)

        at org.jboss.modules.Module.loadModuleClass(Module.java:731)

        at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:247)

        at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410)

        at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)

        at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)

        at java.lang.Class.getDeclaredClasses0(Native Method)

        at java.lang.Class.getDeclaredClasses(Class.java:1867)

        at java.lang.Class$2.run(Class.java:1504)

        at java.lang.Class$2.run(Class.java:1499)

        at java.security.AccessController.doPrivileged(Native Method)

        at java.lang.Class.getClasses(Class.java:1498)


But i see this warn message on the console from jboss 
2020-01-24 20:37:32,458 WARN  [org.jboss.modules.define] (Agent-Thread) Failed to define class org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator$PartiallyComparableAdvisorHolder in Module "deployment.spring-greeter.war" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link org/springframework/aop/aspectj/autoproxy/AspectJAwareAdvisorAutoProxyCreator$PartiallyComparableAdvisorHolder (Module "deployment.spring-greeter.war" from Service Module Loader): org/aspectj/util/PartialOrder$PartialComparable
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.lang.ClassLoader.defineClass(ClassLoader.java:839)
at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:424)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:519)
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:339)
at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:126)
at org.jboss.modules.Module.loadModuleClass(Module.java:731)
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:247)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
at java.lang.Class.getDeclaredClasses0(Native Method)
at java.lang.Class.getDeclaredClasses(Class.java:1867)
at java.lang.Class$2.run(Class.java:1504)
at java.lang.Class$2.run(Class.java:1499)
at java.security.AccessController.doPrivileged(Native Method)
at java.lang.Class.getClasses(Class.java:1498)



Thanks
./Sam

_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev