This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 59057 - fix imports deletes jar imports
Summary: fix imports deletes jar imports
Status: CLOSED DUPLICATE of bug 59031
Alias: None
Product: editor
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 4.x
Hardware: All All
: P2 blocker (vote)
Assignee: issues@editor
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-19 12:04 UTC by loki
Modified: 2007-11-05 13:44 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
build file (2.06 KB, text/xml)
2005-06-07 12:24 UTC, loki
Details
sample java code (3.43 KB, text/plain)
2005-06-07 12:28 UTC, loki
Details
sample jsp (8.62 KB, text/plain)
2005-06-07 12:30 UTC, loki
Details

Note You need to log in before you can comment on or make changes to this bug.
Description loki 2005-05-19 12:04:45 UTC
All imports that are not part of the projects source tree get deleted when I run
'fix imports'. When i started this editing session it worked. Since the last
time it worked i edited a JSP file and run a 'ctr shift F' (format) command on
it. I used JDK 1.5.0.03 netbeans 1.4 on a Suse Linux 9.2 installation. 

I am now going to delete my user setttings to see if that resolves the problem.
cheers,
Aad
Comment 1 loki 2005-05-19 12:11:00 UTC
I have deleted my .netbeans/nb4.1 settings and after restart of Netbeans all
worked fine again (I guess that means we have a workaround). If I can make the
behavior repeatable I will report back.
Comment 2 loki 2005-05-19 12:29:07 UTC
Just did a second test: It is repeatable.

Every time after I have opened a JSP the 'fix import' setting refuses to work
correctly. All imports that are not directly related to the source tree of the
project that I am working on are deleted.

One more detail: I store my .class and .java file in the same folder structure.
Comment 3 loki 2005-05-19 13:14:28 UTC
This issue seems to have more side effects. The code completion in Java also
fails for such ordinary things as the java.lang.Class API.
Comment 4 loki 2005-05-23 09:14:27 UTC
Mmm, the problem is becoming more pressing. Even after deleting the 4.1
subdirectory the problem stays. If this problems persists I may have to
downgrade since it slows creating new code considerably.
Comment 5 Jiri Kovalsky 2005-05-25 12:54:24 UTC
Hm, this is strange. I tried to reproduce this behaviour with NetBeans 4.1
(build #200505031930), JDK 1.5.0_03 (build #6) but on Windows XP and it works
fine for me. I used web application project type. Here is what I did:

1. Using "Add JAR/Folder..." on Libraries node added my own JAR to the web project.
2. Opened index.jsp and pressed CTRL+Shift+F to reformat the page.
3. Created new Java Class and used some class there from my JAR. Auto-completion
auto-imported the class.
4. Right clicked editor area and selected "Fix Imports" from popup menu. Nothing
changed - import statement survived.

What is exact build number of NetBeans 4.1 you are using ? It reminds me of my
older issue #56161.
Comment 6 loki 2005-05-25 14:49:21 UTC
Mmm,

My jar files were added by using the project (from the project view)
right-click, properties, in javasources I added the jars (is that equivalent? or
should I add all jars there as well?) Other than that all your steps are the
same ones i took.

About the build: Linux 2.6.8-24.10-default
IDE version: IDE/1 spec-5.9.1.impl-200505031930 
Product version Netbeans 4.1. (build 200505031930)

All the other info seems pretty much the same. On the nbusers forum some
equivalent remarks about 'losing' the jar info seems to occur.

Some other details:

- classes and java files are stored in same directories (don't ask)
- we use CVS 

can't think of too many other things. If you would like to explore my userdir or
have more questions feel free to drop me a line.

cheers,
Aad
Comment 7 Roman Strobl 2005-06-06 12:57:09 UTC
I am also not able to reproduce the issue. How do you store your .java and
.class files in the same directory - do you use a special build script? Did you
encounter the issue also outside JSP editor (e.g. when editing a java file)? Thanks.
Comment 8 loki 2005-06-06 13:23:06 UTC
The .java and .class files are stored in the same directory tree (about 900
classes). We use a ant based build script. 

The problem occurs in the __JAVA EDITOR__. Here is how I can reproduce it at will:

0. stop netbeans
1. delete all user settings in .netbeans/4.1 
2. restart netbeans
3. 're-attach' the project by selecting it and setting the build file
4. open a .java file and everything works great (including completion and fix
imports)
5. open a jsp file, add a space, delete it, save it
6. go to the same .java file (or open another one) run fix imports and see how
all imports where the java code is not part of your project (e.g. java.util.Map)
are deleted.

6a. try code completion. Nothing works unless it is part of your project.

if you e-mail me a phone number aad at nales.com I am more than willing to give
you a call so that you can ask about the specifics.

We all (4) people work with the same setup and we all experience exactly the
same problems. Since this problem is extremely annoying but since I am already
addicted to the other 4.1. features and I am more than willing to spend time on
fixing this. 

cheers,
Aad
6. go to the same .java file 
Comment 9 Jiri Kovalsky 2005-06-07 11:49:10 UTC
I've spent 2 hours trying to reproduce this problem but without any success. I
used all 3 project types: standard, with own sources and with own build script.
The only way how I was able to reproduce items 6 and 6a was to screw up my build
script or its properties file. This way "Fix Imports" removed all imports and
code completion didn't work but it also resulted in impossibility to build the
project.

So now I have two questions for you:
[1] If this happens, can you really "Clean and Build" the project successfully ?
(I know it's kind of dumb question :-|
[2] Would it be possible to share your project with us ? At least project
metadata (build script and properties file) plus at least fragment of one Java file.

From what I've seen my humble conclusion is that it could be rather problem of
projects than both Java/JSP editors.
Comment 10 loki 2005-06-07 12:21:38 UTC
First your questions:

1. Yes it builds beautifully without a glitch it runs, it starts it stops no
problem what so ever.

2. No problem either, I will upload the build.xml and build.properties. (I will
do that now). Then if you tell me how you would like to get the java sources (do
you want the libs and all as well?) It is an Open Source project so I am OK with
giving you all the source if necessary. 


Comment 11 loki 2005-06-07 12:24:41 UTC
Created attachment 22518 [details]
build file
Comment 12 loki 2005-06-07 12:28:45 UTC
Created attachment 22519 [details]
sample java code
Comment 13 loki 2005-06-07 12:30:31 UTC
Created attachment 22521 [details]
sample jsp
Comment 14 loki 2005-06-07 12:32:54 UTC
Uh, 

I promised too much with the build.properties we don't use one since we only
work on Linux.
Comment 15 Roman Strobl 2005-06-07 12:57:32 UTC
Seems to be a duplicate of issue 59031. Can you zip the nbproject directory and
attach it to the issue? You can try the binary patch attached to 59031 (called
59031.jar, see the end of issue 59031). Thanks and let us know if it helps.
Comment 16 loki 2005-06-07 13:30:05 UTC
The patch works fine for the java code however I now have the same problem
asleson is reporting. The jsp files no longer show up!. But what ever 59031.jar
did to fix the problem is definitely on the right track. I am happy to accept
that is a duplicate of 59031.

I hope a fix will be available soon since I have the same problem as said gentleman.

*** This issue has been marked as a duplicate of 59031 ***
Comment 17 Jiri Kovalsky 2005-06-07 13:36:49 UTC
Thanks for confirmation. Verifying as duplicate issue then ...