214

I got an error in Eclipse. What does this error message means:

The type iglu.ir.TermVector cannot be resolved. It is indirectly referenced from required .class files

zb226
  • 9,586
  • 6
  • 49
  • 79
karikari
  • 6,627
  • 16
  • 64
  • 79

23 Answers23

211

It means: "A class that you use needs another class that is not on the classpath." You should make sure (as Harry Joy suggests) to add the required jar to the classpath.

rmtheis
  • 5,992
  • 12
  • 61
  • 78
Arne Deutsch
  • 14,629
  • 5
  • 53
  • 72
  • In you're trying to remove classes in particular, check parent classes for reference to the missing type. If that's not always what this message means, it's what it means probably most of the time. – butallmj Feb 06 '14 at 20:03
  • 26
    @Arne, Why does it say **indirectly** referenced then? Shouldn't it have said that it is **not** referenced at all? – Pacerier Nov 24 '14 at 10:55
  • 4
    @Pacerier that would not be true. It's not your code that is directly referencing this type, but rather something your code uses, so the dependency from your code to that type is "only" transitive, but it is there. "Indirectly" tells you where to look. – hiergiltdiestfu Apr 15 '15 at 08:49
  • In my case the class was in the classpath but apparently Maven downloaded the artifact incorrectly. Go to the local maven repository ~/.m2/repository/path-to-the-dependency-jar, delete the folder and then update your project via "Maven -> Update Project" to download the dependency again. That did the trick for me. – ibai Jul 06 '17 at 10:54
  • This is wrong. I have the class on my classpath and still get this error. – Philip Rego Jan 30 '19 at 19:00
  • 1
    Then your classpath is probably different from what you think. – Arne Deutsch Feb 08 '19 at 09:12
25

This is as likely a matter of Eclipse's getting confused as it is an actual error. I ignored the error and ran the web service whose endpointInterface it complained about, and it ran fine, except for having to deal with the dialog every time I wanted to run it. Just another opaque error that tells me nothing.

Jerry Miller
  • 921
  • 1
  • 8
  • 11
  • It's also not in a jar. It's in one of the projecs that's included in all the included projects where it's of any relevance. – Jerry Miller Dec 05 '12 at 14:56
  • 4
    I've experienced this problem in eclipse, yet building via maven worked fine. The fix was to delete and re-import the project in the eclipse workspace that contained the required classes. – PiersyP Apr 09 '14 at 16:12
  • 1
    This may happen sometimes, but I have run into errors that give the same response, and the project can't build. – Mira Welner Jul 18 '19 at 16:35
19

It happens to me sometimes, I always fixed that with "mvn eclipse:clean" command to clean old properties and then run mvn eclipse:eclipse -Dwtpversion=2.0 (for web project of course). There are some old properties saved so eclipse is confused sometimes.

Mário Kapusta
  • 488
  • 7
  • 19
  • I cleaned the project (from Project->Clean...) and it worked. – Anu Shibin Joseph Raj Jul 24 '17 at 04:42
  • `mvn eclipse:clean` and/or mvn `eclipse:eclipse` seem to be the magic trick to make it work. – Antoine Martin Apr 30 '19 at 17:53
  • This helped me in Intellij IDEA with Maven also. – cellepo Feb 01 '21 at 19:03
  • Note that Maven `clean` phase is in its own _clean_ [Maven Lifecycle](https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#lifecycle-reference) - that's separate from _default_ lifecycle, which may have other phases you run more regularly (ex: `test`, or `install`, do not run `clean` beforehand, because `clean` is not in their _default_ Lifecycle). – cellepo Feb 01 '21 at 19:09
  • I had a similar problem, but unrelated to IntelliJ. mvn eclipse:clean initially made the problem far worse. To fix it, I deleted the project from eclipse (do NOT delete the source files) and then re-imported the project using import/maven. – Jack Straub Mar 20 '22 at 18:46
18

I had this error because of a corrupted local maven repository.

So, in order to fix the problem, all I had to do was going in my repository and delete the folder where the concerned .jar was, then force an update maven in Eclipse.

Xavier Portebois
  • 3,354
  • 6
  • 33
  • 53
  • 1
    This worked for me, while the above all didn't. The problem occured when one of my team mates updated the version of a repository from pom. – iaL Jun 05 '18 at 13:17
14

It sounds like this has been a known issue (Bug 67414)that was resolved in 3.0 ... someone has commented that it's occurring for them in 3.4 as well.

In the mean time, the work around is to remove the JRE System Library from the project and then add it back again. Here are the steps:

  • Go to properties of project with the build error (right click > Properties)

  • View the "Libraries" tab in the "Build Path" section

  • Find the "JRE System Library" in the list (if this is missing then this error message is not an eclipse bug but a mis-configured project)

  • Remove the "JRE System Library"

  • Hit "Add Library ...", Select "JRE System Library" and add the appropriate JRE for the project (eg. 'Workspace default JRE')

  • Hit "Finish" in the library selection and "OK" in the project properties and then wait for the re-build of the project

Hopefully the error will be resolved ...

zb226
  • 9,586
  • 6
  • 49
  • 79
NPKR
  • 5,368
  • 4
  • 31
  • 48
  • Yes.I had the same problem with spring-web-3.0.1.RELEASE.While it was registered as a dependency in pom.xml , and already working as a dependency in some references , when I made a http.csrf().disable().cors().disable().httpBasic().and().authorizeRequests() .antMatchers(PUBLIC_MATCHERS).permitAll().anyRequest().authenticated(); It broke down.Then I downloaded the jar file and import it the traditional manual way. – Tsakiroglou Fotis Aug 06 '17 at 17:03
  • I had the problem in Eclipse 4.26.0 (!) and could fix it following your advice. – Tillmann Mar 30 '23 at 16:06
  • Addendum to my previous comment (delayed because of an SO downtime): The problem occurred after I _interrupted a longer build_ and then restarted it. Nothing could be achieved by cleaning all projects in my workspace, nor by running a Maven project update on all projects. – Tillmann Mar 30 '23 at 16:19
5

This error occurs when the classes in the jar file does not follow the same structure as of the folder structure of the jar..

e.g. if you class file has package com.test.exam and the classes.jar created out of this class file has structure test.exam... error will be thrown. You need to correct the package structure of your classes.jar and then include it in ecplipse build path...

Mayur
  • 356
  • 3
  • 6
5

What fixed it for me was right clicking on project > Maven > Update Project

Eddie Martinez
  • 13,582
  • 13
  • 81
  • 106
4

I got this exception because eclipse was working in a different version of jdk, just changed to the correct, clean and build and worked!

4

I had an interesting case of this problem with Eclipse 4.4.2. My project (P1) referenced an external class (project P2) with two methods with the same name but different argument types:

public static void setItem(Integer id) …
public static void setItem(Item item) …

The type Item was contained in a third project P3, which I did not want to be visible here. P1 called only the first method:

ExternalClass.setItem(Integer.valueOf(12345));

So the second method, which used the Item class, was not used, and it is true that P3 was not in the compilation classpath – why should it if it is not used.

Still Eclipse told me

The type ...Item cannot be resolved.
It is indirectly referenced from required .class files

Compiling from the command line did not produce any such issues. Changing the name of the second method (unused here!) made the problem go away in Eclipse, too.

Renardo
  • 499
  • 4
  • 13
3

If you still can not find anything wrong with your setup, you can try Project -> Clean and clean all the projects in the workspace.

EDIT: Sorry, did not see the suggestion of verbose_mode ... same thing

Denis
  • 105
  • 1
  • 10
2

For me, it happens when I upgrade my jdk to 1.8.0_60 with my old set of jars has been used for long time. If I fall back to jdk1.7.0_25, all these problem are gone. It seems a problem about the compatibility between the JRE and the libraries.

Ming Leung
  • 385
  • 2
  • 13
1

I got the error when I just changing some svn settings and not anything in the code. Just cleaning the projects fixed the error.

1

In my case ,I created a project and made its minSdkVersion=9 and targetSdkVersion=17. I used automatically generated libs/android-support-v4.jar. I also had to make use of ActionBarActivity using android-support-v7-appcomapt.jar. So I just copied the android-support-v7-appcompat.jar file from android-sdk/extras/andrid/support/v7/appcompat/libs folder and pasted it to my project libs folder. And this caused the above error. So basically,I needed to put android-support-v4.jar file from android-sdk/extras/andrid/support/v7/appcompat/libs as well to my project libs folder. As per my knowledge the v7.jar file had dependencies on v4.jar file. So ,it needed it own v4.jarfile,instead of my project,automatically created v4.jar file.

laaptu
  • 2,963
  • 5
  • 30
  • 49
1

Quickly and Simply I fixed it this way ( I use ADT version: v21.0.0-531062 on Windows XP home edition)

  1. Opened manifest file.
  2. Changed the Existing project minSdkVersion to the same value as maxSdkVersion ( advise: it may be good to create a New project and see what is it's maxSdkVersion )
  3. Save manifest file.
  4. Right Click the project and select Build Project.
  5. From top menu: Project - Clean.. - check Only the relevant project, below I checked Start a build immediately and Build only the selected projects and OK.
  6. open the java file - NO red errors anymore !
  7. Back to step 1 above and changing Back minSdkVersion to it's Original value (to supoprt as many Android version as possible).

It worked BUT the problem returns every few days. I do the same as above and it solves and lets me develop.

Asherah
  • 18,948
  • 5
  • 53
  • 72
0

In addition to the already suggested cause of missing a class file this error can also indicate a duplicate class file, eclipse reports this error when an class file on the build path uses another class that has multiple definitions in the build path.

MilesHampson
  • 2,069
  • 24
  • 43
0

Since you give us very little details, most likely what you did, which is an incredibly easy mistake to make, is that instead of heading to

Build Path > Configure Build Path > Projects

and adding your additional project folder from there, instead you went to

Build Path > Configure Build Path > Libraries

and added your project folder from there instead.

This is most definitely the case if your code is all correct, but upon automatically reorganizing imports via the ctrl+space shortcut , instead of your import statements referring to com.your.additionalproject, your references all point to bin.com.your.additionalproject.

Note the bin. Meaning that you -are- indirectly referring to your class by treating your other project folder structure as a library, making your IDE doing all the wokr of finding the exactly binary class you're referring to.

To correct this, remove the folder from the Libraries, and instead add it under the Projects tab, and reorganize your imports. Your project should work fine.

steelmonkey
  • 415
  • 2
  • 6
  • 19
0

When i use a new eclipse version and try to use the previous workspace which i used with old eclipse version, this error occured.

Here is how i solve the problem:

Right click my project on Package Explorer -> Properties -> Java Build Path -> Libraries -> I see an error(Cross Sign) on JRE System Library. Because the path cannot be found. -> Double click the JRE System Library -> Select the option "Workspace Default JRE" -> Finish -> OK. -> BUM IT IS WORKING

FYI.

oiyio
  • 5,219
  • 4
  • 42
  • 54
0

In my case it was a result of my adding a new dependency to my pom.xml file.

The new dependency depended on an old version of a library (2.5). That same library was required by another library in my pom.xml, but it required version 3.0.

For some reason, when Maven encounters these conflicts it simply omits the most recent version. In Eclipse when viewing pom.xml you can select the "dependency hierarchy" tab at the bottom to see how dependencies are resolved. Here you will find if the library (and thus class) in question has been omitted for this reason.

In my case it was as simple as locking down the newer version. You can do so by right-clicking the entry - there is an option to lock it down in the context menu.

Chris Staikos
  • 1,150
  • 10
  • 24
0

For me none of the solutions above worked. What worked for me was to select all the code in the class, then convert it to a comment, save, then convert it back to normal text, the error was gone.

HopefullyHelpful
  • 1,652
  • 3
  • 21
  • 37
0

In my case the problem was "javax.ws.rs.webapplicationexception cannot be resolved" in execution when starting the web application in Tomcat.

Solution adding the following library (Maven):

<dependency>
    <groupId>javax.ws.rs</groupId>
    <artifactId>javax.ws.rs-api</artifactId>
    <version>2.0</version>
</dependency>
Vikcen
  • 153
  • 2
  • 9
0

right click on your project->properties->maven->active maven profile(comma seperated) then in that box write pom.xml and check the resolve dependencies from workspace project

ritu mansata
  • 77
  • 2
  • 13
0

I ran maven clean (only clean) and it solved the error

BugsOverflow
  • 386
  • 3
  • 19
-1

Point the JRE in the Build path to a JDK. That worked for me.

Neeleshkumar S
  • 746
  • 11
  • 19