MohamedSaeed / xdocreport

Automatically exported from code.google.com/p/xdocreport
1 stars 0 forks source link

java.lang.ClassCastException: org.apache.xerces.parsers.SAXParser cannot be cast to org.xml.sax.XMLReader #332

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,
I would to use xdocreporter to develop a atlassian jira plugin using velocity.

I followed this tutorial 
http://code.google.com/p/xdocreport/wiki/DocxReportingWEBApplicationServlet

This is my error :

java.lang.ClassCastException: org.apache.xerces.parsers.SAXParser cannot be 
cast to org.xml.sax.XMLReader
fr.opensagres.xdocreport.core.XDocReportException: 
java.lang.ClassCastException: org.apache.xerces.parsers.SAXParser cannot be 
cast to org.xml.sax.XMLReader
    at fr.opensagres.xdocreport.document.docx.DocxReport.onBeforePreprocessing(DocxReport.java:183)
    at fr.opensagres.xdocreport.document.AbstractXDocReport.doPreprocessorIfNeeded(AbstractXDocReport.java:347)
    at fr.opensagres.xdocreport.document.AbstractXDocReport.process(AbstractXDocReport.java:512)
    at fr.opensagres.xdocreport.document.AbstractXDocReport.process(AbstractXDocReport.java:487)
    at fr.opensagres.xdocreport.document.web.AbstractProcessXDocReportServlet.doProcessReport(AbstractProcessXDocReportServlet.java:311)
    at fr.opensagres.xdocreport.document.web.AbstractProcessXDocReportServlet.doGenerateReport(AbstractProcessXDocReportServlet.java:253)
    at fr.opensagres.xdocreport.document.web.AbstractProcessXDocReportServlet.processRequest(AbstractProcessXDocReportServlet.java:113)
    at fr.opensagres.xdocreport.document.web.BaseXDocReportServlet.doGet(BaseXDocReportServlet.java:78)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

Thanks

Original issue reported on code.google.com by nadirmez...@gmail.com on 21 Nov 2013 at 12:07

GoogleCodeExporter commented 9 years ago
Your error comes from 
https://code.google.com/p/xdocreport/source/browse/document/fr.opensagres.xdocre
port.document.docx/src/main/java/fr/opensagres/xdocreport/document/docx/DocxRepo
rt.java#166

In this code we use standard code to parse XML with SAX : 

------------------------------------------
XMLReader xmlReader = XMLReaderFactory.createXMLReader();
xmlReader.setContentHandler( contentHandler );
xmlReader.parse( new InputSource( reader ) );
------------------------------------------

I suggest you to search with google "java.lang.ClassCastException: 
org.apache.xerces.parsers.SAXParser cannot be cast to org.xml.sax.XMLReader". 
It seems that's it's a problem with a JAR (xerces-impl?).

if you find which JARs cause problem, it should be cool to tell us. Many 
thank's.

Regards Angelo

Original comment by angelo.z...@gmail.com on 21 Nov 2013 at 1:02

GoogleCodeExporter commented 9 years ago

I use the xerces-impl 2.9.1

Original comment by nadirmez...@gmail.com on 21 Nov 2013 at 1:50

GoogleCodeExporter commented 9 years ago
Just, i have omitted this 
Caused by: java.lang.ClassCastException: org.apache.xerces.parsers.SAXParser 
cannot be cast to org.xml.sax.XMLReader
    at org.xml.sax.helpers.XMLReaderFactory.loadClass(Unknown Source)
    at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(Unknown Source)
    at fr.opensagres.xdocreport.document.docx.DocxReport.onBeforePreprocessing(DocxReport.java:166)

Original comment by nadirmez...@gmail.com on 21 Nov 2013 at 2:27

GoogleCodeExporter commented 9 years ago
I cannot help you more. If you have this problem it means that if you use other 
libraries (spring, hibernate, etc) in your application which uses SAX, those 
libraries will crash too. Perhaps you could post your problem on Xerces forum.

Original comment by angelo.z...@gmail.com on 21 Nov 2013 at 2:36

GoogleCodeExporter commented 9 years ago
Hi,
I have resolved this bug,  rebuilding my project  and  deleting  this 
dependency in my pom.xml
<dependency>
  <groupId>fr.opensagres.xdocreport</groupId>
  <artifactId>fr.opensagres.xdocreport.converter.docx.xwpf</artifactId>
  <version>1.0.3</version>
</dependency>

Original comment by nadirmez...@gmail.com on 27 Nov 2013 at 10:19

GoogleCodeExporter commented 9 years ago
Ok thank's, I close this issue.

Original comment by angelo.z...@gmail.com on 12 Dec 2013 at 1:55