Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 174863 - A change in WTP 1.5.3 breaks o.e.tptp.platform.profile.server.wst.internal.ApplicationServerListener
Summary: A change in WTP 1.5.3 breaks o.e.tptp.platform.profile.server.wst.internal.Ap...
Status: CLOSED FIXED
Alias: None
Product: WTP ServerTools
Classification: WebTools
Component: wst.server (show other bugs)
Version: 1.5.3   Edit
Hardware: All All
: P3 critical (vote)
Target Milestone: 1.5.4 M154   Edit
Assignee: Tim deBoer CLA
QA Contact:
URL:
Whiteboard: PMC_approved
Keywords:
: 176180 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-02-20 15:59 EST by Larry Isaacs CLA
Modified: 2007-04-03 11:37 EDT (History)
5 users (show)

See Also:


Attachments
Stacktrace for breakpoint at getServers() call in ApplicationServerListener (4.10 KB, text/plain)
2007-02-21 13:21 EST, Larry Isaacs CLA
no flags Details
Patch for startup initialization (1.42 KB, patch)
2007-03-07 19:43 EST, Tim deBoer CLA
no flags Details | Diff
Patch for startup initialization 2 (836 bytes, patch)
2007-03-21 17:46 EDT, Tim deBoer CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Larry Isaacs CLA 2007-02-20 15:59:53 EST
I'm not sure I have the right component, but this is my best guess.  The symptom is that the "agent selection" dialog doesn't appear when starting servers, such as Tomcat, in profile mode if the server already exists when the Eclipse session is started.  Here are the steps to reproduce (I used Eclipse 3.2.2, WTP 1.5.3 and tptp.sdk-TPTP-4.3.1-200702191217.zip on WinXP):

1. Create a Tomcat runtime (I used Tomcat 5.5.20)
2. Create a Tomcat server for the runtime.
3. Double-click the server in the Servers view to open server editor.
4. In server editor, click Open launch configuration
5. Select the Environment tab and add a PATH environment variable that points to the org.eclipse.hyades.execution plug-in directory for the OS in use (I used ...\plugins\org.eclipse.hyades.execution.win32.x86_4.3.0.v200611140100)
6. Exit the launch configuration dialog
7. Start the server in profiling mode and no dialog appears to ask for agent, etc.

If you delete the server and repeat the above from step 2 without restarting Eclipse, the dialog will appear.  If you restart Eclipse, it stops appearing for this existing server.

The problem occurs due to changes for Bug 172382 that appear in WTP 1.5.3.  The ApplicationServerListener now gets called at the beginning of ServerCore initialization such that the ServerCore.getServers() call in the startup() method will return a zero length array.  As a result, the listener is not added to existing servers.  For fun, I modified startup() to enclose the existing code in a Job and scheduled it.  This seems to delay execution of this code to a time when ServerCore.getServers() will successfully return the existing servers.
Comment 1 Tim deBoer CLA 2007-02-20 16:35:20 EST
Unfortunately, this probably needs to be fixed in TPTP. Here's some background:
 * The server startup extension point is called during the initialization of the server core framework - the first time someone tries to use server API, not server plugin startup().

 * In this case it is trying to get access to the servers while that API is loading. Since there is no ordering on the extension point, it is ambiguous whether any servers have been loaded or will be created by the other extensions.

 * The worst bit is that this behaviour can cause plugin loading deadlock if anyone triggers this code path from within their plugin's startup(). For this reason we were forced to fix bug 172382 and block out this behaviour.

The easiest fix is to put the code into a Job so that it doesn't touch the API while in the startup method.
Comment 2 Tim deBoer CLA 2007-02-20 23:41:15 EST
Maybe I spoke too soon - I just took a look at the fix in 2.0, and it did go too far avoiding deadlock on bad API usage and caused valid calls to fail as well. However, I've started looking through 1.5.3 and I don't see the same problem yet. I'll keep looking tomorrow, but I don't see a path where getServers() could return before ResourceManager loadRuntimesList() and loadServersList() are called.
Comment 3 Tim deBoer CLA 2007-02-21 10:55:46 EST
I tried this myself (with my own sample, not TPTP), and I could not reproduce - getServers() returned the correct list. I'll grab TPTP and try again.

Larry - were you able to determine the codepath that caused this? I couldn't find a path in 1.5.3 where ResourceManager could be initialized without the server and runtimes list getting loaded.
Comment 4 Larry Isaacs CLA 2007-02-21 13:21:38 EST
Created attachment 59503 [details]
Stacktrace for breakpoint at getServers() call in ApplicationServerListener
Comment 5 Tim deBoer CLA 2007-02-21 16:10:37 EST
Ok, that's screwy. The startup is being called during plugin startup and initialization when other servers aren't loaded yet, so the result of getServers() is correct. However, since it is in the middle of startup it'll fail to get events when the existing servers are loaded. We should fix this in WTP 1.5.4 so that it is impossible to get the startup launched during this period, or so that the events at least get fired.
Comment 6 Larry Isaacs CLA 2007-02-21 17:52:04 EST
Should we still recommend that ApplicationServerListener use a Job so it will work with WTP 1.5.3?  It's a rather noticable regression for those using WTP 1.5.3.
Comment 7 David Williams CLA 2007-02-22 11:58:37 EST
Based on comments, I'm targeting to 1.5.4. 
Please re-target if I am incorrect. 
Comment 8 Tim deBoer CLA 2007-02-22 12:22:59 EST
David - Yes, that's correct. I could have sworn there was no 1.5.4 target when I moved the bug last. ;)

Larry - AFAIK all other Eclipse projects stopped their Eclipse 3.2 service streams after 3.2.2 a couple weeks ago. WTP is starting to plan a 1.5.4 so I can fix this, but I'm not aware of any TPTP service planned on this stream.

Eugene - Does TPTP still have a service release on this stream, so that you could also switch to using a Job?
Comment 9 Eugene Chan CLA 2007-02-26 13:35:48 EST
(In reply to comment #8)
Tim, there is no plan of TPTP on any more service release in the 3.2.2 stream as I know. TPTP has just got its 4.3.1 and 4.2.1.1 out which is built on 3.2.2 stream.

Comment 10 Tim deBoer CLA 2007-02-28 10:51:54 EST
Ok, we'll fix in WTP as soon as 1.5.4 builds start.
Comment 11 Larry Isaacs CLA 2007-03-06 09:53:55 EST
Just a note that a similar problem exists in WTP 2.0 as well.  The InitializeJob calls getServers(), which indirectly calls ResourceManager.executeStartups(), which indirectly calls getServers() recursively via ApplicationServerListener.startup().  Currently a NPE gets thrown because executeStartups() is called before the ResourceManager.servers field is initialized.

Tim, let me know if you would like a separate bug for tracking WTP 2.0 changes.
Comment 12 Tim deBoer CLA 2007-03-06 10:56:12 EST
The 2.0 problem should already be fixed in M6 via bug 174886.
Comment 13 Larry Isaacs CLA 2007-03-06 11:02:29 EST
Yep, that's what I saw using WTP 2.0M5. Thanks.
Comment 14 Tim deBoer CLA 2007-03-07 19:43:43 EST
Created attachment 60405 [details]
Patch for startup initialization
Comment 15 Tim deBoer CLA 2007-03-07 19:45:30 EST
Raising for PMC approval for 1.5.4 since this is a regression in behaviour that breaks TPTP.

Patch attached - Larry (or Eugene), any chance you can try it as well? I believe the safest fix is just to initialize the resource manager first (which will load existing servers before calling the startups), which is equivalent to the behaviour in 1.5.2 or 2.0.
Comment 16 Larry Isaacs CLA 2007-03-08 09:24:41 EST
Unfortunately, this doesn't help. :(  Per the attached stacktrace, ApplicationServerListener.startup() is being executed within the context of initializing the ResourceManager.  The added getResourceManager() call simply returns the already set, but still initializing, instance.
Comment 17 David Williams CLA 2007-03-13 22:20:03 EDT
-1
Given Larry's comment or test, I'm assuming this one needs more work and needs to be resubmitted? (Thanks Larry). 

Comment 18 Tim deBoer CLA 2007-03-18 09:13:46 EDT
Sorry, I didn't take a close enough look at the stack trace. I'll submit a new patch soon, and in the meantime I'll retract from PMC voting.
Comment 19 Tim deBoer CLA 2007-03-21 17:46:58 EDT
Created attachment 61612 [details]
Patch for startup initialization 2

Second patch, replaces the first.
Comment 20 Tim deBoer CLA 2007-03-21 17:50:28 EDT
Corrected patch ready, raising for PMC approval again.
Comment 21 David Williams CLA 2007-03-22 02:15:10 EDT
+1 
And looking forward to Larry's technical assessment/test :) 
Comment 22 Larry Isaacs CLA 2007-03-22 08:44:08 EDT
I've tested the second patch and it works for me too.  The patch reorders the execution of things so that ApplicationServerListener sees the existing servers.  The startup for the wst.server.ui plug-in is still a bit "heavy", but it's probably not practical to address that in WTP 1.5.4.
Comment 23 Eugene Chan CLA 2007-03-22 20:12:08 EDT
*** Bug 176180 has been marked as a duplicate of this bug. ***
Comment 24 Neil Hauge CLA 2007-03-23 15:58:29 EDT
+1
Assumes adequate testing to ensure no regressions occur as a result of this fix.
Comment 25 Tim deBoer CLA 2007-04-01 18:11:08 EDT
Patch released to 1.5.4.
Comment 26 Larry Isaacs CLA 2007-04-03 09:49:59 EDT
Verified that the "agent selection" dialog now appears for existing Tomcat servers using wtp-sdk-M-1.5.4-200704012359.zip.
Comment 27 John Lanuti CLA 2007-04-03 11:37:46 EDT
Closing as verified.