I have this Maven dependency ...
<dependency>
<groupId>javanettasks</groupId>
<artifactId>httpunit</artifactId>
<version>1.7</version>
<scope>test</scope>
</dependency>
I need this for some tests that I'm running. This library relies on xercesImpl v 2.4. Problem is, When we run this through our Bamboo integration server, we get a ClassCastException because our server uses a higher version of xerces. Does anyone know how I can reconcile this? In other words, is there a way I can make my xercesImpl take precedence in the classloader during the test phase?
29-Nov-2011 12:55:12 Running com.myco.clearing.product.client.xmltohtml.XmlToHtmlServiceTest
29-Nov-2011 12:55:16 Loading inherited module 'com.myco.clearing.product.ProductPlusJUnit'
29-Nov-2011 12:55:16 [ERROR] Unexpected error while processing XML
29-Nov-2011 12:55:16 java.lang.ClassCastException: org.apache.xerces.parsers.XML11Configuration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration
29-Nov-2011 12:55:16 at org.apache.xerces.parsers.SAXParser.<init>(Unknown Source)
29-Nov-2011 12:55:16 at org.apache.xerces.parsers.SAXParser.<init>(Unknown Source)
29-Nov-2011 12:55:16 at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.<init>(Unknown Source)
29-Nov-2011 12:55:16 at org.apache.xerces.jaxp.SAXParserImpl.<init>(Unknown Source)
29-Nov-2011 12:55:16 at org.apache.xerces.jaxp.SAXParserFactoryImpl.newSAXParser(Unknown Source)
29-Nov-2011 12:55:16 at com.google.gwt.dev.util.xml.ReflectiveParser.createNewSaxParser(ReflectiveParser.java:65)
29-Nov-2011 12:55:16 at com.google.gwt.dev.util.xml.ReflectiveParser.access$000(ReflectiveParser.java:46)
29-Nov-2011 12:55:16 at com.google.gwt.dev.util.xml.ReflectiveParser$Impl.parse(ReflectiveParser.java:343)
29-Nov-2011 12:55:16 at com.google.gwt.dev.util.xml.ReflectiveParser$Impl.access$200(ReflectiveParser.java:68)
29-Nov-2011 12:55:16 at com.google.gwt.dev.util.xml.ReflectiveParser.parse(ReflectiveParser.java:418)
29-Nov-2011 12:55:16 at com.google.gwt.dev.cfg.ModuleDefLoader.nestedLoad(ModuleDefLoader.java:296)
29-Nov-2011 12:55:16 at com.google.gwt.dev.cfg.ModuleDefLoader$2.load(ModuleDefLoader.java:217)
29-Nov-2011 12:55:16 at com.google.gwt.dev.cfg.ModuleDefLoader.doLoadModule(ModuleDefLoader.java:324)
29-Nov-2011 12:55:16 at com.google.gwt.dev.cfg.ModuleDefLoader.createSyntheticModule(ModuleDefLoader.java:107)
29-Nov-2011 12:55:16 at com.google.gwt.junit.CompileStrategy.maybeCompileModuleImpl2(CompileStrategy.java:165)
29-Nov-2011 12:55:16 at com.google.gwt.junit.CompileStrategy.maybeCompileModuleImpl(CompileStrategy.java:112)
29-Nov-2011 12:55:16 at com.google.gwt.junit.SimpleCompileStrategy.maybeCompileModule(SimpleCompileStrategy.java:36)
29-Nov-2011 12:55:16 at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1340)
29-Nov-2011 12:55:16 at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1309)
29-Nov-2011 12:55:16 at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:653)
29-Nov-2011 12:55:16 at com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:441)
29-Nov-2011 12:55:16 at junit.framework.TestCase.runBare(TestCase.java:134)
29-Nov-2011 12:55:16 at junit.framework.TestResult$1.protect(TestResult.java:110)
29-Nov-2011 12:55:17 at junit.framework.TestResult.runProtected(TestResult.java:128)
29-Nov-2011 12:55:17 at junit.framework.TestResult.run(TestResult.java:113)
29-Nov-2011 12:55:17 at junit.framework.TestCase.run(TestCase.java:124)
29-Nov-2011 12:55:17 at com.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:296)
29-Nov-2011 12:55:17 at junit.framework.TestSuite.runTest(TestSuite.java:232)
29-Nov-2011 12:55:17 at junit.framework.TestSuite.run(TestSuite.java:227)
29-Nov-2011 12:55:17 at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
29-Nov-2011 12:55:17 at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:35)
29-Nov-2011 12:55:17 at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:115)
29-Nov-2011 12:55:17 at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:97)
29-Nov-2011 12:55:17 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
29-Nov-2011 12:55:17 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
29-Nov-2011 12:55:17 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
29-Nov-2011 12:55:17 at java.lang.reflect.Method.invoke(Method.java:597)
29-Nov-2011 12:55:17 at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
29-Nov-2011 12:55:17 at $Proxy0.invoke(Unknown Source)
29-Nov-2011 12:55:17 at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:150)
29-Nov-2011 12:55:17 at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:91)
29-Nov-2011 12:55:17 at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)
Thanks, - Dave
You could define the same
version
of Xerces as adependency
in both your client and server projects. This will take precedence over the transitive dependency on Xerces thathttpunit
has.However, if
httpunit
is incompatible with the Xerces version that you have declared, then you are in trouble.