0

I just happened to get the enum cannot be resolved to a type error, solution to which is described in this answer. But the thing is that I have source level 1.7 selected, so mentioned answer doesn't really help me:

image description

Libraries are up-to-date as well:

image description

Another thing is that I use Ant to build, and it builds the project without errors although whole project tree is red indicating problems:

image description

But, after being built, the project doesn't work, I get errors such as this one:

[ERROR] 2015-10-08 04:01:56,946 org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDAO' defined in ServletContext resource [/WEB-INF/hibernate-persistance.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [cz.techsys.web.server.services.hibernatepersistance.HibernateDAO]: Constructor threw exception; nested exception is java.lang.Error: Unresolved compilation problems: 
    Syntax error, annotations are only available if source level is 1.5 or greater
    Type mismatch: cannot convert from Object to PersistSession
    Syntax error, annotations are only available if source level is 1.5 or greater
    Syntax error, parameterized types are only available if source level is 1.5 or greater
    Type mismatch: cannot convert from Object to History
    Type mismatch: cannot convert from Object to LoginPersistance
    Syntax error, parameterized types are only available if source level is 1.5 or greater

As usual with Eclipse, I didn't really change anything, it changed itself. I am not editing the project and I used IDE only to build it, I'm not project author. Until now, all builds worked.

Community
  • 1
  • 1
Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778

3 Answers3

1

Try the following: Right click on project > Build Path > Configure Build Path, then on the Libraries tab click on JRE System Library and click on Edit button.

Then set the System library on Execution environment to the desired JavaSE or select Workspace default JRE (case the default is the correct).

Hope this helps.

Renan Baggio
  • 411
  • 1
  • 4
  • 11
0

Verify under Java -> Installed JRE's. That the correct JDK is selected.

Also, after doing so, go to Java -> Installed JRE's -> Execution Envirionments and align the correct jdk's/jre's with the execution environments!

  • Verified. While I was working, Eclipse suddenly crashed on Out of memory error. Afterwards, everything was fixed. Note that I already restarted IDE before and it didn't fix the problem. – Tomáš Zato Oct 12 '15 at 08:47
0

Double restart fixed the issue - Eclipse is just weird.

Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778