Eclipse Problems View doesn't show Errors - eclipse

[Note: There is another thread about this problem but it did not answer the question.]
For one specific project in Eclipse, the problems view does not show errors. It shows warnings but it does not show errors. The other projects do show errors (and everything else). For that problematic project, I can see the red squiggly error line in the files. However, the directory structure does not show an error icon and the error is not populated in the Problems View.
Any ideas?

I want to post my story here if Google brings you to this question.
Somehow, "Project->Build Automatically" got turned off.
Turning it back on produces correct errors list.
I've tested that this is the case as far as Ganymede ( at the point of writing this post I am running Indigo )

For anyone else who is having this problem, I have found the answer:
Make sure that Eclipse recognizes your project as a Java project. Specifically, under Project Properties ensure that you have a Java Builder that is checked.
That way, your project will be built and you will see errors in the Problems view.

This was my problem:
http://solveme.wordpress.com/2009/01/06/eclipse-project-missing-default-java-builder/

You'll likely need to change the filter on the Problems view to see the errors. There's a downward pointing arrow in the upper right corner of the panel. Click it -> Configure Contents..., and in the Scope make sure "On any element" is selected.

I had the problem where in the red cross icon by the file name did not appear. I tried all possibilities described on this question. However, the root cause in my case was, I deleted a jar file from SVN. So the java file using the imports from this jar had errors. Surprisingly that didn't show up.
Looking at the build path, I found under Java Build Path -> Libraries -> jar (missing).
Having removed it from the build path, the red icon next to the file showed up !!
Excruciating it was to find this error and wasting so much time, I wonder why this icon does not show up nor does Problem view report it.

I googled this question having same problem, my solution was simply Project -> Clean.

I checked the .classpath file of the Eclipse project. It had incorrect value of src so it was pointing to the wrong source of Java files.
My files incorrect entry:
<classpathentry kind="src" path="src"/>
I changed it to the correct entry:
<classpathentry kind="src" path="source/java"/>
Now it is working.

I'm guessing that the build path for that project is lacking a core library. E.g. if it's a Java project there may not be a JRE/JDK assigned to it.
For a Java project, check this: Properties > Java Build Path > Libraries (this may differ depending on the version of Eclipse, I'm using 3.2.1 at the moment)
There should be a JRE or JDK listed here.

Here is the solution I use when the red icons do not appear on the project tree to highlight errors in our project files from Eclipse (Windows version).
Make sure Eclipse is running on the correct JVM. By default, it will use the latest JRE classpath stored in a registry. If you need to run Eclipse from a JDK instead of JRE, you need to tell Eclipse. So, add the -vm option at the top of the eclipse.ini to refer to our preferred JDK as follows:
-vm
C:\Program Files\Java\jdk1.7.0_21/bin/javaw.exe
Remember to change this when you are upgrading your JRE/JDK.
However, we may encounter issue with Maven complaining about tools.jar in a project's pom.xml. If Eclipse is running on Java JRE instead of JDK, it can be a problem to some Maven plugins like maven-bundle-plugin that still rely on tools.jar which only exists on JDK, causing it to complain. Don't worry about it if your still prefer to run Eclipse using JRE as you can put this entry inside your project's pom.xml to explicitly refer to the right tools.jar:
<profiles>
<profile>
<id>default-profile</id>
<activation>
<activeByDefault>true</activeByDefault>
<file>
<exists>${java.home}/../lib/tools.jar</exists>
</file>
</activation>
<properties>
<toolsjar>${java.home}/../lib/tools.jar</toolsjar>
</properties>
</profile>
<profile>
<id>windows_profile</id>
<activation>
<os>
<family>Windows</family>
</os>
</activation>
<properties>
<toolsjar>${java.home}/../lib/tools.jar</toolsjar>
</properties>
</profile>
<profile>
<id>osx_profile</id>
<activation>
<os>
<family>mac</family>
</os>
</activation>
<properties>
<toolsjar>${java.home}/../Classes/classes.jar</toolsjar>
</properties>
</profile>
</profiles>

My problem was that I had a project that I had not edited in a while, so it was linking on a version of the jre that I no longer had on my system. I went to the project properties --> java build path and deleted the reference to the outdated jre.

I am a newbie to STS, and I had a similar problem. Errors weren't showing up until I saved the file. I discovered it was because I was using the Text Editor, instead of the Java Editor.

I had this mysterious problem in my new installation of Spring Tool Suite 4.
Then I realized that most of the columns in the problems view had been reduced to zero width for some weird reason.
So I just had to drag in the columns from the left and everything appeared.

Related

Mapping maven structures to Eclipse structures, then analyzing with JDT

I'm trying to generate Java unit tests using Eclipse's JDT. Part of that is determining the classpath that pertains to a particular Java class.
I imported a Maven project named jaffa-framework into Eclipse. Jaffa-framework has several Maven modules, including jaffa-api. Each of the submodules has its own pom.xml. I can build jaffa-framework and its submodules with no problem using Maven from within Eclipse (although it will not build using Project -> Build Project).
<project ...
<artifactId>jaffa-framework</artifactId>
...
<profiles>
<profile>
<id>normal</id>
<modules>
<module>jaffa-api</module>
...
</modules>
</profile>
</profiles>
...
</project>
When I import jaffa-framework into Eclipse as a Maven project, I see the following in the UI:
A Java project: jaffa-framework
Two Folders/IPackageFragmentRoots for jaffa-api:
jaffa-api/src/main/java and jaffa-api/src/test/java
One "plain" folder: jaffa-api
This structure looks weird to me. I expected to see something more like:
jaffa-framework
jaffa-api
jaffa-api/src/main/java
jaffa-api/src/test/java
Perhaps I did something wrong while importing? If you have ideas, please let me know.
If I select a Java file within jaffa-api/src/main/java, I can use JDT to navigate to the jaffa-framework project and get its classpath using javaProject.getResolvedClasspath(true); however, what I really need is the classpath for jaffa-api.
The jaffa-api folder contains a pom file, a .project file, and a .classpath file. I don't see an easy way to navigate to it using JDT, and because it is a folder, I don't see how I could obtain the classpath programmatically using JDT.
I'm also wondering why jaffa-api looks like a plain folder, instead of something more project-like. Eclipse must know that it is some kind of subproject, because the folder contains .classpath and .project files.
Please tell me how I can access the classpath information of jaffa-api using JDT, and/or how I can correct my project set up.
There was something screwy about my original project creation. I'm not sure what.
I solved my problem by deleting my jaffa-framework project by right-clicking on it and choosing "Delete" from the menu. I re-imported the project using File -> Open Projects from File System. I'm guessing the key thing to notice here is that the "Search for nested projects" box is checked. After the project was reloaded, both jaffa-framework and jaffa-api appeared as projects.

Eclipse loops endlessly: Invoking 'Maven Project Builder'

Ugh! My Eclipse is stuck in an endless loop:
No operations to display at this time
Refreshing Workspace Building
Workspace. Invoking 'Maven Project Builder' on /MobileWebApp
The building workspace never gets past 58%.
Details:
Google's GWT provides a sample app MobileWebApp. They suggest adding it to Eclipse via File > Import > Checkout Maven projects from SCM.
I followed the instructions in this blog for adding the plugins for m2e, subclipse, and the m2e-subclipse connector.
After installing the plugins, I imported the sample project via File > Import > Checkout Maven projects from SCM and this URL.
The import seemed to complete ok and Eclipse doesn't display any markers. But now I have this endless refreshing and building and have no clue what is causing it or how to fix it.
Versions:
Eclipse Indigo 3.7
m2e 1.0.100
m2e connector for build-helper-maven-plugin 0.14
Maven SCM handler for Subclipse 0.13
Subclipse 1.6.18
Subclipse Client Adapter 1.6.12
Any advice is greatly appreciated.
I opened my module's .project file. There were two entries:
<buildCommand>
<name>org.maven.ide.eclipse.maven2Builder</name>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
</buildCommand>
I removed org.eclipse.m2e.core.maven2Builder entry and it magically fixed the problem.
I was able to resolve this by right clicking on the project and selecting Run As > Maven Clean
I was getting the same issue in an eclipse (Juno) Maven project that had nothing to do with GWT - it just kept refreshing and "Invoking Maven Project Builder". Going to the Progress view and requesting a cancellation of either progress entry (by clicking that red stop button on the right) didn't help.
The project the builder kept getting stuck on was always the same, and a couple of levels deep in a set of multi-pom maven projects in eclipse.
What eventually solved it for me was just going into that particular project's Properties > Builders and unchecking Maven Project Builder (but keeping the Java Builder checked so that it would still auto-build when code changed). I just ignored the warning about this being an "advanced operation" and possibly having "many side-effects" - I figured it couldn't be any more annoying than that constant build-refresh cycle. I'm still not sure what the cause of this loop was, but that stopped it for me. And I haven't had any problems since.
I actually solved the problem that was caused by the jaxb plugin. If the forceRegenerate is set to true you will get the build loop in eclipse (Kepler in my case).
Verify that you have forceRegenerate set to false in your maven-jaxb-plugin.
<configuration>
<forceRegenerate>false</forceRegenerate>
</configuration>
M2e, even in eclipse mars, seems to like infinite building.
In my case, no such thing as repeated build commands, as listed bellow.
The only thing that seems to work when the project tree is gigantic is:
open eclipse
Disable build automatically as soon as you open eclipse
refresh the workspace and trigger manual a Crtl+B or a build all.
Once eclipse is satisfied that it build the full project tree ... better have four core machine or you're gonna be waiting a while, you can finely put the build automatically option active. Eclipse seems not to go in a building spree after that. It will still go for a while scanning some folders, but activating the build automatically - once you've built it all before - is much faster than a new build all, and finally, eclipse becomes stable stops building infinitely.
Otherwise, you're stuck with the deprecated mvn eclipse:eclipse ...
and have to abandon the use of maven commands from within eclipse echosystem. M2e seems to have a really gigantic hard time cooperating with the beast.
I still use m2e, but must say it is 100 times more difficult to swallow m2e than maven integration in netbeans. On the otherhand, eclipse is much faster for very large code base. Pick your poison, you'll always get bitten.
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>rootPom</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
The problem can be a code generating plugin like the openapi-generator-maven-plugin or the protoc-jar-maven-plugin. Such plugins are generating code that retriggers the eclipse compilation. A solution to prevent this behavior could be to disable the plugin for the Eclipse "Maven Project Builder". This can be done by adding an entry to the pom.xml like described here: https://www.eclipse.org/m2e/documentation/m2e-execution-not-covered.html
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<!-- Add plugin execution configuration here -->
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
Such Plugin configuration could look like similar to the following example:
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<versionRange>[0.0,)</versionRange>
<goals>
<goal>generate</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
Alternatively such settings could be done globally for a eclipse workspace: Window > Preferences > Maven > Lifecycle Mappings.
More about this topic can be read here: https://www.benchresources.net/eclipse-maven-plugin-execution-not-covered-by-lifecycle-configuration/
This issue generally also comes when maven unable to delete some file may that is having too long name. So you can manually go to your target folder and clean it and restart eclipse.
it some times worked for me when i change my JAVA_HOME to a new location
I did something similar to Amos M. Carpenter response (https://stackoverflow.com/a/28713259/4470352)
But also I created a new custom builder with the following configuration:
Choose configuration type -> Program
Location (text box) <= D:\apache-maven-3.3.9\bin\mvn.cmd (my custom maven)
Working Directory (text box) <= ${workspace_loc:/project}
Arguments (text area)
<= clean compile test-DproxySet=true -DproxyHost=a.proxy.host -DproxyPort=8080
This compiles me the project with no progress bar, but i can see the progress in text console.
The problem in my case is that every time I compile that project, I download a WSDL and I need to provide proxy configuration. When maven project builder plug-in tries to compile my project, fails and starts again in a loop.
I have tried to setup it into settings.xml maven configuration file, but doesn't work for me, and providing proxy configuration in command line works.
So creating that custom builder does the job and is a new approach.
I hope it to helps you.
I have configured the java environment variable properly (i.e., JAVA_HOME).
Also added the jdk path to the environment variable path, in my case path is C:\Program Files\Java\jdk1.8.0_101\bin.
Also I added path to JDK home in "Installed JREs" preference in Eclipse.
Not sure which one of this resolved the issue, I don't see auto build happening now.
After this, I created a new maven project. Which was set to use the 1.7 by default, this project too resulted in endless loop. But 1.7 is not configured in eclipse. Updating the project properties to use the java version available in my eclipse has resolved the issue.
Eclipse on my workstation hangs every time I try to update maven project. The issue is not resolved even after trying a lot of resolutions/workarounds suggested by community. The only thing that works for me is to run mvn clean and install commands from command prompt. I end the task in task manager, run mvn commands and then re-launch eclipse. Running clean build after re-launching eclipse works fine.
I linked some files in eclipse but the source file was missing (deleted in the meantime). This caused eclipse to restart the build. Deleting the broken link solved the problem.
Delete project from eclipse(not from disk).
And import as "General>Existing Projects into Workspace"
This was happening to me after a project I cloned from GitHub changed its structure to multi-module Maven project. Since some eclipse-specific files were in .gitignore, doing git pull kept the originals even after I removed the old project from Eclipse and re-imported it as new with submodules. This apparently caused some chaos leading to the issue.
Nuking the project directory and re-cloning the project resolved the issue.
Eclipse -> Preferences -> Maven -> Installations
Remove additional installation and using EMBEDDED helped me.
The trigger was, that I wanted to have a separated maven setup for
SLF4J: Class path contains multiple SLF4J bindings.
In my case, I was working with react so running node using frontend plugin. If node is running then it stucks on Invoking 'Maven Project Builder'. I closed node and invoking was completed asap. Node instance running in eclipse was creating issue. I am using windows so going into task manager I closed node instances like shown in image and it works fine. You can check if there is any instance under eclipse which is causing issue.
I opened my module's .project file. There were two redundant entries and deleting one helped
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
I had the same problem. It turns out that I was running Eclipse with the pipe (|) operator, running another process in parallel. The other process was jamming my Eclipse thread. Once I shut down the other process, Eclipse worked fine.

Java compiler level does not match the version of the installed Java project facet

I have created a New Dynamic Project under Eclipse Helios Version, where my JRE Version is set to 1.6.
I have added Maven capabilities to the Web Application by clicking on Configure → Convert to Maven Project.
After adding this, a build error appeared in the Eclipse Problems view:
Java compiler level does not match the version of the installed Java project facet.
Unknown Faceted Project Problem (Java Version Mismatch)
Please tell me how to resolve this error (I want to have my JRE version as 1.6 only).
If your project is not a Maven project, right-click on your project and choose Properties to open the Project Properties dialog.
There is a Project Facets item on the left, select it, look for the Java facet on the list, choose which version you want to use for the project and apply.
Assuming that you are using the m2e plugin in Eclipse, you'll need to specify the source and target versions as 1.6 for maven-compiler-plugin. m2e uses these values to determine the project's Java compiler level. A snippet of the POM is shown below:
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
Alternatively, you can specify the maven.compiler.source and maven.compiler.target properties with values of 1.6, that happen to be the equivalent:
<properties>
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.source>1.6</maven.compiler.source>
</properties>
TK Gospodinov answer is correct even for maven projects. Beware: I do use Maven. The pom was correct and still got this issue. I went to "Project Facets" and actually removed the Java selection which was pointing to 1.6 but my project is using 1.7. On the right in the "Runtimes" tab I had to check the jdk1.7 option. Nothing appeared on the left even after I hit "Apply". The issue went away though which is why I still think this answer is important of the specific "Project Facets" related issue. After you hit OK if you come back to "Project Facets" you will notice Java shows up as version 1.7 so you can now select it to make sure the project is "marked" as a Java project. I also needed to right click on the project and select Maven|Update Project.
I found #bigleftie's comment above very helpful:
"Four things must match
Project->Java Build Path->Libraries->JRE version
Project->Java Compiler-> Compiler Compliance Level
Project->Project Facets->Java->Version
(if using Maven) pom.xml - maven-compiler-plugin artefact source and target".
In my case, in the project properties, Java compiler, the JDK compliance was set to use the workspace settings, which were different from the java version for the project. I clicked on 'Configure Workspace Settings', and changed the workspace Compiler compliance level to what I wanted, and the problem was resolved.
I resolved this problem by setting the java version in Project Facet property of the project properties, Right click the project root folder -> Properties, search for Project Facets, and select compatible java version.
For reference -
I changed the configuration inside workspace/project/.setting/org.eclipse.wst.common.project.facet.core to :
installed facet="jst.web" version="2.5"
installed facet="jst.java" version="1.7"
Before changing config, remove project from IDE.
This worked for me.
I resolved it by Myproject--->java Resource---->libraries-->JRE System Libraries[java-1.6] click on this go to its "property" select "Classpath Container" change the Execution Environment to java-1.8(jdk1.8.0-35) (that is latest)
The Project Facet->Java should match whatever you have in the pom.xml for the maven-compiler-plugin artifact source and target.This is perfect.But if you donot have it here then you can also fix it by matching Java compiler version in Porject-Facets from the setting: Eclispe->Preferences->Java->Compiler
You can change project facet from
Project --> Properties --> Project Facet --> Java --> {required JDK version}
Right click the project and select properties
Click the java compiler from the left and change to your required version
Hope this helps
In Eclipse, right click on your project, go to Maven> Update projetc. Wait and the error will disappear. This is already configured correctly the version of Java for this project.
If using eclipse,
Under.settings click on org.eclipse.wst.common.project.facet.core.xml
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="java" version="1.7"/>
</faceted-project>
Change the version to the correct version.

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

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.
But this warning persists!
What else can be done to fix it?
Thanks.
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
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.
I had the same problem; it vanishes after including
<packaging>war</packaging>
in the pom. There was no packaging at all.
See this solution from Geert Schuring's blog:
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.
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.
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.
Simply right click on the warning and do a quick fix
You can then review the .classpath file changes from source control
I have a simple way to solve this problem:
Delete the project from your Eclipse.
Into the work space where the project is located.
Delete the items selected in the following image. Just leave src and pom.xml.
Re-import the project in your 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
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.
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.
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.
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.
I had the same problem in a maven project with dynamic web project, but I solved it like this.
Right click on the project
Properties
Deployment Assembly and button "add".
Select Directive Type "Java Build Path Entries"
Select "Maven Dependecies" and select button finish
This way when the "war" file of the final project is created, all the "jar" files from the "Maven Dependencies" directory will be added.
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.
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!
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.

Get source jar files attached to Eclipse for Maven-managed dependencies

I am using Maven (and the Maven Eclipse Integration) to manage the dependencies for my Java projects in Eclipse. The automatic download feature for JAR files from the Maven repositories is a real time saver. Unfortunately, it does not include API documentation and source code.
How can I set up Maven to automatically also get the source and javadoc attachments and register them properly with Eclipse?
I am sure m2eclipse Maven plugin for Eclipse - the other way around - can do that. You can configure it to download both the source files and javadoc automatically for you.
This is achieved by going into Window > Preferences > Maven and checking the "Download Artifact Sources" and "Download Artifact JavaDoc" options.
mvn eclipse:eclipse -DdownloadSources=true
or
mvn eclipse:eclipse -DdownloadJavadocs=true
or you can add both flags, as Spencer K points out.
Additionally, the =true portion is not required, so you can use
mvn eclipse:eclipse -DdownloadSources -DdownloadJavadocs
The other answers on this work, but if you want to avoid having to remember command line arguments, you can also just add to the downloadSources and downloadJavadocs config to the maven-eclipse-plugin section of your pom.xml:
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
... other stuff ...
</configuration>
</plugin>
</plugins>
</build>
...
</project>
I prefer not to put source/Javadoc download settings into the project pom.xml file as I feel these are user preferences, not project properties. Instead, I place them in a profile in my settings.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<profiles>
<profile>
<id>sources-and-javadocs</id>
<properties>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>sources-and-javadocs</activeProfile>
</activeProfiles>
</settings>
Right click on project -> maven -> download sources
If the source jars are in the local repository and you are using Eclipses maven support the sources are getting automatically attached. You can run mvn dependency:sources to download all source jars for a given project. Not sure how to do the same with the documentation though.
If you are using meclipse do
window --> maven --> Download Artifact Sources (select check)
(If you still get attach source window, then click on attach file button and close the attach source window. The next time you try to see the source it will open the correct source)
There is also a similiar question that answers this and includes example pom settings.
I tried windows->pref..->Maven But it was not working out. Hence I created a new class path with command mvn eclipse:eclipse -DdownloadSources=true and refreshed the workspace once. voila.. Sources were attached.
Source jar's entry is available in class path. Hence new build solved the problem...
in my version of Eclipse helios with m2Eclipse there is no
window --> maven --> Download Artifact Sources (select check)
Under window is only "new window", "new editor" "open perspective" etc.
If you right click on your project, then chose maven--> download sources
Nothing happens. no sources get downloaded, no pom files get updated, no window pops up asking which sources.
Doing mvn xxx outside of eclipse is dangerous - some commands dont work with m2ecilpse - I did that once and lost the entire project, had to reinstall eclipse and start from scratch.
Im still looking for a way to get ecilpse and maven to find and use the source of external jars like servlet-api.
Changing pom for maven-eclipse-plugin to include source/javadoc just apply for new dependencies being added to pom. If we need to apply for existing dependencies, we must run mvn dependency:sources. I checked this.
Checking download source/javadoc in Eclipse-Maven preference, sometimes is not enough. In the event maven failed to download them for some reason (a network blackout?), maven creates some *.lastUpdated files, then will never download again. My empirical solution was to delete the artifact directory from .m2/repository, and restart the eclipse workspace with download source/javadoc checked and update projects at startup checked as well.
After the workspace has been restarted, maybe some projects can be marked in error, while eclipse progress is downloading, then any error will be cleared.
Maybe this procedure is not so "scientific", but for me did succeded.
I've added the pom configuration to the maven-eclipse plugin to download source and javadocs, but I figure/hope that will happen for new dependencies, not existing ones.
For existing dependencies, I browsed in package explorer down to the "Maven Dependencies" and right-clicked on commons-lang-2.5.jar, selected Maven | Download Sources and... nothing appeared to happen (no progress bar or indication that it was doing anything). It did, however, download as I'm able to jump to source in commons-lang now.
overthink suggested using the setup in the pom:
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
... other stuff ...
</configuration>
</plugin>
</plgins>
</build>
...
First i thought this still won't attach the javadoc and sources (as i tried unsuccessfully with that -DdownloadSources option before).
But surprise - the .classpath file IS getting its sources and javadoc attached when using the POM variant!
For Indigo (and probably Helios) the checkboxes mentioned above are located here:
Window -> Preferences -> Maven
I had a similar problem, and the solution that worked best for me was to include the source in the same jar as the compiled code (so a given directory in the jar would include both Foo.java and Foo.class). Eclipse automatically associates the source with the compiled code, and automatically provides the JavaDoc from the source. Obviously, that's only helpful if you control the artifact.
After Setting the Properties either at Project Level or User Properties level,
Please do a Maven -> Update Project (Force Update). It downloads the sources
A Small addition to the answer, if your project is not a maven project still you can get the source code of the jars, by using this plugin provided in eclipse
Java Source Attacher