[keycloak-user] Issue with XPathFactory

carmen carmen.checa at masergy.com
Thu Oct 15 17:40:59 EDT 2015


Hi Bill,

I already had  <module name="javax.api”/> in my module.xml

I did find a workaround that I do not like and I am hoping that you can help me do it right


Ok so I first set  jaxp debug to true, 
and I was getting the following error

JAXP: using thread context class loader (ModuleClassLoader for Module "deployment.keycloak-server.war:main" from Service Module Loader) for search
11:03:40,517 ERROR [stderr] (default task-2) JAXP: Looking up system property 'javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom' <http://java.sun.com/jaxp/xpath/dom'>
11:03:40,517 ERROR [stderr] (default task-2) JAXP: The value is '__redirected.__XPathFactory'
11:03:40,517 ERROR [stderr] (default task-2) JAXP: createInstance(__redirected.__XPathFactory)
11:03:40,518 ERROR [stderr] (default task-2) JAXP: loaded __redirected.__XPathFactory from jar:file:/Users/Carmen/software/keycloak-demo-1.5.0.Final/keycloak/jboss-modules.jar!/__redirected/__XPathFactory.class
11:03:40,518 ERROR [stderr] (default task-2) JAXP: could not instantiate __redirected.__XPathFactory
11:03:40,519 ERROR [stderr] (default task-2) java.lang.ClassCastException: __redirected.__XPathFactory cannot be cast to javax.xml.xpath.XPathFactory
11:03:40,519 ERROR [stderr] (default task-2) 	at javax.xml.xpath.XPathFactoryFinder.createInstance(XPathFactoryFinder.java:306)
11:03:40,519 ERROR [stderr] (default task-2) 	at javax.xml.xpath.XPathFactoryFinder._newFactory(XPathFactoryFinder.java:184)
11:03:40,519 ERROR [stderr] (default task-2) 	at javax.xml.xpath.XPathFactoryFinder.newFactory(XPathFactoryFinder.java:157)


So it looked like there was  a class loader issue and the ClassCast was not working.
I did not know how to fix that, so I went ahead and I changed the property javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom <http://java.sun.com/jaxp/xpath/dom> back to the default, to override looking for __redirected.__XPathFactory 
The default implementation is a com.sun….. class that lives in rt.jar and when I tried that I was getting a ClassNotFound, so I went ahead, added Xalan to my module and changed the property to use the Xalan class: org.apache.path.jaxp.XPathFactoryImpl 
That worked.

I had that same issue with another class that was also overriden with a __redirected class (DocumentBuilderFactory), and once I set the default value to the default implementation, the implementation cannot be loaded because it is in rt.jar. I went around that by adding crimsom to my module.

So it looks like even though there is a dependency defined of java.api, those jars (at least for xml) do not contain implementations, just the interfaces, and the actual providers are in rt.jar and I get an error trying to load them.

So I really do not like what I have done. There’s got to be a way to be able to use the implementations in rt.jar, right?

Thanks
Maria

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-user/attachments/20151015/6efd3115/attachment.html 


More information about the keycloak-user mailing list