简体   繁体   中英

Maven raises java.lang.NoSuchMethodError org.codehaus.plexus.util.xml.pull.MXParser

I'm trying to install and use Maven on a Mac OS X 10.8.5,

$java -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)

and

$env
PATH=/Users/dev/.bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/local/sbin:/Users/dev/.rbenv/shims:/Users/dev/.rbenv/shims:/Users/dev/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/dev/.rvm/bin:/Users/dev/bin/apache-maven-3.2.1/bin
TMPDIR=/var/folders/ds/y8xcz0v92c31y9618cvfd6s80000gn/T/
SHELL=/bin/zsh
HOME=/Users/dev
USER=dev
LOGNAME=dev
SSH_AUTH_SOCK=/tmp/launch-w886dP/Listeners
Apple_Ubiquity_Message=/tmp/launch-kJun90/Apple_Ubiquity_Message
Apple_PubSub_Socket_Render=/tmp/launch-NRuj9p/Render
DISPLAY=/tmp/launch-PBxe8n/org.macosforge.xquartz:0
COMMAND_MODE=unix2003
__CF_USER_TEXT_ENCODING=0x1F5:0:7
TERM_PROGRAM=Apple_Terminal
TERM_PROGRAM_VERSION=309
TERM_SESSION_ID=0FFAAC0D-A437-4283-B502-24F2A26FC7D9
LANG=sv_SE.UTF-8
TERM=xterm-256color
SHLVL=1
PWD=/Users/dev
OLDPWD=/Users/dev
VISUAL=vim
EDITOR=vim
PS1=$(git_prompt_info)[${SSH_CONNECTION+"%{$fg_bold[green]%}%n@%m:"}%{$fg_bold[blue]%}%~%{$reset_color%}] 
HISTSIZE=4096
EYRC=./.eyrc
dirstacksize=5
CLICOLOR=1
_=/usr/bin/env

I get the following output when I run the mvn command as follows:

$mvn
---------------------------------------------------
constituent[0]: file:/Users/dev/bin/apache-maven-3.2.1/lib/aether-api-0.9.0.M2.jar
constituent[1]: file:/Users/dev/bin/apache-maven-3.2.1/lib/aether-connector-wagon-0.9.0.M2.jar
constituent[2]: file:/Users/dev/bin/apache-maven-3.2.1/lib/aether-impl-0.9.0.M2.jar
constituent[3]: file:/Users/dev/bin/apache-maven-3.2.1/lib/aether-spi-0.9.0.M2.jar
constituent[4]: file:/Users/dev/bin/apache-maven-3.2.1/lib/aether-util-0.9.0.M2.jar
constituent[5]: file:/Users/dev/bin/apache-maven-3.2.1/lib/aopalliance-1.0.jar
constituent[6]: file:/Users/dev/bin/apache-maven-3.2.1/lib/cdi-api-1.0.jar
constituent[7]: file:/Users/dev/bin/apache-maven-3.2.1/lib/commons-cli-1.2.jar
constituent[8]: file:/Users/dev/bin/apache-maven-3.2.1/lib/commons-io-2.2.jar
constituent[9]: file:/Users/dev/bin/apache-maven-3.2.1/lib/commons-lang-2.6.jar
constituent[10]: file:/Users/dev/bin/apache-maven-3.2.1/lib/guava-14.0.1.jar
constituent[11]: file:/Users/dev/bin/apache-maven-3.2.1/lib/javax.inject-1.jar
constituent[12]: file:/Users/dev/bin/apache-maven-3.2.1/lib/jsoup-1.7.2.jar
constituent[13]: file:/Users/dev/bin/apache-maven-3.2.1/lib/jsr250-api-1.0.jar
constituent[14]: file:/Users/dev/bin/apache-maven-3.2.1/lib/maven-aether-provider-3.2.1.jar
constituent[15]: file:/Users/dev/bin/apache-maven-3.2.1/lib/maven-artifact-3.2.1.jar
constituent[16]: file:/Users/dev/bin/apache-maven-3.2.1/lib/maven-compat-3.2.1.jar
constituent[17]: file:/Users/dev/bin/apache-maven-3.2.1/lib/maven-core-3.2.1.jar
constituent[18]: file:/Users/dev/bin/apache-maven-3.2.1/lib/maven-embedder-3.2.1.jar
constituent[19]: file:/Users/dev/bin/apache-maven-3.2.1/lib/maven-model-3.2.1.jar
constituent[20]: file:/Users/dev/bin/apache-maven-3.2.1/lib/maven-model-builder-3.2.1.jar
constituent[21]: file:/Users/dev/bin/apache-maven-3.2.1/lib/maven-plugin-api-3.2.1.jar
constituent[22]: file:/Users/dev/bin/apache-maven-3.2.1/lib/maven-repository-metadata-3.2.1.jar
constituent[23]: file:/Users/dev/bin/apache-maven-3.2.1/lib/maven-settings-3.2.1.jar
constituent[24]: file:/Users/dev/bin/apache-maven-3.2.1/lib/maven-settings-builder-3.2.1.jar
constituent[25]: file:/Users/dev/bin/apache-maven-3.2.1/lib/org.eclipse.sisu.inject-0.0.0.M5.jar
constituent[26]: file:/Users/dev/bin/apache-maven-3.2.1/lib/org.eclipse.sisu.plexus-0.0.0.M5.jar
constituent[27]: file:/Users/dev/bin/apache-maven-3.2.1/lib/plexus-cipher-1.7.jar
constituent[28]: file:/Users/dev/bin/apache-maven-3.2.1/lib/plexus-component-annotations-1.5.5.jar
constituent[29]: file:/Users/dev/bin/apache-maven-3.2.1/lib/plexus-interpolation-1.19.jar
constituent[30]: file:/Users/dev/bin/apache-maven-3.2.1/lib/plexus-sec-dispatcher-1.3.jar
constituent[31]: file:/Users/dev/bin/apache-maven-3.2.1/lib/plexus-utils-3.0.17.jar
constituent[32]: file:/Users/dev/bin/apache-maven-3.2.1/lib/sisu-guice-3.1.3-no_aop.jar
constituent[33]: file:/Users/dev/bin/apache-maven-3.2.1/lib/slf4j-api-1.7.5.jar
constituent[34]: file:/Users/dev/bin/apache-maven-3.2.1/lib/slf4j-simple-1.7.5.jar
constituent[35]: file:/Users/dev/bin/apache-maven-3.2.1/lib/wagon-file-2.6.jar
constituent[36]: file:/Users/dev/bin/apache-maven-3.2.1/lib/wagon-http-2.6-shaded.jar
constituent[37]: file:/Users/dev/bin/apache-maven-3.2.1/lib/wagon-http-shared-2.6.jar
constituent[38]: file:/Users/dev/bin/apache-maven-3.2.1/lib/wagon-provider-api-2.6.jar
constituent[39]: file:/Users/dev/bin/apache-maven-3.2.1/conf/logging/
---------------------------------------------------
Exception in thread "main" java.lang.NoSuchMethodError: org.codehaus.plexus.util.xml.pull.MXParser.<init>(Lorg/codehaus/plexus/util/xml/pull/EntityReplacementMap;)V
  at org.apache.maven.settings.io.xpp3.SettingsXpp3Reader.read(SettingsXpp3Reader.java:523)
  at org.apache.maven.settings.io.xpp3.SettingsXpp3Reader.read(SettingsXpp3Reader.java:557)
  at org.apache.maven.settings.io.DefaultSettingsReader.read(DefaultSettingsReader.java:92)
  at org.apache.maven.settings.building.DefaultSettingsBuilder.readSettings(DefaultSettingsBuilder.java:169)
  at org.apache.maven.settings.building.DefaultSettingsBuilder.build(DefaultSettingsBuilder.java:91)
  at org.apache.maven.cli.MavenCli.settings(MavenCli.java:766)
  at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:209)
  at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:606)
  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)

The JDK install is a fresh one, and also the maven installation is a fresh one. I've tried several different versions of maven, but they all give the same error. Any ideas on where I shall continue my search for the resolution of this error?

Also, the resulting command that is run (inside mvn script file, which fails) is /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/bin/java -classpath /Users/dev/bin/apache-maven-3.2.1/boot/plexus-classworlds-2.5.1.jar -Dclassworlds.conf=/Users/dev/bin/apache-maven-3.2.1/bin/m2.conf -Dmaven.home=/Users/dev/bin/apache-maven-3.2.1 org.codehaus.plexus.classworlds.launcher.Launcher

Any help is appreciated.

The problem seemed to be caused by settings of two different versions:

This is in your PATH:

/Users/dev/bin/apache-maven-3.1.1/bin

but having MAVEN_HOME set like this:

MAVEN_HOME=/Users/dev/bin/apache-maven-3.2.1

and M2_HOME:

M2_HOME=/Users/dev/bin/apache-maven-3.2.1

I wouldn't set MAVEN_HOME nor M2_HOME just simply set the PATH correctly to the Maven installation you want to use which simply means:

PATH=$PATH:/Users/dev/bin/apache-maven-3.2.1/bin

Update:

Have you unset JAVA_HOME? Where have you configured the setting of JAVA_HOME? Have you restarted you console? I would suggest to remove JAVA_HOME settings and put a file into $HOME/.mavenrc which contains the following:

export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home

I would suggest to use the following (assumed you have installed Java 1.7) in your $HOME/.mavenrc (plese check the path for this on your machine):

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home

The first this I would do in such a situation (after getting you variables straight, as shown by Karl-Heinz) would be to move ~/.m2/repository to ~/.m2/repository-old and re-run things.

(This sounds retarded, I know, but please try it and let us know the results).

I got the same problem. And when I restart a Spring project ,I got this: The error may be caused by jars in java exceptions directory which conflicts with libraries used by the external. Try adding -Djava.ext.dirs="" argument to 'Build process VM options ' in File|Settings|Build,Execution,Deploy....

The reason is when I run "mvn install",I incorrently install a wrong jar into %JAVA_HOME%\\jre\\lib\\ext. The solution is to remove the wrong jars in %JAVA_HOME%\\jre\\lib\\ext. Or repalce ext with a normal ext folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM