1 Reply Latest reply on Nov 30, 2006 10:57 AM by FRANCOIS MICHAUD

    java.lang.ClassCastException: org.apache.xerces.jaxp.SAXPars

    FRANCOIS MICHAUD Newbie

      Hi,

      I use a JBOSS 4.04 (Seam + JSF/Facelet) with a JVM Sun 1.5.09.

      One service must convert HTML to PDF. For this task, IText v.1.4.7 (http://www.lowagie.com/iText/) library is employed.

      But IText requires a SAX parser factory and when I'm calling action, I obtain the next exception :

      16:24:59,765 ERROR [STDERR] Error while converting document. Message: org.apache.xerces.jaxp.SAXParserFactoryImpl
      16:24:59,765 ERROR [STDERR] java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl
      16:24:59,765 ERROR [STDERR] at javax.xml.parsers.SAXParserFactory.newInstance(Unknown Source)


      In my classpath :

      commons-beanutils-1.7.0.jar
      commons-codec-1.3.jar
      commons-digester-1.6.jar
      emma_ant.jar
      emma.jar
      hibernate-all.jar
      javax.servlet.jsp.jar
      jboss-aop-jdk50.jar
      jboss-cache-jdk50.jar
      jboss-ejb3-all.jar
      jbpm-3.1.1.jar
      jgroups.jar
      jstl.jar
      mailstuff.jar
      myfaces-api-1.1.3.jar
      myfaces-impl-1.1.3.jar
      portlet-api-lib.jar
      servlet-api.jar
      testng-4.5.1-jdk15.jar
      jboss-seam-debug.jar
      jboss-seam-ui.jar
      jboss-seam.jar
      postgresql-8.1-407.jdbc3.jar
      commons-io-1.1.jar
      itext-1.4.7.jar
      Tidy.jar
      thirdparty-all.jar
      xerces.jar
      resolver.jar
      serializer.jar
      xml-apis.jar
      


      EAR hierarchy :

      EAR
       + itext-1.4.7.jar
       + jboss-seam.jar
       + jbpm-3.1.1.jar
       + Tidy.jar
       + application.jar
       + application.ear


      Partial code of service :
       try {
       SAXParserFactory factory = SAXParserFactory.newInstance();
       SAXParser saxParser = factory.newSAXParser();
      
       if (saxParser != null) {
       Document document = new Document(PageSize.A4);
       PdfWriter.getInstance(document, out);
       }
       }
       catch (ParserConfigurationException e)
       {
       System.err.println("[ParserConfigurationException] Error while converting document. Message: " + e.getMessage());
       }
       catch (Exception e) {
       System.err.println("Error while converting document. Message: " + e.getMessage());
       e.printStackTrace();
       }


      Exist there a configuration handling to solve this problem ?

      Thank you for your help.


        • 1. Re: java.lang.ClassCastException: org.apache.xerces.jaxp.SAX
          FRANCOIS MICHAUD Newbie

          Sorry, there are some errors :

          for the EAR :

          + itext-1.4.7.jar
           + jboss-seam.jar
           + jbpm-3.1.1.jar
           + Tidy.jar
           + application.jar
           + application.war
          


          and I forget application.xml file :

          <application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee
           http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
          
           <display-name>Zou</display-name>
           <module>
           <web>
           <web-uri>zou.war</web-uri>
           <context-root>/zou</context-root>
           </web>
           </module>
          
           <module>
           <ejb>zou.jar</ejb>
           </module>
          
           <module>
           <java>jboss-seam.jar</java>
           </module>
          
           <module>
           <java>jbpm-3.1.1.jar</java>
           </module>
          
           <module>
           <java>xml-apis.jar</java>
           </module>
          
           <module>
           <java>itext-1.4.7.jar</java>
           </module>
          
           <module>
           <java>Tidy.jar</java>
           </module>
          </application>
          


          Erratum : the classpath is Eclipse classpath.

          Thank you.