PDA

View Full Version : dom Node Class not found


dbrosius
May 12th, 2008, 06:35 PM
I'm getting the following exception. I would have assumed that org/w3c/dom/Node was on the osgi platform's class path.

I see this buried down there

Caused by: java.lang.NoClassDefFoundError: org/w3c/dom/Node
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.ja va:2395)
at java.lang.Class.getMethod0(Class.java:2642)
at java.lang.Class.getMethod(Class.java:1579)


Does this mean that the class was found, but a method needed wasn't?


org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'echoService' defined in URL [bundleentry://108/META-INF/spring/echo-context.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/w3c/dom/Node
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1302)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:463)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:404)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:375)
at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 63)
at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:170)
at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:260 )
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:184)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:163)
at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:430)
at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:729)
at org.springframework.osgi.context.support.AbstractD elegatedExecutionApplicationContext.completeRefres h(AbstractDelegatedExecutionApplicationContext.jav a:269)
at org.springframework.osgi.extender.internal.depende ncies.startup.DependencyWaiterApplicationContextEx ecutor$CompleteRefreshTask.run(DependencyWaiterApp licationContextExecutor.java:141)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.NoClassDefFoundError: org/w3c/dom/Node
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.ja va:2395)
at java.lang.Class.getMethod0(Class.java:2642)
at java.lang.Class.getMethod(Class.java:1579)
at org.apache.cxf.common.xmlschema.SchemaCollection.<clinit>(SchemaCollection.java:53)
at org.apache.cxf.service.model.ServiceInfo.<init>(ServiceInfo.java:45)
at org.apache.cxf.service.factory.ReflectionServiceFa ctoryBean.buildServiceFromClass(ReflectionServiceF actoryBean.java:321)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBe an.buildServiceFromClass(JaxWsServiceFactoryBean.j ava:512)
at org.apache.cxf.service.factory.ReflectionServiceFa ctoryBean.initializeServiceModel(ReflectionService FactoryBean.java:394)
at org.apache.cxf.service.factory.ReflectionServiceFa ctoryBean.create(ReflectionServiceFactoryBean.java :180)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBe an.create(JaxWsServiceFactoryBean.java:163)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointF actory.createEndpoint(AbstractWSDLBasedEndpointFac tory.java:79)
at org.apache.cxf.frontend.ServerFactoryBean.create(S erverFactoryBean.java:114)
at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create (JaxWsServerFactoryBean.java:160)
at com.primavera.echo.installer.EchoInstaller.init(Ec hoInstaller.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeCustomInitMethod( AbstractAutowireCapableBeanFactory.java:1378)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1339)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1299)
... 14 more

oleg.zhurakousky
May 12th, 2008, 10:27 PM
NoClassDefFound could be triggered by several conditions, including the one you mentioned. It means that definition of the class that was available during compilation is different then definition available during runtime. org.w3c.dom package is included in JDK since Java 5, but I've seen people still use separate JAR file in the class path during compilation which results in this issue. Could you please provide more info as to what JVM you are using and if you have it also in the class path of your dev environment?

EDIT: Just realized the title of your post says Class not found and wanted to make sure you understand that there is difference between ClassNotFound and NoClassDefFound

Costin Leau
May 13th, 2008, 05:06 AM
All packages besides java.* need to be imported and exported - otherwise they will not be properly wired. Most OSGi platforms, by default, export the JDK packages including javax.* and org.w3c.dom however this might not be case for your setup.
Additionally, you bundle will have to import the org.w3c.dom package.
Make sure the bundle in question has the proper import (likely the cause of the problem) and then check your system exports (if you have problems post the name of the OSGi implementation and version).

dbrosius
May 13th, 2008, 01:30 PM
I went back to spring 2.5.2 (from 2.5.4) and the problem went away. I can live with that.

Costin Leau
May 13th, 2008, 02:48 PM
What version of Spring-DM are you using?
Note that Spring AOP 2.5.2 has a dynamic import which resolves the missing class for you - this might seem convenient but in the long run it can backfire since you are not sure to what bundle it is actually wired.

dbrosius
May 13th, 2008, 03:36 PM
I'm using 1.1.0-m1. I tried m2, but couldn't get it to work.

Costin Leau
May 14th, 2008, 01:54 AM
In M2, the aop and class loading infrastructure has been improved removing the usage of DynamicImport and forcing static imports to be used instead. This is why some NoClassDefFound exceptions appear when migrating to M2.
I'd be interested to know what problems you faced when migrated to M2 from M1.