Shengjie
Shengjie

Reputation: 12786

Eclipse: The archive which is referenced by the classpath, does not exist

My Eclipse is Indigo Java classic.

I have a java project which has mockito-all as a dependency. pom.xml:

<dependency>
    <groupId>org.mockito</groupId>
    <artifactId>mockito-all</artifactId>
    <version>1.8.5</version>
    <scope>test</scope>
</dependency>

run mvn clean install, everything is ok. Then I did mvn eclipse:eclipse to resolve all the dependencies in Eclipse.

when I try to run a Junit in eclipse, it doesn't run and gives me this error:

'Launching YourTest' has encountered a problem.

The archive: /home/shengjie/.m2/repository/org/mockito/mockito-all/1.9.5.jar which is referenced by the classpath, does not exist.

My project pom.xml claims it's depending on mockito-all 1.8.5, I am not sure where the 1.9.5 reference is coming from. Any ideas?

==EDIT==

$ mvn dependency:tree | grep mockito
[INFO] +- org.mockito:mockito-all:jar:1.8.5:test
[INFO] \- org.powermock:powermock-api-mockito:jar:1.4.12:test
[INFO] \- org.powermock:powermock-api-mockito:jar:1.4.12:test
[INFO]    +- org.mockito:mockito-all:jar:1.8.5:test (version managed from 1.9.0)
[INFO] |  +- org.mockito:mockito-all:jar:1.8.5:test (version managed from 1.9.5; scope managed from compile)
[INFO] |  +- org.mockito:mockito-all:jar:1.8.5:test (version managed from 1.9.5; scope managed from compile)
[INFO] \- org.powermock:powermock-api-mockito:jar:1.4.12:test
[INFO] +- org.mockito:mockito-all:jar:1.8.5:test
[INFO] +- org.powermock:powermock-api-mockito:jar:1.4.12:test
[INFO] |  +- org.mockito:mockito-all:jar:1.8.5:test (version managed from 1.9.5; scope managed from compile)

Upvotes: 34

Views: 129641

Answers (8)

Sudhanshoo Sarage
Sudhanshoo Sarage

Reputation: 13

I was facing similar issue :

Eclipse: The archive which is referenced by the classpath, does not exist

Run as --> Run Configurations --> Dependencies, tab were having jars which was not available at given location of my system.

Upvotes: 0

Vikas Piprade
Vikas Piprade

Reputation: 352

I reproduced this problem

enter image description here

Resolution :-

As stated in error "The archive: /AutomationPrj/src/test/resources/resources which is referenced by the classpath, does not exist."

In my project /AutomationPrj/src/test/resources**/resources** indeed does not exists. I created resources folder [empty] at appropriate location and issues resolved.

enter image description here

Upvotes: 0

Go to Window > Show View > Navigator

There you will see .classpath file where the dependencies related to your M2 Repo can be seen

An example would be -

<classpathentry 
 exported="true" 
 kind="var" 
 path="M2_REPO/javax/activation/activation/1.1.1-redhat-2/activation-1.1.1-redhat-2.jar"/>

Change the version to the one under

Project Explorer > Your Project > Libraraies > Maven Dependencies

enter image description here

Hopefully this will resolve the issue.

Upvotes: 5

Issam El omri
Issam El omri

Reputation: 131

If any of the previous answers didn't work, try this : Right click on your project -> Debug As -> Open Debug Dialog ... -> In the classpath you'll find the jar causing you the trouble. Remove it.

Hope this work for you as it worked for me.

Upvotes: 1

Anuj Kumar
Anuj Kumar

Reputation: 11

It might be the version issue of java and eclipse.

I upgraded from kepler to mars and I was using JAVA 1.7. I faced the same issue with tools.jar.

I downgrade the eclipse and this time build ran successfully. It might help you.

Upvotes: -1

Christopher Broderick
Christopher Broderick

Reputation: 448

In my case I had a JRE installed then added a JDK. ANT seemed to stick with the JRE even though I changed my project to use the JDK.

To fix this I had to do: 1. Select "Run As..." 2. Select the second "Ant build..." option 3. This brings up a panel to allow setting configuration. Choose the "JRE" tab and change the selected JRE to the JDK

Upvotes: 2

macloving
macloving

Reputation: 1277

In my case with using ANT I change the setting in Windows --> Preferences --> Ant --> Runtime --> Global Entries. You need to add tools.jar as an External Jar.

Upvotes: 8

Birol Efe
Birol Efe

Reputation: 1751

I had a similar problem while I was trying to start my tomcat. I would suggest that you check "Classpath" the following way:

1) Run Configurations

  • Right click on your project
    • then click "Run" -> "Run Configurations..."
    • there check your settings for you project (e. g. in my case it was the Apache Tomcat)
    • here look into you tab "Classpath" under "User Entries"

2) Project classpath

  • Right click on your project -> "Properties" -> "Java Build Path"
    • now check the "Source" Tab as well as your "Libraries" Tab
    • Problems should be marked red in the "Libraries" tab

Upvotes: 89

Related Questions