1 November 2012

How to solve problem "The hierarchy of the type XXX is inconsistent" in project that uses spring framework

Solution for Eclipse/Spring framework 3.1.3

STORY:
So you create a shiny new project using spring framework  in eclipse and you based on some example "Hello World" found on internet and yo copy all stuff BUT Eclipse complain that:

"The hierarchy of the type HelloWorldController is inconsistent" near  to "extends  AbstractController ".

(Usually this error come with another: "The type org.springframework.beans.BeansException cannot be resolved. It is indirectly referenced from required .class files" ).

and you ask question WTF ... which stands for what a terrible failure ...

SOLUTION:

no worries.

It means your "copy and paste" skills are rubbish,because you forgot paste one of the libraries needed for spring framework
(One of the core library is missing .You need add to your librarys,maven or whatever you use for library managment)

In my case i forgot to add beans library called  org.springframework.beans-3.1.3.RELEASE


btw.

 1) if anybody need working hello world example for spring framework 3.0.5 and higher
http://www.dzone.com/tutorials/java/spring/spring-mvc-tutorial-1.html

 2)Here you have nice explanation of what inconsistent hierarchy error means in general case :    http://java.syntaxerrors.info/index.php?title=Inconsistent_hierarchy

Note to myself :
"The hierarchy of the type xxl is inconsistent"

if something in the hierarchy is broken(not exist etc.).
For example, if you have 


 public abstract class Size implements NonExistentInterface { 

   (...)

}
 public abstract XXL extends Size {

     (...)  

}


then you will get an error in Foo.java saying that the hierarchy of the type Foo is inconsistent.


(NonExistentInterface is an interface that doesn't exist .)

Worth to know: During crap nature of Eclipse it can be  displayed if your imports are out of sync,  hit 'Refresh' (F5) in project