PDA

View Full Version : Problem with xerces and Spring-DM...


mburbidg
Jun 4th, 2008, 05:04 PM
I cannot resolve the following exception from the Spring-DM based web application:


java.lang.NoClassDefFoundError: org/w3c/dom/html/HTMLDocument
at org.apache.xml.serialize.OutputFormat.whichMethod( Unknown Source)
at org.apache.xml.serialize.OutputFormat.<init>(Unknown Source)
at com.adobe.dandelion.XmlUtils.serializeXml(XmlUtils .java:64)
at com.adobe.dandelion.BaseView.serializeXml(BaseView .java:89)
at com.adobe.dandelion.categories.CategoriesView.gene rateXml(CategoriesView.java:54)
at com.adobe.dandelion.categories.CategoriesView.rend erBody(CategoriesView.java:40)
at com.adobe.dandelion.BaseView.render(BaseView.java: 53)
at org.springframework.web.servlet.DispatcherServlet. render(DispatcherServlet.java:1173)
at org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:901)
at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:809)
at org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:571)
at org.springframework.web.servlet.FrameworkServlet.d oGet(FrameworkServlet.java:501)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:803)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:188)
at org.springframework.web.filter.CharacterEncodingFi lter.doFilterInternal(CharacterEncodingFilter.java :96)
at org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:210)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:151)
at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:870)
at org.apache.coyote.http11.Http11BaseProtocol$Http11 ConnectionHandler.processConnection(Http11BaseProt ocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.process Socket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThr ead.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:685)
at java.lang.Thread.run(Thread.java:613)


I'm using equinox 3.2.2 with catalina embedded within. I'm using com.springsource.org.apache.xerces-2.8.1.jar which I downloaded from BRIT. But it is missing the stuff that is in xml-apis.jar that comes with the standard xerces distribution. So using the bnd tool I created a bundle from xml-apis.jar. If I do a status I can see that the library was resolved.

I've included an import for the package in my manifest.

I've also tried just including the standard xerces jars in my war, but still get the same missing class def.

Has anyone successfully user xerces? Was there a special trick?

Thanks,
Michael-

mburbidg
Jun 4th, 2008, 06:26 PM
I went back to trying to use the libraries from my WAR, but I get the following exception when I do this:


nested exception is java.lang.LinkageError: loader constraints violated when linking org/xml/sax/ErrorHandler class


Does anyone know what this means?

mburbidg
Jun 4th, 2008, 06:42 PM
I just realized that org/w3c/dom/html/HTMLDocument is in the JDK. This must be the same problem as javax.transaction....

I have to find which bundle has that and specify a version.

What a pain! Getting the right set of jars is a nightmare!

mburbidg
Jun 4th, 2008, 07:53 PM
There is a single class in com.springsource.org.apache.xerces-2.8.1.jar in the package org.w3c.dom.html. This class in the JDK as well as the rest of the classes that are supposed to be in org.w3c.dom.html.

I tried removing the class and repackaging, but I must have to do something with the exports in the manifest also.

I'm not sure what to do here. Any help?

Michael-

mburbidg
Jun 4th, 2008, 08:26 PM
Wow, I got by that one. I removed the single class org/w3c/dom/html/HTMLDocument from com.springsource.org.apache.xerces-2.8.1.jar as well as it's export of org.w3c.dom.html. I then added an import for org.w3c.dom.html. I then repackaged and redeployed. That problem went away. It found it in the jdk. I think I said before I got this jar from BRITS. But it flat out doesn't work. I can't believe others haven't tried to use the xerces library from BRITS. And there appear to be other similar problems in the xerces jar.

Are others having similar problems?

Michael-

mburbidg
Jun 4th, 2008, 08:32 PM
Finally I had to add an import for org.w3c.dom.traversal to com.springsource.org.apache.xerces-2.8.1.jar and it now works completely.

Costin Leau
Jun 5th, 2008, 01:46 AM
Michael, as you pointed out the org.w3c package is part of the JDK - one can update it using the endorsed/ folder. In my case, all the packages that are using these packages have it wired to the JDK's one and I suspect this is similar to the general use.
However, it is entirely possible to use a different version inside OSGi - sorry to hear about the xerces problem you experienced. Next time you encounter a problem, please report it on S2BR issue tracker - normally they get addressed fairly fast.
For your case, I've created an issue myself which you can track at:
http://issuetracker.springsource.com/browse/BRITS-69

It's considerably nicer to have the problem fixed directly in the repo then locally on your machine (you run into distribution problems again).

sweeney
Jul 30th, 2008, 07:49 AM
Hi,

we have reworked the bundle packaging such that the org.w3c.dom packages should now all resolve properly. Please try the latest bundle and let us know if you still have any problems.

Tony.