maven打包出错 Error injecting constructor, java.lang.NoClassDefFoundError

记录一个maven编译遇到的问题

D:\AAA\工作\公司\c3\hdp_baisc>mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building uwin_conference 0.0.1-hdp
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.caucho-uwin:hessian:jar:4.0.7 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.json.simple:json_simple:jar:1.1 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for baidu.ueditor:json:jar:1.1.1 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for baidu.ueditor:ueditor:jar:1.1.2 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for fakepath:ehcache:jar:2.8.0 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for fakepath:ehcache-spring-annotations:jar:1.2.0 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ uwin_conference ---
[INFO] Deleting D:\AAA\工作\公司\c3\hdp_baisc\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ uwin_conference ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\AAA\工作\公司\c3\hdp_baisc\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ uwin_conference ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ uwin_conference ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\AAA\工作\公司\c3\hdp_baisc\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ uwin_conference ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ uwin_conference ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-war-plugin:2.6:war (default-war) @ uwin_conference ---
[WARNING] The POM for com.thoughtworks.xstream:xstream:jar:1.4.4 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] Error injecting: org.apache.maven.plugin.war.WarMojo
com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) Error injecting constructor, java.lang.NoClassDefFoundError: com/thoughtworks/xstream/io/HierarchicalStreamDriver
  at org.apache.maven.plugin.war.WarMojo.(Unknown Source)
  while locating org.apache.maven.plugin.war.WarMojo

1 error
        at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1018)
        at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1044)
        at org.eclipse.sisu.space.AbstractDeferredClass.get(AbstractDeferredClass.java:48)
        at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:86)
        at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:54)
        at com.google.inject.internal.ProviderInternalFactory$1.call(ProviderInternalFactory.java:70)
        at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:115)
        at org.eclipse.sisu.bean.BeanScheduler$Activator.onProvision(BeanScheduler.java:176)
        at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:126)
        at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:68)
        at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:68)
        at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:46)
        at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1009)
        at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1059)
        at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1005)
        at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:36)
        at org.eclipse.sisu.inject.LazyBeanEntry.getValue(LazyBeanEntry.java:81)
        at org.eclipse.sisu.plexus.LazyPlexusBean.getValue(LazyPlexusBean.java:51)
        at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:263)
        at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:255)
        at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:546)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:121)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
        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:498)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: java.lang.NoClassDefFoundError: com/thoughtworks/xstream/io/HierarchicalStreamDriver
        at org.apache.maven.plugin.war.AbstractWarMojo.(AbstractWarMojo.java:329)
        at org.apache.maven.plugin.war.WarMojo.(WarMojo.java:54)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:86)
        at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:108)
        at com.google.inject.internal.ConstructorInjector.access$000(ConstructorInjector.java:32)
        at com.google.inject.internal.ConstructorInjector$1.call(ConstructorInjector.java:92)
        at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:115)
        at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:133)
        at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:68)
        at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:90)
        at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:269)
        at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1009)
        at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1066)
        at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1005)
        ... 42 more
Caused by: java.lang.ClassNotFoundException: com.thoughtworks.xstream.io.HierarchicalStreamDriver
        at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
        ... 60 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.427 s
[INFO] Finished at: 2019-03-20T09:24:37+08:00
[INFO] Final Memory: 15M/187M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.6:war (default-war) on project uwin_conference: Execution default-war of goal org.apache.maven.plugins:maven-war-plugin:2.6:war failed: Unable to load the mojo 'war' in the plugin 'org.apache.maven.plugins:maven-war-plugin:2.6'. A required class is missing: com/thoughtworks/xstream/io/HierarchicalStreamDriver
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.apache.maven.plugins:maven-war-plugin:2.6
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/F:/m2repo/org/apache/maven/plugins/maven-war-plugin/2.6/maven-war-plugin-2.6.jar
[ERROR] urls[1] = file:/F:/m2repo/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar
[ERROR] urls[2] = file:/F:/m2repo/junit/junit/3.8.1/junit-3.8.1.jar
[ERROR] urls[3] = file:/F:/m2repo/org/slf4j/slf4j-jdk14/1.5.6/slf4j-jdk14-1.5.6.jar
[ERROR] urls[4] = file:/F:/m2repo/org/slf4j/jcl-over-slf4j/1.5.6/jcl-over-slf4j-1.5.6.jar
[ERROR] urls[5] = file:/F:/m2repo/org/apache/maven/reporting/maven-reporting-api/2.2.1/maven-reporting-api-2.2.1.jar
[ERROR] urls[6] = file:/F:/m2repo/org/apache/maven/doxia/doxia-sink-api/1.1/doxia-sink-api-1.1.jar
[ERROR] urls[7] = file:/F:/m2repo/org/apache/maven/doxia/doxia-logging-api/1.1/doxia-logging-api-1.1.jar
[ERROR] urls[8] = file:/F:/m2repo/commons-cli/commons-cli/1.2/commons-cli-1.2.jar
[ERROR] urls[9] = file:/F:/m2repo/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-4/plexus-interactivity-api-1.0-alpha-4.jar
[ERROR] urls[10] = file:/F:/m2repo/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar
[ERROR] urls[11] = file:/F:/m2repo/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[12] = file:/F:/m2repo/org/apache/maven/maven-archiver/2.6/maven-archiver-2.6.jar
[ERROR] urls[13] = file:/F:/m2repo/org/apache/maven/shared/maven-shared-utils/0.7/maven-shared-utils-0.7.jar
[ERROR] urls[14] = file:/F:/m2repo/com/google/code/findbugs/jsr305/2.0.1/jsr305-2.0.1.jar
[ERROR] urls[15] = file:/F:/m2repo/org/codehaus/plexus/plexus-io/2.4.1/plexus-io-2.4.1.jar
[ERROR] urls[16] = file:/F:/m2repo/commons-io/commons-io/2.2/commons-io-2.2.jar
[ERROR] urls[17] = file:/F:/m2repo/org/codehaus/plexus/plexus-archiver/2.9/plexus-archiver-2.9.jar
[ERROR] urls[18] = file:/F:/m2repo/org/apache/commons/commons-compress/1.9/commons-compress-1.9.jar
[ERROR] urls[19] = file:/F:/m2repo/org/codehaus/plexus/plexus-interpolation/1.21/plexus-interpolation-1.21.jar
[ERROR] urls[20] = file:/F:/m2repo/com/thoughtworks/xstream/xstream/1.4.4/xstream-1.4.4.jar
[ERROR] urls[21] = file:/F:/m2repo/org/codehaus/plexus/plexus-utils/3.0.20/plexus-utils-3.0.20.jar
[ERROR] urls[22] = file:/F:/m2repo/org/apache/maven/shared/maven-filtering/1.3/maven-filtering-1.3.jar
[ERROR] urls[23] = file:/F:/m2repo/org/sonatype/plexus/plexus-build-api/0.0.4/plexus-build-api-0.0.4.jar
[ERROR] urls[24] = file:/F:/m2repo/org/apache/maven/shared/maven-mapping/1.0/maven-mapping-1.0.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------: com.thoughtworks.xstream.io.HierarchicalStreamDriver
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException

看到这么多英文,有没有一脸茫然。如何成为码农界的一个高级玩家,在众人之中脱颖而出,首先你得英文好,一切解决bug的答案尽在这一片英文之中,请仔细阅读,关键的部分在下面,大意是提示我们说这个依赖jar包是无效的,有可能是因为网络或其他诸多原因导致maven下载的jar包破损,解决的办法就是把相应的jar包删了,让maven重新编译下载即可。

The POM for com.thoughtworks.xstream:xstream:jar:1.4.4 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details

比如,我的有问题的jar包,提示说是com.thoughtworks.xstream:xstream:jar:1.4.4,那么就去maven仓库下的com/thoughtworks/xstream文件夹下,把文件都删了,然后在mvn install即可,像我下面就是成功了

D:\AAA\工作\公司\c3\hdp_baisc>mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building uwin_conference 0.0.1-hdp
.........................
.........................
[INFO] Installing D:\AAA\工作\公司\c3\hdp_baisc\pom.xml to F:\m2repo\com\uwin\uwin_conference\0.0.1-hdp\uwin_conference-0.0.1-hdp.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:05 min
[INFO] Finished at: 2019-03-20T09:29:29+08:00
[INFO] Final Memory: 17M/194M
[INFO] ------------------------------------------------------------------------

我的GitHub
QQ:2541692705
邮箱:[email protected]
微信扫一扫关注我,没事可以玩玩小游戏
maven打包出错 Error injecting constructor, java.lang.NoClassDefFoundError_第1张图片


我想去流浪,我想去读书,若有机会,江湖再见
扫一扫,领取红包,就当奖励你我付出的努力
maven打包出错 Error injecting constructor, java.lang.NoClassDefFoundError_第2张图片

你可能感兴趣的:(bug)