当前位置:   article > 正文

maven命令行创建web项目报错:java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils...

import from realm classrealm

  早上新建一个web项目,没想到一敲命令创建就失败了,真是出师不利。各种折腾无果,当然我也可以用eclipse直接创建的,就是想搞清楚状况。刚刚才发现问题原因,这个结果我也是醉了,太坑爹了。

  问题现象:

  1. E:\workspace>mvn archetype:generate -DarchetypeCatalog=internal -DgroupId=com.wulf.memcache -DartifactId=memcache-view -DarchetypeArtifactId=maven-archetype-webapp
  2. [INFO] Scanning for projects...
  3. [INFO]
  4. [INFO] ------------------------------------------------------------------------
  5. [INFO] Building Maven Stub Project (No POM) 1
  6. [INFO] ------------------------------------------------------------------------
  7. [INFO]
  8. [INFO] >>> maven-archetype-plugin:3.0.1:generate (default-cli) > generate-sources @ standalone-pom >>>
  9. [INFO]
  10. [INFO] <<< maven-archetype-plugin:3.0.1:generate (default-cli) < generate-sources @ standalone-pom <<<
  11. [INFO]
  12. [INFO] --- maven-archetype-plugin:3.0.1:generate (default-cli) @ standalone-pom ---
  13. [WARNING] Error initializing: org.codehaus.plexus.velocity.DefaultVelocityComponent@6443b128
  14. java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
  15. at org.apache.velocity.runtime.resource.ResourceManagerImpl.initialize(ResourceManagerImpl.java:161)
  16. at org.apache.velocity.runtime.RuntimeInstance.initializeResourceManager(RuntimeInstance.java:730)
  17. at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:263)
  18. at org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:93)
  19. at org.codehaus.plexus.velocity.DefaultVelocityComponent.initialize(DefaultVelocityComponent.java:95)
  20. at org.eclipse.sisu.plexus.PlexusLifecycleManager.initialize(PlexusLifecycleManager.java:303)
  21. at org.eclipse.sisu.plexus.PlexusLifecycleManager.activate(PlexusLifecycleManager.java:207)
  22. at org.eclipse.sisu.bean.BeanScheduler$Pending.activate(BeanScheduler.java:156)
  23. at org.eclipse.sisu.bean.BeanScheduler$Activator.onProvision(BeanScheduler.java:185)
  24. at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:126)
  25. at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:68)
  26. at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:63)
  27. at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:45)
  28. at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1016)
  29. at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
  30. at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1012)
  31. at org.eclipse.sisu.inject.Guice4$1.get(Guice4.java:162)
  32. at org.eclipse.sisu.inject.LazyBeanEntry.getValue(LazyBeanEntry.java:81)
  33. at org.eclipse.sisu.plexus.LazyPlexusBean.getValue(LazyPlexusBean.java:51)
  34. at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:263)
  35. at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:255)
  36. at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:517)
  37. at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:121)
  38. at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
  39. at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
  40. at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
  41. at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
  42. at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
  43. at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
  44. at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
  45. at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
  46. at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
  47. at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
  48. at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
  49. at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
  50. at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
  51. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  52. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  53. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  54. at java.lang.reflect.Method.invoke(Method.java:498)
  55. at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
  56. at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
  57. at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
  58. at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
  59. Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils
  60. at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
  61. at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
  62. at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
  63. at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
  64. ... 44 more
  65. [INFO] ------------------------------------------------------------------------
  66. [INFO] BUILD FAILURE
  67. [INFO] ------------------------------------------------------------------------
  68. [INFO] Total time: 11.561 s
  69. [INFO] Finished at: 2017-11-21T10:13:13+08:00
  70. [INFO] Final Memory: 10M/93M
  71. [INFO] ------------------------------------------------------------------------
  72. [ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate (default-cli) on project standalone-pom: Execution default-cli of goal org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate failed: A required class was missing while executing org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate: org/apache/commons/lang/StringUtils
  73. [ERROR] -----------------------------------------------------
  74. [ERROR] realm = plugin>org.apache.maven.plugins:maven-archetype-plugin:3.0.1
  75. [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
  76. [ERROR] urls[0] = file:/E:/Users/wulf/.m2/repository/org/apache/maven/plugins/maven-archetype-plugin/3.0.1/maven-archetype-plugin-3.0.1.jar
  77. [ERROR] urls[1] = file:/E:/Users/wulf/.m2/repository/org/apache/maven/archetype/archetype-catalog/3.0.1/archetype-catalog-3.0.1.jar
  78. [ERROR] urls[2] = file:/E:/Users/wulf/.m2/repository/org/apache/maven/archetype/archetype-descriptor/3.0.1/archetype-descriptor-3.0.1.jar
  79. [ERROR] urls[3] = file:/E:/Users/wulf/.m2/repository/org/apache/maven/archetype/archetype-common/3.0.1/archetype-common-3.0.1.jar
  80. [ERROR] urls[4] = file:/E:/Users/wulf/.m2/repository/net/sourceforge/jchardet/jchardet/1.0/jchardet-1.0.jar
  81. [ERROR] urls[5] = file:/E:/Users/wulf/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.6/plexus-component-annotations-1.6.jar
  82. [ERROR] urls[6] = file:/E:/Users/wulf/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar
  83. [ERROR] urls[7] = file:/E:/Users/wulf/.m2/repository/jdom/jdom/1.0/jdom-1.0.jar
  84. [ERROR] urls[8] = file:/E:/Users/wulf/.m2/repository/commons-io/commons-io/2.2/commons-io-2.2.jar
  85. [ERROR] urls[9] = file:/E:/Users/wulf/.m2/repository/org/codehaus/plexus/plexus-velocity/1.1.8/plexus-velocity-1.1.8.jar
  86. [ERROR] urls[10] = file:/E:/Users/wulf/.m2/repository/org/apache/velocity/velocity/1.7/velocity-1.7.jar
  87. [ERROR] urls[11] = file:/E:/Users/wulf/.m2/repository/org/codehaus/groovy/groovy/1.8.3/groovy-1.8.3.jar
  88. [ERROR] urls[12] = file:/E:/Users/wulf/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar
  89. [ERROR] urls[13] = file:/E:/Users/wulf/.m2/repository/asm/asm/3.2/asm-3.2.jar
  90. [ERROR] urls[14] = file:/E:/Users/wulf/.m2/repository/asm/asm-commons/3.2/asm-commons-3.2.jar
  91. [ERROR] urls[15] = file:/E:/Users/wulf/.m2/repository/asm/asm-util/3.2/asm-util-3.2.jar
  92. [ERROR] urls[16] = file:/E:/Users/wulf/.m2/repository/asm/asm-analysis/3.2/asm-analysis-3.2.jar
  93. [ERROR] urls[17] = file:/E:/Users/wulf/.m2/repository/asm/asm-tree/3.2/asm-tree-3.2.jar
  94. [ERROR] urls[18] = file:/E:/Users/wulf/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.21/plexus-utils-3.0.21.jar
  95. [ERROR] urls[19] = file:/E:/Users/wulf/.m2/repository/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-6/plexus-interactivity-api-1.0-alpha-6.jar
  96. [ERROR] urls[20] = file:/E:/Users/wulf/.m2/repository/org/sonatype/sisu/sisu-inject-bean/1.4.2/sisu-inject-bean-1.4.2.jar
  97. [ERROR] urls[21] = file:/E:/Users/wulf/.m2/repository/org/sonatype/sisu/sisu-guice/2.1.7/sisu-guice-2.1.7-noaop.jar
  98. [ERROR] urls[22] = file:/E:/Users/wulf/.m2/repository/org/sonatype/aether/aether-util/1.7/aether-util-1.7.jar
  99. [ERROR] urls[23] = file:/E:/Users/wulf/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14.jar
  100. [ERROR] urls[24] = file:/E:/Users/wulf/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar
  101. [ERROR] urls[25] = file:/E:/Users/wulf/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
  102. [ERROR] urls[26] = file:/E:/Users/wulf/.m2/repository/org/apache/maven/shared/maven-invoker/2.2/maven-invoker-2.2.jar
  103. [ERROR] urls[27] = file:/E:/Users/wulf/.m2/repository/org/apache/maven/shared/maven-artifact-transfer/0.9.0/maven-artifact-transfer-0.9.0.jar
  104. [ERROR] urls[28] = file:/E:/Users/wulf/.m2/repository/org/apache/maven/shared/maven-common-artifact-filters/3.0.0/maven-common-artifact-filters-3.0.0.jar
  105. [ERROR] urls[29] = file:/E:/Users/wulf/.m2/repository/org/apache/maven/shared/maven-shared-utils/3.0.0/maven-shared-utils-3.0.0.jar
  106. [ERROR] urls[30] = file:/E:/Users/wulf/.m2/repository/com/google/code/findbugs/jsr305/2.0.1/jsr305-2.0.1.jar
  107. [ERROR] urls[31] = file:/E:/Users/wulf/.m2/repository/commons-codec/commons-codec/1.6/commons-codec-1.6.jar
  108. [ERROR] urls[32] = file:/E:/Users/wulf/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar
  109. [ERROR] urls[33] = file:/E:/Users/wulf/.m2/repository/org/apache/maven/shared/maven-script-interpreter/1.0/maven-script-interpreter-1.0.jar
  110. [ERROR] urls[34] = file:/E:/Users/wulf/.m2/repository/org/beanshell/bsh/2.0b4/bsh-2.0b4.jar
  111. [ERROR] urls[35] = file:/E:/Users/wulf/.m2/repository/org/apache/ant/ant/1.8.1/ant-1.8.1.jar
  112. [ERROR] Number of foreign imports: 1
  113. [ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
  114. [ERROR]
  115. [ERROR] -----------------------------------------------------: org.apache.commons.lang.StringUtils
  116. [ERROR] -> [Help 1]
  117. [ERROR]
  118. [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
  119. [ERROR] Re-run Maven using the -X switch to enable full debug logging.
  120. [ERROR]
  121. [ERROR] For more information about the errors and possible solutions, please read the following articles:
  122. [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException
  123. [WARNING] Problem disposing: org.codehaus.plexus.components.interactivity.DefaultInputHandler@5d39f2d8
  124. java.lang.NullPointerException
  125. at org.codehaus.plexus.components.interactivity.DefaultInputHandler.dispose(DefaultInputHandler.java:70)
  126. at org.eclipse.sisu.plexus.PlexusLifecycleManager.dispose(PlexusLifecycleManager.java:368)
  127. at org.eclipse.sisu.plexus.PlexusLifecycleManager.unmanage(PlexusLifecycleManager.java:173)
  128. at org.codehaus.plexus.DefaultPlexusContainer.dispose(DefaultPlexusContainer.java:590)
  129. at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:315)
  130. at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
  131. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  132. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  133. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  134. at java.lang.reflect.Method.invoke(Method.java:498)
  135. at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
  136. at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
  137. at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
  138. at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
  139. [WARNING] Problem disposing: org.codehaus.plexus.components.interactivity.DefaultOutputHandler@55ea2d70
  140. java.lang.NullPointerException
  141. at org.codehaus.plexus.components.interactivity.DefaultOutputHandler.dispose(DefaultOutputHandler.java:53)
  142. at org.eclipse.sisu.plexus.PlexusLifecycleManager.dispose(PlexusLifecycleManager.java:368)
  143. at org.eclipse.sisu.plexus.PlexusLifecycleManager.unmanage(PlexusLifecycleManager.java:173)
  144. at org.codehaus.plexus.DefaultPlexusContainer.dispose(DefaultPlexusContainer.java:590)
  145. at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:315)
  146. at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
  147. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  148. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  149. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  150. at java.lang.reflect.Method.invoke(Method.java:498)
  151. at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
  152. at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
  153. at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
  154. at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

  问题原因:从报错日志看是少类了org/apache/commons/lang/StringUtils,我到本地仓库去看是有commons-lang这个jar包的。换了其他几个mvn archetype:generate命令参数都不行,可以确定跟命令本身无关,怀疑是jar包问题。删掉commons-lang这个jar包,直接敲mvn archetype:generate回车,没发现重现下包,而报错依旧。既然不是StringUtils引起的,那么会不会是ResourceManagerImpl搞的鬼?接着删velocity这个jar包,接着敲mvn archetype:generate,这次从私服上重新下载了该jar包,但还是报错依旧:

  1. E:\workspace>mvn archetype:generate
  2. [INFO] Scanning for projects...
  3. [INFO]
  4. [INFO] ------------------------------------------------------------------------
  5. [INFO] Building Maven Stub Project (No POM) 1
  6. [INFO] ------------------------------------------------------------------------
  7. [INFO]
  8. [INFO] >>> maven-archetype-plugin:3.0.1:generate (default-cli) > generate-sources @ standalone-pom >>>
  9. [INFO]
  10. [INFO] <<< maven-archetype-plugin:3.0.1:generate (default-cli) < generate-sources @ standalone-pom <<<
  11. [INFO]
  12. [INFO] --- maven-archetype-plugin:3.0.1:generate (default-cli) @ standalone-pom ---
  13. [WARNING] Error initializing: org.codehaus.plexus.velocity.DefaultVelocityComponent@baf1bb3
  14. java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
  15. at org.apache.velocity.runtime.resource.ResourceManagerImpl.initialize(ResourceManagerImpl.java:161)
  16. at org.apache.velocity.runtime.RuntimeInstance.initializeResourceManager(RuntimeInstance.java:730)
  17. at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:263)
  18. at org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:93)
  19. at org.codehaus.plexus.velocity.DefaultVelocityComponent.initialize(DefaultVelocityComponent.java:95)
  20. at org.eclipse.sisu.plexus.PlexusLifecycleManager.initialize(PlexusLifecycleManager.java:303)
  21. at org.eclipse.sisu.plexus.PlexusLifecycleManager.activate(PlexusLifecycleManager.java:207)
  22. at org.eclipse.sisu.bean.BeanScheduler$Pending.activate(BeanScheduler.java:156)
  23. at org.eclipse.sisu.bean.BeanScheduler$Activator.onProvision(BeanScheduler.java:185)
  24. at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:126)
  25. at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:68)
  26. at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:63)
  27. at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:45)
  28. at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1016)
  29. at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
  30. at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1012)
  31. at org.ecli
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/天景科技苑/article/detail/1021301
推荐阅读
相关标签
  

闽ICP备14008679号