This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 205445 - NPE when creating XDoclet Servlet
Summary: NPE when creating XDoclet Servlet
Status: CLOSED FIXED
Alias: None
Product: WTP EJB Tools
Classification: WebTools
Component: jst.ejb (show other bugs)
Version: 2.0.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 2.0.2 M202   Edit
Assignee: Kaloyan Raev CLA
QA Contact: Naci Dai CLA
URL:
Whiteboard:
Keywords:
: 158570 163673 167643 169896 170952 192503 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-10-04 10:36 EDT by Kaloyan Raev CLA
Modified: 2008-05-12 09:13 EDT (History)
8 users (show)

See Also:


Attachments
.log (5.78 KB, text/plain)
2007-10-04 10:36 EDT, Kaloyan Raev CLA
no flags Details
Add a null check- if the parameter is null, return null. (1.03 KB, patch)
2007-10-05 15:16 EDT, Carl Anderson CLA
no flags Details | Diff
.log #2 (5.39 KB, text/plain)
2007-10-12 05:10 EDT, Kaloyan Raev CLA
no flags Details
patch (1.18 KB, patch)
2007-12-06 15:17 EST, Kaloyan Raev CLA
no flags Details | Diff
patch 2 (1.06 KB, patch)
2007-12-11 07:33 EST, Kaloyan Raev CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kaloyan Raev CLA 2007-10-04 10:36:01 EDT
Created attachment 79726 [details]
.log

Driver: M-2.0.2-20071004053715

1. Start Eclipse in a new workspace. 
2. Open the Error view.
3. Execute the "Create a Web 2.4 project" step from the smoke test scenario:
http://wiki.eclipse.org/J2EE_Smoke_Test_%28WTP_2.0%29#Create_a_Web_2.4_project
(Mind the prerequisites)

It should be, when the XDoclet builder executes, a NullPointerException is logged. 
The .log is attached. 

There is no visual consequences from this error.
Comment 1 Carl Anderson CLA 2007-10-05 09:43:41 EDT
JEM bug- getJavaProject should return null if the parameter is null, instead of throwing an NPE.
Comment 2 Carl Anderson CLA 2007-10-05 15:16:24 EDT
Created attachment 79828 [details]
Add a null check- if the parameter is null, return null.
Comment 3 Carl Anderson CLA 2007-10-05 15:57:18 EDT
Committed to both 2.0.2 and 3.0.
Comment 4 Kaloyan Raev CLA 2007-10-12 05:08:55 EDT
Hi Carl, 

You have indeed fixed the described the described NPE, but now another one appears. 
I reopen this bug, because the symptoms are the same. 

Greetings,
Kaloyan
Comment 5 Kaloyan Raev CLA 2007-10-12 05:10:49 EDT
Created attachment 80206 [details]
.log #2

.log with the new NullPointerException
Comment 6 Carl Anderson CLA 2007-10-16 14:52:21 EDT
The next NPE is in the XDoclet code.
Comment 7 Kaloyan Raev CLA 2007-12-06 15:13:17 EST
This bug was actually introduced by the org.eclipse.ui.workbench plugin - probably when solving bug 73872. 

Steps to reproduce: 
1. Start Eclipse with the WTP plugins in a new workspace. 
2. Open the Error view. 
3. Create a new Dynamic Web 2.4 Project with the XDoclet facet enabled. 
4. Right-click on the newly created project. 

The NPE appears in the console log. 

The reason for the NPE is because org.eclipse.jst.j2ee.ejb.annotations.internal.xdoclet.action.XDocletActionDelegate (plugin org.eclipse.jst.j2ee.ejb.annotations.xdoclet) receives in method selectionChanged(IAction, ISelection):58 an empty selection as an argument. But in fact there is a real selection, because the user has right clicked on the project.

Digging on the stack trace: 

Thread [main] (Suspended (breakpoint at line 70 in XDocletActionDelegate))	
	RunXDocletAction(XDocletActionDelegate).getFirstSourceFile() line: 70	
	RunXDocletAction.selectionChanged(IAction, ISelection) line: 60	
	<unknown receiving type>(PluginAction).refreshEnablement() line: 208	
	<unknown receiving type>(PluginAction).createDelegate() line: 128	
	<unknown receiving type>(PluginAction).selectionChanged(ISelection) line: 277	
	<unknown receiving type>(PluginAction).<init>(IConfigurationElement, String, int) line: 112	
.......

It turns out that in PluginAction constructor on line 112 there is a call:

     selectionChanged(StructuredSelection.EMPTY);

The problem would be solved that if the above is replaced with a call to "selectionChanged()" with the current selection. 
Comment 8 Kaloyan Raev CLA 2007-12-06 15:17:40 EST
Created attachment 84663 [details]
patch

I attach a patch with the suggested solution described in the previous comment. This patch solves the issue for WTP.
Comment 9 Paul Webster CLA 2007-12-06 15:30:54 EST
This patch cannot be accepted as is ... it is valid for selectionChanged(*) to be called with EMPTY_SELECTION, you *must* handle it.

PW
Comment 10 Kaloyan Raev CLA 2007-12-11 07:33:56 EST
Created attachment 84949 [details]
patch 2

Resolves the NPE in the o.e.j.j2ee.ejb.annotations.xdoclet plugin.
Comment 11 Kaloyan Raev CLA 2007-12-11 07:40:32 EST
patch 2 is dropped to HEAD. 

The o.e.j.j2ee.ejb.annotations.xdoclet plugin is not branched, so the patch goes in both 2.0.2 and 3.0. 
Comment 12 Kaloyan Raev CLA 2007-12-27 12:46:17 EST
Verified with the S-3.0M4-20071227065330 build. 
Comment 13 Kaloyan Raev CLA 2008-01-31 11:44:06 EST
Verified with the M-2.0.2-20080131091038 build, too. 
Comment 14 Kaloyan Raev CLA 2008-04-14 07:10:11 EDT
*** Bug 158570 has been marked as a duplicate of this bug. ***
Comment 15 Kaloyan Raev CLA 2008-04-14 07:17:44 EDT
*** Bug 163673 has been marked as a duplicate of this bug. ***
Comment 16 Kaloyan Raev CLA 2008-04-14 07:19:23 EDT
*** Bug 167643 has been marked as a duplicate of this bug. ***
Comment 17 Kaloyan Raev CLA 2008-04-14 07:42:19 EDT
*** Bug 169896 has been marked as a duplicate of this bug. ***
Comment 18 Kaloyan Raev CLA 2008-04-14 08:02:07 EDT
*** Bug 170952 has been marked as a duplicate of this bug. ***
Comment 19 Kaloyan Raev CLA 2008-04-14 10:47:48 EDT
*** Bug 192503 has been marked as a duplicate of this bug. ***
Comment 20 Kaloyan Raev CLA 2008-05-12 09:13:14 EDT
Closing