This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 206810 - NPE during Java EE smoke test
Summary: NPE during Java EE smoke test
Status: CLOSED FIXED
Alias: None
Product: WTP ServerTools
Classification: WebTools
Component: jst.server (show other bugs)
Version: 2.0.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0 M5   Edit
Assignee: Gorkem Ercan CLA
QA Contact: Tim deBoer CLA
URL:
Whiteboard:
Keywords:
: 210281 217353 223498 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-10-18 15:06 EDT by Kaloyan Raev CLA
Modified: 2017-10-11 16:21 EDT (History)
5 users (show)

See Also:


Attachments
exception (5.66 KB, text/plain)
2007-10-18 15:06 EDT, Kaloyan Raev CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kaloyan Raev CLA 2007-10-18 15:06:25 EDT
Created attachment 80689 [details]
exception

The NullPointerException was logged in the error log during the execution of the Java EE smoke test scenario on WTP 2.0.2: 
http://wiki.eclipse.org/J2EE_Smoke_Test_%28WTP_2.0%29

Unfortunately, I cannot say when exactly the error was logged. I guess, it was on the step where I run the servlet or jsp on the server. 

I used JBoss v4.2 a server. 

The NPE happened only once and I haven't noticed any negative effect of it.
Comment 1 Tim deBoer CLA 2007-10-18 15:18:47 EDT
Yup, I think this is a known (dup) issue when the New Server wizard appears. AFAIK exception does not cause runtime problem.
Comment 2 Gorkem Ercan CLA 2007-11-19 14:20:44 EST
*** Bug 210281 has been marked as a duplicate of this bug. ***
Comment 3 Kaloyan Raev CLA 2008-01-31 15:35:47 EST
The NPE seems to be fixed in the latest 2.0.2 and 3.0 M5 drivers that I have just smoketested. 

Have you done any code changes, related to this?
Comment 4 Konstantin Komissarchik CLA 2008-02-04 10:04:39 EST
Not fixed. We just hit this while testing 2.0.2 RC1? Any chance of a fix for 2.0.2?
Comment 5 Gorkem Ercan CLA 2008-02-04 16:05:12 EST
When a server is created  ServerWorkingCopy is initialized with a runtime if hasRuntime() returns true. Generic server assumes that there will always be a runtime. When a server is created through NewRuntimeComposite it conforms to the expected behavior. But there is a second path for Server creation ServerCreationCache and when a server is created through that ServerWorkingCopy is never initialized with its runtime and this is causing the NPE in some cases. 
Tim can you comment is there really a case where a server can be created without a runtime(if it requires one), or is this simply a mistake?
Comment 6 Tim deBoer CLA 2008-02-04 23:06:19 EST
Found it. In this case it is creating the server first, then creating and setting the runtime and calling setDefaults() again. I can probably get the runtime created first and then create the server, but since I can't also create and import a configuration if it's needed, there's always going to be a case where something is set after the call to create() and setDefaults() needs to be called again.

In short - I can improve this case, but setDefaults() should also handle cases where the server isn't complete yet, or where the runtime or configuration was invalid, etc. I think we should both fix this.
Comment 7 Gorkem Ercan CLA 2008-02-05 14:41:04 EST
I am trying to improve it as well, as generic servers do not support configuration that will not be a problem. But the defaults depend on the runtime type. 
Comment 8 Tim deBoer CLA 2008-02-06 09:29:56 EST
I have just released a change that should create the runtime first, so it is set the first time setDefaults() is called. It'll still be called twice, but it should avoid the NPE.

Gorkem - This change alone should fix it, but just putting in a null check would have worked (or will provide double protection) too. 
Comment 9 Gorkem Ercan CLA 2008-02-06 17:15:29 EST
*** Bug 217353 has been marked as a duplicate of this bug. ***
Comment 10 Gorkem Ercan CLA 2008-02-06 17:41:02 EST
I am adding the null check that is easy but the impact can be quite large. GenericServer.getServerDefinition() is used throughout the generic server plugins and it is one of the basic APIs. Until now It was assumed that GenericServer can always determine the associated .serverdef file and therefore the API was assumed to always return a value. The lack of runtime of course makes creates the situation where GenericServer.getServerDefinition() can return null. The ideal is now to go over all the places where the API is used and try to adjust for this new behavior. Do you think it is safe to assume that only when called from setDefaults() runtime can be null. 
Comment 11 Tim deBoer CLA 2008-02-06 17:47:54 EST
Yes... except that of course any user could inadvertently delete their runtime, check a server out of source control without one, etc. We don't need to address it   in this bug, but to be fully robust we should assume that anything could be invalid and handle nulls appropriately, where 'appropriate' might still be to throw an exception or log the problem.
Comment 12 Gorkem Ercan CLA 2008-02-17 16:24:11 EST
I have made changes to detect the null and fall back. Released to the HEAD. 
Comment 13 Kaloyan Raev CLA 2008-02-21 13:16:51 EST
This is still a valid bug in 2.0.2 RC3. It seems that it is fixed only in the 3.0 stream.

Was the intention to fix it in 2.0.2, too? If yes, then we should reopen the bug. Otherwise, retarget it to 3.0.
Comment 14 Konstantin Komissarchik CLA 2008-03-20 12:38:53 EDT
Re-opening, since it is unclear whether this fix was ever integrated into 2.0.2?
Comment 15 Gorkem Ercan CLA 2008-03-23 10:06:32 EDT
*** Bug 223498 has been marked as a duplicate of this bug. ***
Comment 16 Gorkem Ercan CLA 2008-03-23 10:10:29 EDT
My changes are in 3.0 stream only., Tim, If your changes will not go to 2.0.2 I will retarget this for 3.0.
Comment 17 Tim deBoer CLA 2008-03-24 08:51:20 EDT
My changes were in 3.0 stream only as well, so changing target to 3.0. Unless I'm missing something, there should be no need to backport either change to the 2.0 stream since this is just an unnecessary .log message that's been there since <2.0.
Comment 18 Tim deBoer CLA 2008-06-13 10:48:54 EDT
Closing bugs that have been fixed for several months without owner verification. Bugs that did not involve external user/adopter scenarios have been verified in WTP. We are about to release WTP 3.0, please feel free to reopen if you have any further problems.
Comment 19 Eclipse Genie CLA 2017-10-11 16:20:41 EDT
New Gerrit change created: https://git.eclipse.org/r/108521
Comment 20 Eclipse Genie CLA 2017-10-11 16:21:14 EDT
New Gerrit change created: https://git.eclipse.org/r/108536