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.
Build 200504171930 1) Open 4.0 Web project 2) project's context menu | Resolve missing reference 3) Upgrade project 4) ERROR: Broken reference window doesn't appear. NPE is thrown (see attachment)
Created attachment 21700 [details] java.lang.NullPointerException at org.netbeans.modules.web.project.UpdateHelper.saveUpdate(UpdateHelper.java:302)
Any library, project or JAR file (which were on the 4.0 project's classpath) are not packaged into WAR file until you modify project's Properties. Although they are part of the build/clean targets.
After creating test directory in 4.0 project structure, there are still no default Compile/Tun Tests classpath items in project's properties. I think it is a consequence of this NPE. If not, I'll file a new issue.
The "updateListener" is supposed to remove servlet api and jsp api libraries. How is it ensured that WebProjectProperties are created before this is called?? I think this code relied on WebProject creating WPP when open, which was removed because it caused performance problems. That would explain the regression -- is it know when this last worked? Anyway, there is code in UpdateHelper that seems to remove these libraries. I am testing with 40 project and it works ok, so I removed the problematic (and seemingly useless) code. But it is strange that the code that removes the libraries in WPP was added in the same version as the code in UpdateHelper that does this so maybe I am missing something. Adding Marek to comment. Checking in src/org/netbeans/modules/web/project/UpdateHelper.java; /cvs/web/project/src/org/netbeans/modules/web/project/UpdateHelper.java,v <-- UpdateHelper.java new revision: 1.15; previous revision: 1.14 done Checking in src/org/netbeans/modules/web/project/ui/customizer/WebProjectProperties.java; /cvs/web/project/src/org/netbeans/modules/web/project/ui/customizer/WebProjectProperties.java,v <-- WebProjectProperties.java new revision: 1.91; previous revision: 1.90 done
The code wasn't useless :-). It handles a situation when an user opens a 4.0 project, opens project properties, do some changes and then close the dialog. In such a case the WebProjectProperties caches the libraries data in a memory model and then, when user closes the dialog and confirms project upgrade, it saves the data from memory and rewrites the updated ones. It is possible that there is a much more elegant solution to this problem than the "updateListener" hack, but it works. As Pavel correctly pointed out the problem is that when WebProjectProperties instance is not created and the UpdateHelper is asked to upgrade project, then the "updateListener" is not registered and hence the code throws the reported NPE. IMO the minimal sufficient fix is to check the listener not to be null. Steps to reproduce the problem with not removed libraries after Pavel's commit: 1) open a 4.0 project => broken references warning dialog appears 2) close it 3) open project properties and go to libraries 4) close the project props. dialog => project upgrade dialog appears 5) choose upgrade project => servlet24 and jsp20 libraries are not removed
The regression came in time 0321-0328 - I suspect issue 56844 fix.
reverted Pavel's commit and fixed Checking in src/org/netbeans/modules/web/project/UpdateHelper.java; /cvs/web/project/src/org/netbeans/modules/web/project/UpdateHelper.java,v <-- UpdateHelper.java new revision: 1.16; previous revision: 1.15 done Checking in src/org/netbeans/modules/web/project/ui/customizer/WebProjectProperties.java; /cvs/web/project/src/org/netbeans/modules/web/project/ui/customizer/WebProjectProperties.java,v <-- WebProjectProperties.java new revision: 1.92; previous revision: 1.91 done cvs diff -r1.14 UpdateHelper.java Index: UpdateHelper.java =================================================================== RCS file: /cvs/web/project/src/org/netbeans/modules/web/project/UpdateHelper.java,v retrieving revision 1.14 retrieving revision 1.16 diff -u -r1.14 -r1.16 --- UpdateHelper.java 25 Mar 2005 09:59:46 -0000 1.14 +++ UpdateHelper.java 19 Apr 2005 08:00:16 -0000 1.16 @@ -299,7 +299,7 @@ } //fire project updated - projectUpdateListener.projectUpdated(); + if(projectUpdateListener != null) projectUpdateListener.projectUpdated(); //create conf dir if doesn't exist and copy default manifest inside try { @@ -473,7 +473,7 @@ public boolean canUpdate (); } - private ProjectUpdateListener projectUpdateListener; + private ProjectUpdateListener projectUpdateListener = null; public void setProjectUpdateListener(ProjectUpdateListener l) { this.projectUpdateListener = l;
Yes Karle, the regression was caused by Issue #56844 for sure. As Pavel wrote, the "updateListener" wasn't initialized when resolving broken references and hence the code thrown the NPE. It is fixed now.
I agree with the fix. Thanks for correcting me, Marku.
fixed in release41 branch Checking in src/org/netbeans/modules/web/project/UpdateHelper.java; /cvs/web/project/src/org/netbeans/modules/web/project/UpdateHelper.java,v <-- UpdateHelper.java new revision: 1.14.2.1; previous revision: 1.14 done
The second fix was verified in trunk by QE.
Verified in release41 branch too.