Classpath entry org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER will not be exported

EclipseMavenExport

Eclipse Problem Overview


I'm getting this warning in Eclipse:

> Classpath entry org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER will not be exported or published. Runtime ClassNotFoundExceptions may result

After searching I found that I need fix export. I did it.

Eclipse Java Build Path properties

But this warning persists! What else can be done to fix it? Thanks.

Eclipse Solutions


Solution 1 - Eclipse

You can right click on the warning, choose quickfix and choose one of the following:

  • Mark the associated raw classpath entry as a publish/export dependency.
  • Exclude the associated raw classpath entry from the set of potential publish/export dependencies.

As you will not have eclipse publishing/exporting the project it is safe to exclude it. But either way it makes no difference

Step by step screenshots:
http://publib.boulder.ibm.com/infocenter/radhelp/v8/index.jsp?topic=/com.ibm.javaee.doc/topics/tlooseclasspath.html

Solution 2 - Eclipse

I had tried both of the options but only the latter is what you need:

  • Mark the associated raw classpath entry as a publish/export dependency
  • Exclude the associated raw classpath entry from the set of potential publish/export dependencies

If you export the dependency, refreshing the project configuration via Maven -> Update Project Configuration context menu will cause the warning to return. In this case you need to edit the .classpath file by hand:

<classpathentry kind="con" exported="true" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
	<attributes>
		<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
	</attributes>
</classpathentry>

Simply delete have the attribute exported="true" and confirm by refreshing the project configuration.

Solution 3 - Eclipse

I had the same problem; it vanishes after including

<packaging>war</packaging> 

in the pom. There was no packaging at all.

Solution 4 - Eclipse

http://geertschuring.wordpress.com/2009/03/05/why-the-maven2_classpath_container-will-not-be-exported-or-published/

On certain occasions Eclipse will present you with the following warning:

Classpath entry org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER will not be exported or published. Runtime ClassNotFoundExceptions may result.

So solve this, do the following:

Open the properties of the project that generates this warning
Click on “Java Build Path”
Click on the tab “Order and Export”
Enable “Maven Dependencies”
Click on “Ok”
Open the “Problems” view
Select the warning we are trying to solve, and press “Ctrl-1″
Click on “Ok”

The problem is now solved. It may take some time before the warning disapears because the project needs to rebuild before it goes away.

Solution 5 - Eclipse

I wasn't able to solve the problem with the quickfix in Eclipse Luna. The problem disappeared after removing the Project Facet "Dynamic Web _Module". In Windows -> Preferences -> Project Facets.

enter image description here

P.S. Packaging as War also solved the issued but it was suppoused to be a JAR and I was puzzled why some projects worked ok and some didn't.

And by the way, the warning was real. It caused a ClassNotFoundExceptions exceptions in the server that made it unsusable when other projects referenced this.

Solution 6 - Eclipse

Simply right click on the warning and do a quick fix

enter image description here

You can then review the .classpath file changes from source control

enter image description here

Solution 7 - Eclipse

I have a simple way to solve this problem:

  1. Delete the project from your Eclipse.
  2. Into the work space where the project is located.
  3. Delete the items selected in the following image. Just leave src and pom.xml.

enter image description here

  1. Re-import the project in your Eclipse.

Solution 8 - Eclipse

Most answers, including the currently accepted one, only provide a temporary solution to this issue: every time I chose Maven > Update Project… and leaving the option 'Update project configuration from pom.xml' on, the warning came back.

However, after installing m2e-wtp - Maven Integration for WTP in Eclipse 4.5 (Mars) and issuing Update Project… again, while leaving the option selected, the warning (and resulting error) went away.

Solution 9 - Eclipse

None of the answers helped in my case. Every time I update the project, m2e will delete the entry from the .classpath file which disables the warnings.

I've now filed a bug report: https://bugs.eclipse.org/bugs/show_bug.cgi?id=537401

Solution 10 - Eclipse

Using Eclipse Photon, the configuration below fixed the problem for me: Window > Preferences > Maven > Java EE Integration > Enable Java EE Configuration

Note that I disabled this option before receiving the warning Classpath entry org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER will not be exported

All other options may not be checked if you do not need them.

The warning does not reappear after a Maven update.

Solution 11 - Eclipse

I had the same issue after updating my JDK in project and resolved it by replacing my .classpath file with previous one. I noticed the following changes in my .classpath file

	<attributes>
		<attribute name="maven.pomderived" value="true"/>
		<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
	</attributes>

The second line was missing from above code

<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>

This line was missing

	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
	<attributes>
		<attribute name="owner.project.facets" value="java"/>
	</attributes>
</classpathentry>

These lines were added so I manually removed them and it all worked again.

Solution 12 - Eclipse

I was in the same situation that Aaron Digulla.

I am learning Maven and noticed that this issue manifested when

  • I added a pom packaging line, for war
  • updated the project
  • removed said line and updated again

I noticed that the file ".settings/org.eclipse.wst.common.component" was one of the leftover files after this operation. When I removed this one in particular and updated the project, the Warning would go away and it wouldn't come back unless I repeated it all again.

Solution 13 - Eclipse

Adding to the pom.xml:

<properties>
	<java.version>1.8</java.version>
</properties>

helped me in this case and also with Dynamic Web Module and other issues.

Solution 14 - Eclipse

I came across this issue too! I Believe that eclipse adds the same deps twice. once in the

> Maven Dependencies

Group and another in the form of

> M2_REPO/ ...

You must remove the last one in the

> Properties -> Java Buil Path -> Libraries

for the error to dissapear!

Solution 15 - Eclipse

That's the typical problem with maven projects configured in Eclipse that are changed its configuration or saved inappropriately.

Normally I'll edit my .classpath file and check the references for the build path, etc.

So in your case, I think you'll need to delete your classpathentry with those org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER reference inside.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser710818View Question on Stackoverflow
Solution 1 - EclipseAlin StoianView Answer on Stackoverflow
Solution 2 - EclipsedcompiledView Answer on Stackoverflow
Solution 3 - EclipseFrank RünagelView Answer on Stackoverflow
Solution 4 - EclipsegoooooooglingView Answer on Stackoverflow
Solution 5 - EclipseborjabView Answer on Stackoverflow
Solution 6 - EclipseFangmingView Answer on Stackoverflow
Solution 7 - EclipseMocoView Answer on Stackoverflow
Solution 8 - EclipseMarcel KorpelView Answer on Stackoverflow
Solution 9 - EclipseAaron DigullaView Answer on Stackoverflow
Solution 10 - EclipseRemi PatriarcheView Answer on Stackoverflow
Solution 11 - EclipseGaurav MattaView Answer on Stackoverflow
Solution 12 - EclipseJumBêView Answer on Stackoverflow
Solution 13 - EclipsejanapView Answer on Stackoverflow
Solution 14 - EclipseBiggg JimmmView Answer on Stackoverflow
Solution 15 - EclipseNacho CougilView Answer on Stackoverflow