早上新建一个web项目,没想到一敲命令创建就失败了,真是出师不利。各种折腾无果,当然我也可以用eclipse直接创建的,就是想搞清楚状况。刚刚才发现问题原因,这个结果我也是醉了,太坑爹了。
问题现象:
- E:\workspace>mvn archetype:generate -DarchetypeCatalog=internal -DgroupId=com.wulf.memcache -DartifactId=memcache-view -DarchetypeArtifactId=maven-archetype-webapp
- [INFO] Scanning for projects...
- [INFO]
- [INFO] ------------------------------------------------------------------------
- [INFO] Building Maven Stub Project (No POM) 1
- [INFO] ------------------------------------------------------------------------
- [INFO]
- [INFO] >>> maven-archetype-plugin:3.0.1:generate (default-cli) > generate-sources @ standalone-pom >>>
- [INFO]
- [INFO] <<< maven-archetype-plugin:3.0.1:generate (default-cli) < generate-sources @ standalone-pom <<<
- [INFO]
- [INFO] --- maven-archetype-plugin:3.0.1:generate (default-cli) @ standalone-pom ---
- [WARNING] Error initializing: org.codehaus.plexus.velocity.DefaultVelocityComponent@6443b128
- java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
- at org.apache.velocity.runtime.resource.ResourceManagerImpl.initialize(ResourceManagerImpl.java:161)
- at org.apache.velocity.runtime.RuntimeInstance.initializeResourceManager(RuntimeInstance.java:730)
- at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:263)
- at org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:93)
- at org.codehaus.plexus.velocity.DefaultVelocityComponent.initialize(DefaultVelocityComponent.java:95)
- at org.eclipse.sisu.plexus.PlexusLifecycleManager.initialize(PlexusLifecycleManager.java:303)
- at org.eclipse.sisu.plexus.PlexusLifecycleManager.activate(PlexusLifecycleManager.java:207)
- at org.eclipse.sisu.bean.BeanScheduler$Pending.activate(BeanScheduler.java:156)
- at org.eclipse.sisu.bean.BeanScheduler$Activator.onProvision(BeanScheduler.java:185)
- 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:63)
- at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:45)
- at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1016)
- at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
- at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1012)
- at org.eclipse.sisu.inject.Guice4$1.get(Guice4.java:162)
- 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:517)
- at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:121)
- at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
- 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:863)
- at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
- at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
- 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.ClassNotFoundException: org.apache.commons.lang.StringUtils
- 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)
- ... 44 more
- [INFO] ------------------------------------------------------------------------
- [INFO] BUILD FAILURE
- [INFO] ------------------------------------------------------------------------
- [INFO] Total time: 11.561 s
- [INFO] Finished at: 2017-11-21T10:13:13+08:00
- [INFO] Final Memory: 10M/93M
- [INFO] ------------------------------------------------------------------------
- [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
- [ERROR] -----------------------------------------------------
- [ERROR] realm = plugin>org.apache.maven.plugins:maven-archetype-plugin:3.0.1
- [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
- [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
- [ERROR] urls[1] = file:/E:/Users/wulf/.m2/repository/org/apache/maven/archetype/archetype-catalog/3.0.1/archetype-catalog-3.0.1.jar
- [ERROR] urls[2] = file:/E:/Users/wulf/.m2/repository/org/apache/maven/archetype/archetype-descriptor/3.0.1/archetype-descriptor-3.0.1.jar
- [ERROR] urls[3] = file:/E:/Users/wulf/.m2/repository/org/apache/maven/archetype/archetype-common/3.0.1/archetype-common-3.0.1.jar
- [ERROR] urls[4] = file:/E:/Users/wulf/.m2/repository/net/sourceforge/jchardet/jchardet/1.0/jchardet-1.0.jar
- [ERROR] urls[5] = file:/E:/Users/wulf/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.6/plexus-component-annotations-1.6.jar
- [ERROR] urls[6] = file:/E:/Users/wulf/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar
- [ERROR] urls[7] = file:/E:/Users/wulf/.m2/repository/jdom/jdom/1.0/jdom-1.0.jar
- [ERROR] urls[8] = file:/E:/Users/wulf/.m2/repository/commons-io/commons-io/2.2/commons-io-2.2.jar
- [ERROR] urls[9] = file:/E:/Users/wulf/.m2/repository/org/codehaus/plexus/plexus-velocity/1.1.8/plexus-velocity-1.1.8.jar
- [ERROR] urls[10] = file:/E:/Users/wulf/.m2/repository/org/apache/velocity/velocity/1.7/velocity-1.7.jar
- [ERROR] urls[11] = file:/E:/Users/wulf/.m2/repository/org/codehaus/groovy/groovy/1.8.3/groovy-1.8.3.jar
- [ERROR] urls[12] = file:/E:/Users/wulf/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar
- [ERROR] urls[13] = file:/E:/Users/wulf/.m2/repository/asm/asm/3.2/asm-3.2.jar
- [ERROR] urls[14] = file:/E:/Users/wulf/.m2/repository/asm/asm-commons/3.2/asm-commons-3.2.jar
- [ERROR] urls[15] = file:/E:/Users/wulf/.m2/repository/asm/asm-util/3.2/asm-util-3.2.jar
- [ERROR] urls[16] = file:/E:/Users/wulf/.m2/repository/asm/asm-analysis/3.2/asm-analysis-3.2.jar
- [ERROR] urls[17] = file:/E:/Users/wulf/.m2/repository/asm/asm-tree/3.2/asm-tree-3.2.jar
- [ERROR] urls[18] = file:/E:/Users/wulf/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.21/plexus-utils-3.0.21.jar
- [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
- [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
- [ERROR] urls[21] = file:/E:/Users/wulf/.m2/repository/org/sonatype/sisu/sisu-guice/2.1.7/sisu-guice-2.1.7-noaop.jar
- [ERROR] urls[22] = file:/E:/Users/wulf/.m2/repository/org/sonatype/aether/aether-util/1.7/aether-util-1.7.jar
- [ERROR] urls[23] = file:/E:/Users/wulf/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14.jar
- [ERROR] urls[24] = file:/E:/Users/wulf/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar
- [ERROR] urls[25] = file:/E:/Users/wulf/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
- [ERROR] urls[26] = file:/E:/Users/wulf/.m2/repository/org/apache/maven/shared/maven-invoker/2.2/maven-invoker-2.2.jar
- [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
- [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
- [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
- [ERROR] urls[30] = file:/E:/Users/wulf/.m2/repository/com/google/code/findbugs/jsr305/2.0.1/jsr305-2.0.1.jar
- [ERROR] urls[31] = file:/E:/Users/wulf/.m2/repository/commons-codec/commons-codec/1.6/commons-codec-1.6.jar
- [ERROR] urls[32] = file:/E:/Users/wulf/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar
- [ERROR] urls[33] = file:/E:/Users/wulf/.m2/repository/org/apache/maven/shared/maven-script-interpreter/1.0/maven-script-interpreter-1.0.jar
- [ERROR] urls[34] = file:/E:/Users/wulf/.m2/repository/org/beanshell/bsh/2.0b4/bsh-2.0b4.jar
- [ERROR] urls[35] = file:/E:/Users/wulf/.m2/repository/org/apache/ant/ant/1.8.1/ant-1.8.1.jar
- [ERROR] Number of foreign imports: 1
- [ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
- [ERROR]
- [ERROR] -----------------------------------------------------: org.apache.commons.lang.StringUtils
- [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
- [WARNING] Problem disposing: org.codehaus.plexus.components.interactivity.DefaultInputHandler@5d39f2d8
- java.lang.NullPointerException
- at org.codehaus.plexus.components.interactivity.DefaultInputHandler.dispose(DefaultInputHandler.java:70)
- at org.eclipse.sisu.plexus.PlexusLifecycleManager.dispose(PlexusLifecycleManager.java:368)
- at org.eclipse.sisu.plexus.PlexusLifecycleManager.unmanage(PlexusLifecycleManager.java:173)
- at org.codehaus.plexus.DefaultPlexusContainer.dispose(DefaultPlexusContainer.java:590)
- at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:315)
- at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
- 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)
- [WARNING] Problem disposing: org.codehaus.plexus.components.interactivity.DefaultOutputHandler@55ea2d70
- java.lang.NullPointerException
- at org.codehaus.plexus.components.interactivity.DefaultOutputHandler.dispose(DefaultOutputHandler.java:53)
- at org.eclipse.sisu.plexus.PlexusLifecycleManager.dispose(PlexusLifecycleManager.java:368)
- at org.eclipse.sisu.plexus.PlexusLifecycleManager.unmanage(PlexusLifecycleManager.java:173)
- at org.codehaus.plexus.DefaultPlexusContainer.dispose(DefaultPlexusContainer.java:590)
- at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:315)
- at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
- 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)
问题原因:从报错日志看是少类了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包,但还是报错依旧:
- E:\workspace>mvn archetype:generate
- [INFO] Scanning for projects...
- [INFO]
- [INFO] ------------------------------------------------------------------------
- [INFO] Building Maven Stub Project (No POM) 1
- [INFO] ------------------------------------------------------------------------
- [INFO]
- [INFO] >>> maven-archetype-plugin:3.0.1:generate (default-cli) > generate-sources @ standalone-pom >>>
- [INFO]
- [INFO] <<< maven-archetype-plugin:3.0.1:generate (default-cli) < generate-sources @ standalone-pom <<<
- [INFO]
- [INFO] --- maven-archetype-plugin:3.0.1:generate (default-cli) @ standalone-pom ---
- [WARNING] Error initializing: org.codehaus.plexus.velocity.DefaultVelocityComponent@baf1bb3
- java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
- at org.apache.velocity.runtime.resource.ResourceManagerImpl.initialize(ResourceManagerImpl.java:161)
- at org.apache.velocity.runtime.RuntimeInstance.initializeResourceManager(RuntimeInstance.java:730)
- at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:263)
- at org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:93)
- at org.codehaus.plexus.velocity.DefaultVelocityComponent.initialize(DefaultVelocityComponent.java:95)
- at org.eclipse.sisu.plexus.PlexusLifecycleManager.initialize(PlexusLifecycleManager.java:303)
- at org.eclipse.sisu.plexus.PlexusLifecycleManager.activate(PlexusLifecycleManager.java:207)
- at org.eclipse.sisu.bean.BeanScheduler$Pending.activate(BeanScheduler.java:156)
- at org.eclipse.sisu.bean.BeanScheduler$Activator.onProvision(BeanScheduler.java:185)
- 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:63)
- at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:45)
- at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1016)
- at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
- at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1012)
- at org.ecli