1 Reply Latest reply on Oct 19, 2012 11:55 AM by mksplg

    ClassCastException when using Xerces in an application

    mksplg

      I use Picketlink 2.1.4 SAML on JBoss 7.1.0 in a project. One of the libraries I use (jena) has Apache Xerces as a dependency.

      When I use Deploy my applications and start JBoss everything works fine. However when I redeploy the application without restarting JBoss I get the following exception:

       

       

      {code:java}

      14:47:09,897 ERROR [org.picketlink.identity.federation] (http-localhost-127.0.0.1-8080-2) org.picketlink.identity.federation.core.exceptions.ProcessingException: PLFED000102: Processing Exception

      14:47:09,897 ERROR [org.apache.catalina.connector.CoyoteAdapter] (http-localhost-127.0.0.1-8080-2) An exception or error occurred in the container during the request processing: java.lang.RuntimeException: PLFED000146: Error during processing the SAML Handler Chain.

                at org.picketlink.identity.federation.PicketLinkLoggerImpl.samlHandlerChainProcessingError(PicketLinkLoggerImpl.java:1120) [picketlink-jbas7-2.1.4.Final.jar:2.1.4.Final]

                at org.picketlink.identity.federation.web.process.ServiceProviderBaseProcessor.process(ServiceProviderBaseProcessor.java:182) [picketlink-core-2.1.4.Final.jar:2.1.4.Final]

                at org.picketlink.identity.federation.bindings.tomcat.sp.AbstractSPFormAuthenticator.generalUserRequest(AbstractSPFormAuthenticator.java:555) [picketlink-jbas7-2.1.4.Final.jar:2.1.4.Final]

                at org.picketlink.identity.federation.bindings.tomcat.sp.AbstractSPFormAuthenticator.authenticate(AbstractSPFormAuthenticator.java:293) [picketlink-jbas7-2.1.4.Final.jar:2.1.4.Final]

                at org.picketlink.identity.federation.bindings.tomcat.sp.AbstractSPFormAuthenticator.authenticate(AbstractSPFormAuthenticator.java:253) [picketlink-jbas7-2.1.4.Final.jar:2.1.4.Final]

                at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:455) [jbossweb-7.0.10.Final.jar:]

                at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:154) [jboss-as-web-7.1.0.Final.jar:7.1.0.Final]

                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.10.Final.jar:]

                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.10.Final.jar:]

                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.10.Final.jar:]

                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.10.Final.jar:]

                at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.10.Final.jar:]

                at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.10.Final.jar:]

                at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.10.Final.jar:]

                at java.lang.Thread.run(Thread.java:679) [rt.jar:1.6.0_24]

      Caused by: org.picketlink.identity.federation.core.exceptions.ProcessingException: PLFED000102: Processing Exception

                at org.picketlink.identity.federation.PicketLinkLoggerImpl.processingError(PicketLinkLoggerImpl.java:85) [picketlink-jbas7-2.1.4.Final.jar:2.1.4.Final]

                at org.picketlink.identity.federation.web.handlers.saml2.SAML2AuthenticationHandler$SPAuthenticationHandler.generateSAMLRequest(SAML2AuthenticationHandler.java:393) [picketlink-core-2.1.4.Final.jar:2.1.4.Final]

                at org.picketlink.identity.federation.web.handlers.saml2.SAML2AuthenticationHandler.generateSAMLRequest(SAML2AuthenticationHandler.java:147) [picketlink-core-2.1.4.Final.jar:2.1.4.Final]

                at org.picketlink.identity.federation.web.process.ServiceProviderBaseProcessor.process(ServiceProviderBaseProcessor.java:176) [picketlink-core-2.1.4.Final.jar:2.1.4.Final]

                ... 13 more

      Caused by: 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) [xercesImpl-2.7.1.jar:]

                at org.apache.xerces.parsers.DOMParser.<init>(Unknown Source) [xercesImpl-2.7.1.jar:]

                at org.apache.xerces.jaxp.DocumentBuilderImpl.<init>(Unknown Source) [xercesImpl-2.7.1.jar:]

                at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Unknown Source) [xercesImpl-2.7.1.jar:]

                at __redirected.__DocumentBuilderFactory.newDocumentBuilder(__DocumentBuilderFactory.java:119) [jboss-modules.jar:1.1.1.GA]

                at org.picketlink.identity.federation.core.saml.v2.util.DocumentUtil.getDocument(DocumentUtil.java:155) [picketlink-core-2.1.4.Final.jar:2.1.4.Final]

                at org.picketlink.identity.federation.core.saml.v2.util.DocumentUtil.getDocument(DocumentUtil.java:139) [picketlink-core-2.1.4.Final.jar:2.1.4.Final]

                at org.picketlink.identity.federation.api.saml.v2.request.SAML2Request.convert(SAML2Request.java:270) [picketlink-core-2.1.4.Final.jar:2.1.4.Final]

                at org.picketlink.identity.federation.web.handlers.saml2.SAML2AuthenticationHandler$SPAuthenticationHandler.generateSAMLRequest(SAML2AuthenticationHandler.java:377) [picketlink-core-2.1.4.Final.jar:2.1.4.Final]

                ... 15 more


      {code}

      I have read that this is a know problem when using Xerces in an environment that uses multiple classloaders.

      http://xerces.apache.org/xerces2-j/faq-general.html#faq-5

      http://www.ibm.com/developerworks/websphere/library/techarticles/0310_searle/searle.html

      There was a similar problem in JBoss 5 when loading the configuration. It was fixed in JBoss 6 by switching the classloader. https://issues.jboss.org/browse/JBAS-7210 Maybe something similar would help here.

        • 1. Re: ClassCastException when using Xerces in an application
          mksplg

          I now have excluded org.jaxen und org.apache.xerces in all dependencies and have added them to the manifest file (using maven). It seems to work this way since only the version the JBoss provides is used.

           

          JBoss has an older version than what is specified in the actual dependency so it's not ideal but seems to work.