Showing posts with label eclipse. Show all posts
Showing posts with label eclipse. Show all posts

Tuesday, September 08, 2009

Is Eclipse deleting XML resources from my build path?

Keywords:
eclipse 3.4.0 ganymede FileNotFoundException xml properties build classpath filtered resources deleted excluded "class path resource cannot be resolved"

Problem:
I have a project where configuration resources (mostly hibernate - hibernate.cfg.xml & *.hbm.xml) exist in the same folders as the java source and it's expected that these are copied to the build output so they can be loaded from the classpath.

It seems eclipse is "cleaning up" the XML files from the build output folder. Check the include/exclude settings on the project and Included is set to (All). Adding *.xml explicitly to the included list makes no difference.

Out of curiosity, manually copying an XML file to the build output folder and refreshing the project causes the XML to be deleted. Why?

Solution:
I'm not sure if it was an update or plugin that caused this, but the problem is with the Filtered Resources setting.

In Window -> Preferences:
go to: Java > Compiler > Building
in Output folder section:
  • check the Filtered resources value
  • if *.xml is in the comma separated list, this is the cause.
    Remove from the list and allow the Project rebuild.

As mentioned, even if you explicitly add *.xml to be included in your Project settings the above global setting will cause it to be excluded.

Tuesday, June 16, 2009

Eclipse build errors - java.lang.object cannot be resolved

Keywords:
eclipse 3.4.0 ganymede The type java.lang.object "cannot be resolved" "Cannot find the class file" "refers to the missing type"

Problem:
Opened eclipse, it needed to do a full workspace build (probably because ant scripts have updated class files and it needs to refresh). Random classes in the project now no longer compile. Examples of the errors being reported:



DescriptionResourcePathLocationType
The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class filesMyClass.javaMyProject/src/com/exampleline 1Java Problem
The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this projectMyProjectUnknownJava Problem
The method myMethod(SomeClass) from the type MyOtherClass refers to the missing type (insert java type here: InputStream|File|Vector|IOException|etc)MyOtherClass.javaMyProject/src/com/exampleline 123Java Problem


Solution:
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:
  1. Go to properties of project with the build error (right click > Properties)
  2. View the "Libraries" tab in the "Build Path" section
  3. 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)
  4. Remove the "JRE System Library"
  5. Hit "Add Library ...", Select "JRE System Library" and add the appropriate JRE for the project (eg. 'Workspace default JRE')
  6. Hit "Finish" in the library selection and "OK" in the project properties and then wait for the re-build of the project
  7. Hopefully the error will be resolved ...