Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing tools.jar in local repository breaks m2eclipse

The problem I'm experiencing is that eclipse can't resolve any of the dependencies of my project. This causes problems because even though the dependencies seem to work alright when coding (I get autocompletion) I still get a huge list of errors referring to missing artifacts.

When filtering these, I found the following:

The container 'Maven Dependencies' references non existing library '/home/[...]/.m2/repository/com/sun/tools/1.5.0/tools-1.5.0.jar'

It seems that this dependency was introduced by struts2, who have a profile set up as follows in their pom:

<dependency>
    <groupId>com.sun</groupId>
    <artifactId>tools</artifactId>
    <version>1.5.0</version>
    <scope>system</scope>
    <systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>

That systemPath resolves and so I don't see a reason why this would be causing trouble. In any case, is there a way to tell eclipse that this m2eclipse dependency is a system dependency that is not found in the local repository?

like image 279
wds Avatar asked Mar 11 '11 13:03

wds


People also ask

How do I add a missing jar to Maven dependencies in eclipse?

My problem solved by right click on project -> Maven -> Update project. Then the Maven Dependencies appear on the project explore. Save this answer.

Why Maven dependencies are not showing in STS?

You can find this in Window > Preferences > Maven > User Settings , and then point Global Settings to your external maven settings. xml . Then i removed the broken projects and re-added them, and the Maven Dependencies library appeared again. Save this answer.

How do you fix the container Maven dependencies references non existing library?

Try to update your Maven configuration : In the Project Explorer, right-click on the project, Maven -> Update project. If the problem still remains, try to clean your project: right-click on your pom. xml, Run as -> Maven build (the second one). Enter "clean package" in the Goals fields.


2 Answers

I was facing the same problem and needed to do the following things

  • Added -vm path/to/jdk/bin in eclipse.ini file
  • Clean the existing workspace and reload the project.

It worked for me seamlessly.

Its worth to add that, in my eclipse.ini file I had to add the -vm ... lines at the top of the file. like

-vm
C:\Program Files\Java\jdk1.6.0_27\bin
... ... ...

Make sure that, -vm option is placed before -vmargs as everything after -vmargs is passed directely to vm and selecting a particular is depend on -vm option.

like image 118
Samiron Avatar answered Nov 07 '22 06:11

Samiron


I had this issue, but I have fixed by using the steps below:

Case1:

Eclipse by default pointing to JRE but eclipse maven plugin required JDK so point to JDK

Window -> Preperences -> Java -> Installed JREs

change it to JDK

Follow the steps to change to JDK from JRE

  1. In the Eclipse IDE go to: Window… Preferences… Installed JREs
  2. Select defaulted JRE and click on Edit.
  3. Click on Add External Jar
  4. I found tools.jar in “C:\Program Files\Java\jdk1.6.0_22\lib” and added.

Now I can build my project without any issue. Is this the correct way to solve this issue?

like image 31
Sasikumar Murugesan Avatar answered Nov 07 '22 05:11

Sasikumar Murugesan