Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Indirectly referenced from required .class files

I'm getting below error in STS:

The type org.springframework.core.env.EnvironmentCapable cannot be resolved. It is indirectly referenced from required .class files

like image 256
Srinivasan Avatar asked Dec 10 '13 15:12

Srinivasan


2 Answers

This sounds like a transitive dependency issue. What this means is that your code relies on a jar or library to do something - evidently, you depend on Spring framework code. Well, all that Spring code also depends on libraries and jars.

Most likely, you need to add the corerctly versioned org.springframework.core jar to your classpath so that the EnvironmentCapable class can be found when your IDE attempts to build your project.

This might also be a jar collision issue as well, although that sounds less likely. When an application experiences jar collision (also known as "dll hell"), the compiler is finding multiple jars and classes with the same fully-qualified name. For example, let's say you added Spring to your classpath, along with the entire Tomcat server library. Well, those two jars may contain the same exact named classes, maybe the same version, maybe different versions. But either way, when the compiler looks for that EnvironmentCapable class, it finds two (in this contrived example) - one in the Spring jar and one in the Tomcat jar. Well, it doesn't know which one to choose, and so it throws a ClassDefNotFoundException, which would/could manifest itself as the error you experienced.

like image 185
liltitus27 Avatar answered Nov 08 '22 21:11

liltitus27


I faced same error while i work with spring security on spring-security-config.i jsut deleted that jar in maven repo and gave maven->update Project in eclipse. it is resolved.Please try it once.

like image 33
Anbu Prakash Avatar answered Nov 08 '22 20:11

Anbu Prakash