java - Spring application fails on startup with NoClassDefFoundError when deployed in tc Server with Insight -
i have spring-based app (packaged war) runs fine in jetty , "ordinary" tomcat 7, produces strange noclassdeffounderror when it's deployed tc server spring insight. class it's complaining can't found in jar in web-inf/lib
folder (and i've double-checked no competing jars exist in tomcat shared lib folder).
here's stack trace, showing spring thinks can't locate class hierarchicalloop
:
java.lang.classnotfoundexception: com.foo.hierarchicalloop<com.foo.loop> @ org.apache.catalina.loader.webappclassloader.loadclass(webappclassloader.java:1714) ~[na:na] @ org.apache.catalina.loader.webappclassloader.loadclass(webappclassloader.java:1559) ~[na:na] ... 32 common frames omitted wrapped by: java.lang.noclassdeffounderror: com/foo/hierarchicalloop<com/foo/loop> @ java.lang.class.getdeclaredconstructors0(native method) ~[na:1.7.0_60] @ java.lang.class.privategetdeclaredconstructors(class.java:2532) ~[na:1.7.0_60] @ java.lang.class.getconstructor0(class.java:2842) ~[na:1.7.0_60] @ java.lang.class.getdeclaredconstructor(class.java:2053) ~[na:1.7.0_60] @ org.springframework.beans.factory.support.simpleinstantiationstrategy.instantiate(simpleinstantiationstrategy.java:80) ~[spring-beans-4.1.6.release.jar:4.1.6.release] @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.instantiatebean(abstractautowirecapablebeanfactory.java:1094) ~[spring-beans-4.1.6.release.jar:4.1.6.release] ... 26 common frames omitted wrapped by: org.springframework.beans.factory.beancreationexception: error creating bean name 'x12builder' defined in class path resource [spring/x12-builder-config.xml]: instantiation of bean failed; nested exception java.lang.noclassdeffounderror: com/foo/hierarchicalloop<com/foo/x12loop> @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.instantiatebean(abstractautowirecapablebeanfactory.java:1101) ~[spring-beans-4.1.6.release.jar:4.1.6.release]
if disable insight in server instance, app loads fine, , reproducible on 3 different machines. said, war loads correctly under jetty , tomcat (without insight). i'm pretty sure it's narrowed down insight does.
in experience, these kinds of mysterious noclassdeffounderror
or classnotfoundexception
errors caused class loader mixups. example, container's root classloader trying load classes application jar. in case insight black box me, i'm not sure it's doing under covers. suspect maybe spring classes coming classloader other application's classloader, explain why spring can't see classes jars in application's lib
. that's little more educated speculation, , if accurate have no idea how resolve it.
any ideas troubleshooting or insight how insight works appreciated.
it turns out due kind of limitation or bug in insight. class complaining about, hierarchicalloop<loop>
causing problems insight classloader (tomcatweavinginsightclassloader
) made report classnotfoundexception
. has type parameters; here's 2 classes involved in causing class loader problems:
public class loop<childtype extends loop> { //... } public class hierarchicalloop<childtype extends loop> extends loop<childtype> { //... }
this valid java , no other containers/classloaders (tomcat, jetty, junit) have problem loading classes. insight does, reason.
there subclasses of hierarchicalloop
of them specify loop
childtype
parameter, parameter isn't needed. able work around problem removing type parameter hierarchicalloop
:
public class hierarchicalloop extends loop<loop> { //.. }
i'm pretty sure bug in insight; i'd report have been unable find community support or bug reporting channel.
Comments
Post a Comment