我有这个 Maven 依赖项......
<dependency>
<groupId>javanettasks</groupId>
<artifactId>httpunit</artifactId>
<version>1.7</version>
<scope>test</scope>
</dependency>
我需要这个来进行一些我正在运行的测试。该库依赖于 xercesImpl v 2.4。问题是,当我们通过 Bamboo 集成服务器运行它时,我们会收到 ClassCastException,因为我们的服务器使用更高版本的 xerces。有谁知道我该如何调和这个?换句话说,有没有办法让我的 xercesImpl 在测试阶段在类加载器中优先?
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)
谢谢, - 戴夫