GWT2.8 : org.apache.xerces.parsers.XIncludeAwareParserConfiguration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration

1,871 views
Skip to first unread message

Darren Smith

unread,
Oct 6, 2016, 3:20:49 AM10/6/16
to GWT Users
Hi,

I am developing a <web-app> that contains within it
  - a vanilla HttpServlet
  - a GWT RPC Service implementation (RemoteServiceServlet) 

I am currently using [GWT2.8rc1].

Both servlets manipulate XML documents, and hence make calls to the following code
DocumentBuilderFactory docfactory = DocumentBuilderFactory.newInstance();
docfactory.setNamespaceAware(true); 

DocumentBuilder builder = docfactory.newDocumentBuilder();   // * problem here *

When I launch the application in Eclipse, using the embedded Jetty container, the vanilla HttpServlet will fail at the line
DocumentBuilder builder = docfactory.newDocumentBuilder();   // * problem here *

The error message is 
  java.lang.ClassCastException: org.apache.xerces.parsers.XIncludeAwareParserConfiguration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration

Having done some research, this exception is typically raised when there are several Xerces implementations found on the classpath.
(I can only see Xerces implementations in gwt-dev and in Eclipse as a plugin).


For the GWT RPC Service implementation, launched as part of the same <web-app>, the XML document processing works fine - i.e. no exception raised.

If I comment out in the web.xml file the GWT-RPC servlet defintion, then the vanilla HttpServlet will perform the XML document processing without an exception.


Has anyone encountered similar problems?

Darren Smith.


Ian Whyman

unread,
Oct 10, 2016, 11:10:08 AM10/10/16
to GWT Users
Hi Darren,

We are seeing the same issue, did you find any resolution?

Regards,

Ian

Drew Spencer

unread,
Oct 10, 2016, 11:16:18 AM10/10/16
to GWT Users
Hey guys, this might help you. I had an issue with an old Xerces on the path before: http://stackoverflow.com/questions/38457973/cant-compile-gwt-app-using-2-8-0-snapshot-and-java-8-with-gwt-maven-plugin

Happy coding!

Drew

Darren Smith

unread,
Oct 18, 2016, 5:37:08 AM10/18/16
to GWT Users
Hi Ian,

Yes, we are still seeing the problem. I've put it aside for the moment, hoping to revisit once we upgrade to a new GWT Release Candidate.
Glad to know I'm not the only one suffering from this :)

Cheers
Darren

Ian Whyman

unread,
Oct 25, 2016, 8:21:40 AM10/25/16
to GWT Users
It seems still to be an issue with the final 2.8.0 release

Ian

Peter Petranik

unread,
Dec 2, 2016, 5:10:58 AM12/2/16
to GWT Users
Hi, I have a same problem after I updated my application from GWT 2.7 to 2.8

That is the code that raises the exception:
DocumentBuilderFactory.newInstance().newDocumentBuilder()

And that is the exception: 

java.lang.ClassCastException: org.apache.xerces.parsers.XIncludeAwareParserConfiguration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration
at org.apache.xerces.parsers.DOMParser.<init>(Unknown Source)
at org.apache.xerces.parsers.DOMParser.<init>(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.<init>(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Unknown Source)
...

Has somebody already found some solution how to fix that ?

Juan Pablo Gardella

unread,
Dec 2, 2016, 9:00:04 AM12/2/16
to GWT Users
Try by removing/exluding (if you have it in you r dependencies) xerces. 

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.
To post to this group, send email to google-we...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Peter Petranik

unread,
Dec 2, 2016, 9:55:38 AM12/2/16
to GWT Users
I have the Xerces library as dependency as part of gwt-dev.jar that is set by GWT SDK. I am not using the maven for a project. My dependencies are defined just by Eclipse in Project Settings (check the screenshot)




Am Donnerstag, 6. Oktober 2016 09:20:49 UTC+2 schrieb Darren Smith:

Juan Pablo Gardella

unread,
Dec 2, 2016, 10:01:52 AM12/2/16
to GWT Users

Ian Whyman

unread,
Dec 2, 2016, 10:13:43 AM12/2/16
to google-we...@googlegroups.com
In the end we fixed that by shipping our own version of xerces & co in our war.
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "GWT Users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/google-web-toolkit/jZEikD1GbYk/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
--
Ian Whyman
Message has been deleted

Adam Gerbert

unread,
Dec 15, 2016, 1:50:37 PM12/15/16
to GWT Users
Ran into the same issue after upgrading to 2.8 from 2.7. Only happened in super dev mode, as the xerces dependency was coming from gwt-dev.jar. I fixed it in the same manner as Ian Whyman (thanks!), by including the dependency explicitly. 

Peter Petranik

unread,
Jan 9, 2017, 5:06:33 AM1/9/17
to GWT Users
I found the solution for my problem with this exception, according to Javadoc and databasesandlife.com I have used two system properties and problem was gone, because our code was written to use JDK xerces

-Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
-Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl

Leto

unread,
Jun 29, 2018, 12:07:25 PM6/29/18
to GWT Users


Am Dienstag, 25. Oktober 2016 14:21:40 UTC+2 schrieb Ian Whyman:
It seems still to be an issue with the final 2.8.0 release

Ian


I recently upgraded to GWT 2.8.2 (from the old version 2.6.0) I ran into the same problem ("org.apache.xerces.parsers.XIncludeAwareParserConfiguration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration").

What I would like to understand is, is the Xerces version packaged with GWT 2.8.2 (gwt-dev.jar) incompatible? The fix with 

-Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
-Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl

seems to work.

So are we talking about a kind of dependency-problem with GWT (2.8.0+)?

Thomas Broyer

unread,
Jun 30, 2018, 8:35:17 AM6/30/18
to GWT Users
What's in your classpath? There might probably be ways to avoid those situations, in GWT, but so few people have run into this that no one investigated further.

Leto

unread,
Jul 1, 2018, 3:13:43 AM7/1/18
to GWT Users


Am Samstag, 30. Juni 2018 14:35:17 UTC+2 schrieb Thomas Broyer:
What's in your classpath? There might probably be ways to avoid those situations, in GWT, but so few people have run into this that no one investigated further.


I stripped down my dependencies to just only a few, and if I omit the 

> -Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
> -Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl

arguments, the problem still occurs.

I use the simple Ant script, no Eclipse, no Maven in this setup. And within my Ant script, I print the current classpath, which results in:


> D:\[...]\gwt-2.8.2\gwt-user.jar
> D:\[...]\gwt-2.8.2\gwt-dev.jar
> D:\[...]\Eclipse\MyGwtApp\src
> D:\[...]\Eclipse\MyGwtApp\war\WEB-INF\classes
> D:\[...]\Eclipse\MyGwtApp\war\WEB-INF\lib
> D:\[...]\Eclipse\MyGwtApp\war\WEB-INF\lib\aopalliance-1.0.jar
> D:\[...]\Eclipse\MyGwtApp\war\WEB-INF\lib\gin-2.1.2.jar
> D:\[...]\Eclipse\MyGwtApp\war\WEB-INF\lib\guice-3.0.jar
> D:\[...]\Eclipse\MyGwtApp\war\WEB-INF\lib\guice-assistedinject-3.0.jar
> D:\[...]\Eclipse\MyGwtApp\war\WEB-INF\lib\gwt-visualization-1.1.2.jar
> D:\[...]\Eclipse\MyGwtApp\war\WEB-INF\lib\javax.inject-1.jar 



Slava Pankov

unread,
Jul 3, 2018, 10:57:55 PM7/3/18
to GWT Users
For me the following helps in my project's pom.xml:

    <!-- for unknown reason GWT 2.8 debugging under Eclipse fails without xerces dependency -->
    <dependency> 
      <groupId>xerces</groupId>
      <artifactId>xercesImpl</artifactId>
      <version>2.11.0</version>
    </dependency>
Reply all
Reply to author
Forward
0 new messages