如何在Maven自己的构建类路径中调试依赖冲突

时间:2015-01-16 09:42:16

标签: java maven

我今天遇到了Maven的一个奇怪问题。我在运行单元测试时遇到了以下异常:

java.lang.VerifyError: class com.google.debugging.sourcemap.proto.Mapping$OriginalMapping overrides final method getUnknownFields.()Lcom/google/protobuf/UnknownFieldSet;
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at com.google.debugging.sourcemap.SourceMapConsumerV3.getOriginalMappingForEntry(SourceMapConsumerV3.java:533)
        at com.google.debugging.sourcemap.SourceMapConsumerV3.getMappingForLine(SourceMapConsumerV3.java:253)
        at org.stjs.generator.sourcemap.JavascriptToJava.getJavaLine(JavascriptToJava.java:46)
        at org.stjs.generator.sourcemap.JavascriptToJava.buildStacktraceElement(JavascriptToJava.java:107)
        at org.stjs.generator.sourcemap.JavascriptToJava.buildStacktrace(JavascriptToJava.java:147)
        at org.stjs.testing.driver.TestResult.buildException(TestResult.java:66)
        at org.stjs.testing.driver.TestResultCollection.buildException(TestResultCollection.java:64)
        at org.stjs.testing.driver.STJSTestDriverRunner$1.evaluate(STJSTestDriverRunner.java:74)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
        at org.stjs.testing.driver.STJSTestDriverRunner.run(STJSTestDriverRunner.java:46)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2(ReflectionUtils.java:208)
        at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:159)
        at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:87)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:95)

现在我知道这种VerifyError通常是由尚未正确解决的依赖冲突引起的。在这种情况下,似乎类路径上的protobuf库的版本不是预期的版本。

有关此异常的有趣之处在于它与我之前看到的所有内容不同,它不会发生在被测应用程序的类路径中,但它发生在Maven自己的类路径中。我相信我在两个构建插件之间存在依赖冲突。每个插件可能都需要不同版本的protobuf。

我知道如何在项目类路径中调试这种事情,但如何在构建工具自己的类路径中调试此问题?

0 个答案:

没有答案