Frequently asked questions about Maven Integration for Eclipse project
- Common problems
- Unable to download the artifact from any repository xxx:zzz-2.4.1.jar
- Unable to locate the Javac Compiler Error
- How to Configure Proxy and location of Maven local repository
- Classpath container refresh job never finishes
- How to generate a thread dump
- How to configure Maven project to use separate output folders in Eclipse
- How to retrieve an actual command line used to start JVM and Maven
- Miscellaneous
Common problems
Unable to download the artifact from any repository xxx:zzz-2.4.1.jar
In some project dependency resolved and Maven builder give weird error about magic dependency version 2.4.1. This happens when project poms are using ${version}, which is resolved to system property that is set by some other Eclipse plugin. See MGG-2653 for more details.
Unable to locate the Javac Compiler Error
Some users reported the following error that happens when importing Maven projects or when invoking "Update Sources" action.
6/25/07 1:15:44 PM CDT: ERROR mojo-execute : compiler:compile : Compilation failure Unable to locate the Javac Compiler in: C:\Program Files\Java\j2re1.4.2_14\..\lib\tools.jar Please ensure you are using JDK 1.4 or above and not a JRE (the com.sun.tools.javac.Main class is required). In most cases you can change the location of your Java installation by setting the JAVA_HOME environment variable.
That happens because those actions runs in the same JVM where Eclipse is running. If that JVM comes from JRE that isn't part of JDK, there is no Java compiler (the tools.jar) around.
To workaround this you can add -vm argument to Eclipse command line or eclipse.ini. For Eclipse 3.3 it would look something like this:
-showsplash org.eclipse.platform --launcher.XXMaxPermSize 256m -vm C:\jdk1.6.0\bin\javaw.exe -vmargs -Xms40m -Xmx256m
Alternatively you could specify compilerId in the pom.xml, so Maven won't be looking for JDK when compiling Java code:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerId>eclipse</compilerId>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-eclipse</artifactId>
<version>xxxx</version>
</dependency>
</dependencies>
</plugin>
Also note that to launch Maven from within Eclipse, JRE used for launch also need to come from JDK.
By default Eclipse registers JRE it is started in, but this can be configured on "Window / Preferences... / Java / Installed JREs" preference page.
How to Configure Proxy and location of Maven local repository
Eclipse Plugin is using Maven's config.xml for proxy, local repository location and any other environment-specific configuration. This way we can use same settings between the command line and the IDE.
Default location of the settings.xml is at <user home>/.m2/settings.xml, but you can also specify location of the global settings, i.e. one in <maven home>/conf/settings.xml

Classpath container refresh job never finishes
This could happens for a number of reasons, but to narrow it down you can open Maven console in Eclipse Console view and check if there is any logging going on. It is possible that dependency resolved got into a loop (i.e. MNGECLIPSE-348. As a forkaround you can terminate this job and try to run Project / Clean... on individual projects.
If there is no logging happens then it is possible that job is blocked by some other plugins. To check that you need to take a thread dump and see if there are any deadlocks.
How to generate a thread dump
- On Windows press Ctrl-Break in the Java console started with Eclipse IDE. To start Eclipse with Java console use java.exe instead of javaw.exe in eclipse.ini.
-vm C:\jdk1.6.0_03\bin\java.exe
- On Unix, Linux, Mac OS X press Ctrl-\ in the terminal console used to start Eclipse IDE
- send the QUIT signal to the Java VM running Eclipse: kill -QUIT process_id, where process_id is the process number of the respective java process
- other tools listed on Javapedia ThreadDump page
How to configure Maven project to use separate output folders in Eclipse
Because Eclipse JDT is managing all changes in the project sources and incrementally compiles classes it is quite sensitive to the external modifications of compiled classes. That is why Maven users who also want to work with their projects in Eclipse IDE also want to configure Eclipse to use separate output folders for Maven projects, so it won't interfere with Maven build run from the command line.
On the other hand, many Maven plugins have assumptions about location of compiled classes and resources and in many cases, changing output folders would simply break those Maven plugins. That is why we decided to remove this option from version 0.9.4, which caused inconvenience for several people.
While we are still looking for a better solution, there is a simple workaround that allows to configure Maven project to use separate output folders for Eclipse. The idea is to use property to specify output folder location and change that property using Maven profiles. Here is how it could look like in pom.xml:
<project> ... <build> <outputDirectory>${basedir}/${target.dir}/classes</outputDirectory> <testOutputDirectory>${basedir}/${target.dir}/test-classes</testOutputDirectory> </build> <properties> <target.dir>target</target.dir> </properties> <profiles> <profile> <id>eclipse-folders</id> <properties> <target.dir>target-eclipse</target.dir> </properties> </profile> </profiles> ...
So, by default Maven would compile classes to /target/classes folder, but if "eclipse-folders" profile is enabled it would instead use /target-eclipse/classes folder. This configuration can be also declared in a common parent pom.xml.
In m2eclipse you can specify active profile for given project on Maven property page in project properties dialog

How to retrieve an actual command line used to start JVM and Maven
An actual command line used to start JVM processes in Eclipse, including Maven builds, can be retrieved from the Debug view (e.g. from the Debug perspective):

There you can select corresponding Java process and open its properties (from the popup menu or using Alt-Enter shortcut):

Miscellaneous
How Search Works
Dependency search is using local index for Maven repositories:
- indexes for remove Maven repositories, such as Central repository, can be downloaded from remote repositories if they publish index created using Nexus Indexer tool or if repository is managed by Nexus repository manager
- indexes for remote Maven repositories can be also packaged as Eclipse plugin and installed using Eclipse Update manager.
- index for a Local Maven repository is updated incrementally when plugin downloads jars from any remote repositories. Local repository can be also reindexed from Window / Preferences... / Maven preferences page.
- index for an Eclipse workspace is updated when projects are added, removed or changed in Eclipse workspace.
Maven Integration for Eclipse vs. Maven eclipse:eclipse plugin
The Maven Integration for Eclipse (m2eclipse) is an Eclipse plugin that allows execution of Maven goals and manages Maven dependencies. It is a different beast to the maven-eclipse-plugin which is a Maven plugin that attempts to manage/modify Eclipse project files to account for Maven dependencies. Generally, if you are using m2eclipse you don't really need maven-eclipse-plugin. The former is providing advanced project import and configuration features and provides integration with other Eclipse tools.
As of maven-eclipse-plugin-2.3 its dependency management is incompatible with m2eclipse and is waiting for the patches to be applied. See MECLIPSE-78.
What Maven version is used by plugin
Plugin is not actually using Maven itself. It is using component that is part of Maven called Maven Embedder. This component is not available for Maven 2.0.x. Embedder is used by the Maven command line interface (CLI) starting from version 2.1, so the current version of Embedder correspond to the Maven 2.1 code line that include number of improvements to allow to actually embed Maven.
If you want to execute particular version of Maven installed elsewhere, you can do so from the standard External Tools launch configuration.
You can also build Maven 2.1 from trunk and use it from the command line.
M2_HOME environment variable
Maven Integration for Eclipse currently is not using M2_HOME environment variable and generally any other environment variables.