My Play project currently depends on Play’s pdf module version 0.9 and JavaAPIforKml 2.2.0 (used to create objects representing kml files).
Previously I was using pdf module version 0.7 and everything was working fine.
Now that I have upgraded to version 0.9, all my tests for kml based classes now fail. The exception I get is this:
java.lang.ClassNotFoundException: org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl
at java.lang.ClassLoader.findClass(ClassLoader.java:358)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at
play.classloading.ApplicationClassloader.loadClass(ApplicationClassloader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at javax.xml.datatype.FactoryFinder.getProviderClass(FactoryFinder.java:115)
at javax.xml.datatype.FactoryFinder.newInstance(FactoryFinder.java:146)
at javax.xml.datatype.FactoryFinder.findJarServiceProvider(FactoryFinder.java:298)
at javax.xml.datatype.FactoryFinder.find(FactoryFinder.java:223)
at javax.xml.datatype.DatatypeFactory.newInstance(DatatypeFactory.java:131)
at com.sun.xml.bind.DatatypeConverterImpl.<clinit>(DatatypeConverterImpl.java:833)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl$3.run(JAXBContextImpl.java:287)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl$3.run(JAXBContextImpl.java:286)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:285)
at
com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1140)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:154)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:202)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:363)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522)
at de.micromata.opengis.kml.v_2_2_0.Kml.getJaxbContext(Kml.java:631)
at de.micromata.opengis.kml.v_2_2_0.Kml.createMarshaller(Kml.java:640)
at de.micromata.opengis.kml.v_2_2_0.Kml.marshal(Kml.java:682)
The part of the code that causes the exception is this:
de.micromata.opengis.kml.v_2_2_0.Kml kml = ...
kml.marshal(someByteArrayOutputStream); // This is the line that causes the exception
If I switch back to pdf module version 0.7, everything works again. Does anyone know what I could do to keep using pdf module version 0.9 and have the kml tests to continue to work?
In case it helps, the pdf module version 0.9 has these dependencies:
core-renderer.jar
itest-2.1.7.jar
jaxen-1.1.jar
jtidy-r938.jar
shani-parser-v1.4.17.jar
xml-apis.jar
yahp-internal.jar
yahp.jar
While the JavaApiForKml version 2.2.0 has these dependencies:
jaxb-impl 2.2
jaxb-xjc 2.2
xmlunit 1.2
I’ve managed to get my build to work again however I don’t particularly like the solution. Firstly, I download the xerces2 library from apache.
I put the jar into the lib directory and the build worked. This library never existed previously so I’m not sure how it worked before.
I then put the xerces jar in its own play “module” called xerces so that when running
play deps --syncthe xerces jar would not get wiped from the lib directory. After running the build using this technique the build failed again!So after more playing around, I thought it may have something to do with the ordering of the jars. I renamed the xerces module I created to be called apache-xerces and re-ran the build and the build started working again!