Bug 364600 - Java/Groovy files disappearing from Project Explorer when not located inside the build path
Summary: Java/Groovy files disappearing from Project Explorer when not located inside ...
Status: NEW
Alias: None
Product: WTP Java EE Tools
Classification: WebTools
Component: jst.j2ee (show other bugs)
Version: 3.0.3   Edit
Hardware: PC Windows 7
: P3 normal with 4 votes (vote)
Target Milestone: ---   Edit
Assignee: jst.j2ee CLA
QA Contact: Chuck Bridgham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-23 09:36 EST by Mauro Molinari CLA
Modified: 2020-06-16 11:57 EDT (History)
3 users (show)

See Also:


Attachments
Zipped project to reproduce the problem (4.01 KB, application/zip)
2011-11-23 09:37 EST, Mauro Molinari CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mauro Molinari CLA 2011-11-23 09:36:58 EST
Build Identifier: 20110916-0149

When a Java (or Groovy) file is located outside the build path of a Dynamic Web Project, some kind of operation will make it disappear from the Project Explorer. That file won't be reachable in any way then, at least with the Project Explorer. You must use the Package Explorer or Ctrl+Shift+R to get to it again. 

To make the file visible again in the Project Explorer, you have to disable the "Enhanced Java Rendering for Web" content provider.

If you are wondering why one may put a Java file outside the project build path, the answer is that there may be other files with Java or Groovy nature that are usually located outside the build path and are used for some other facilities. In particular, this problem was tracked down after the reporting of a bug in Spring Tools Suite integration with Gradle (see: https://issuetracker.springsource.com/browse/STS-2278, especially Kris De Volder's comment of 18/nov/11): in Gradle projects, there are Groovy files (usually build.gradle or settings.gradle) that are located in the root of a project (which may be a Java project or a Dynamic Web Project) and that are handled by the Groovy editor (because their content is actually Groovy code). This bug is making those file "randomly" disappear from the Project Explorer (although we discovered it does not actually happen "randomly").

Reproducible: Always

Steps to Reproduce:
Reproduced with a just-downloaded Eclipse IDE for Java EE Developers:

1. import the attached project in a fresh new workspace
2. double click on the MyClass.java located at the root of the project, so that the Java editor is opened
3. now try to change the build path of the project in some way: for instance, you may remove or re-add the JUnit library from the project
4. MyClass.java disappears from the Project Explorer!
5. now click on the down-arrow in the top-right corner of the Project Explorer view, then Customize View... | Content and disable the "Enhanced Java Rendering for Web": the file will appear again in the Project Explorer
Comment 1 Mauro Molinari CLA 2011-11-23 09:37:34 EST
Created attachment 207420 [details]
Zipped project to reproduce the problem
Comment 2 Kris De Volder CLA 2011-11-23 12:56:14 EST
It's important to point out that, although the original problem in STS was reported with a .gradle (and so a groovy file). We have reproduced it with plain .java files.

Conditions necessary to trigger the bug seem to be the following:
 - WTP project
 - a 'java-like' file placed outside the project's classpath.
 - this file open in the editor.
 - a refresh of some kind causing the project explorer to update its contents.
 - "Enhanced Java Rendering for Web" content provider active

Hypothesis (not sure this is really what is happening, just my guess):

"Enhanced Java Rendering for Web" is removing the file from the view because it mistakenly believes it is on the classpath when it is open in the editor. Maybe this is due to some kind of interference by the Java editor having triggered a reconcile.
Comment 3 Mauro Molinari CLA 2012-08-31 03:31:49 EDT
Any news for this? It's very annoying when working with Gradle files...
Comment 4 Mauro Molinari CLA 2020-06-16 11:57:05 EDT
This still happens in 2019-12.