Stack Traces for Bug 244862 – WTP

April 12, 2009

After I recieved the email from Peter Liu who mentioned Tahereh’s working bug 244862, I take a quick look. I followed Davoud’s introduction to reproduce it. I catch several stack traces for the bug 244862 in different scenarios even though I don’t what we can do to fix the bug. Anyway I posted them so that other students may get some hints from the stack traces.

Stack Trace for creating a server

Stack trace for creating a server

Stack trace for creating a server

Stack Trace for Starting a server without any Started server

Stack stack for starting a server when there no started server

Stack stack for starting a server when there no started server

Stack Trace for Starting a Server with a Started Server

Stack Trace for starting server, publishing the server is failed

Stack Trace for starting server, publishing the server is failed

Stack Trace for Deleting Server Project from Package Explore

Delete the server project from package explore

Delete the server project from package explore

Stack Trace for Deleting Server from Server View
bug244862_deleteserver3


How does “Run as->Run configurations” work

April 6, 2009

As I tried to investigate the bug 137822 which is related to the server configuration, I got some idea about how the server configuration works. Anyway I posted some of my findings so that some other students may get some help from my findings to fix some other server related bugs (there are still some server-related bugs need to be fixed in the bug list.).

After Clicking the “Run -> Run Configurations”, the following steps are invoked:

  1. The configuration dialog is opened
  2. The content of the configuration dialog is created and filled with all the controls and actions .

    • Create the Viewer area with the event control and action
    • Create the Edit area with the event control, created the tab, filled the server combo from the tomcat server list in the server view
    • Initialize the values including the arguments in the tabs
    • Display the Run Configurations Dialog and be ready to catch any event including mouse and key activities
  3. Catch the Double Click event/ New_configuration action/Selected Item Change event, fire the actions
  4. Create instances including wc with a unique name such as “New configuration(1)”, configuration dialog and the group tabs, initialize the tab content.
  5. write the new configuration information to a file and update launch manager with the new configuration.
  6. Display the updated configuration dialog

Bug 137822 is fixed :)

April 4, 2009

It’s very happy to know that my fellow Le fixed the bug 137822 based on my posting. see Le’s post.

Anyway, I list some important classes and methods which related to the bug and web server. Some other person who worked on the web server tool may get some help or hint from my investigation.

  1. org.eclipse.debug.internal.ui.launchConfigurations is a important package in the plugin.

    • CreateLaunchConfigurationAction.performAction() — create wc with the unique name “New_Configuration(1)”,configuration dialog with all the tabs, set the default configuration for the dialog to be the new created wc .
    • LaunchConfigurationView.handleConfigurationAdded()
    • createLaunchConfigurationSelectionArea()
      (handler double click, display a tree of launch configurations that may select, and allow to create new configurations and delete, duplicate existing configuration)
    • LaunchConfigurationTabGroupViewer — create a viewer to display tabs for a launch configuration with Apply and Revert button.
    • LaunchConfigurationDialog (line 423(create),1055(open))
      create the launch configuration dialog
    • LaunchConfigurationTabGroupViewer.inputChanged
    • .LaunchConfigurationDialog (line 543) — catch selectionEvent, then call handleConfigurationAdded()
  2. org.eclipse.wst.server.ui.ServerLaunchConfigurationTab.performApply()
    (will get the server configuration “Tomcat 6.0”)
  3. org.eclipse.wst.server.core.internal.Server.getLaunchConfiguration(bool,IProgress) — bool is true, will create a new server.
  4. org.eclipse.jst.server.tomcat.core.internal.TomcatServerBehaviour.
    setLaunchConfiguration ILaunchConfigurationWorkingCopy workingCopy, IProgressMonitor monitor) (set the tomcat arguments for the VM and Program)
  5. org.eclipse.debug.internal.core.LaunchManager.run() — catch Add, then launch fListener.launchConfigurationAdded(fConfiguration)
  6. org.eclipse.swt.Display.runDerredEvents() –Always called by Display to get any event including selection, mousedown etc.
  7. org.eclipse.jface.util.OpenStrategy.handlerEvent — catch all the event, mouseup,mousedown, etc. then call function
    . Keydown may invoke fireOpenEvent(new SelectionEvent(e))
    .Selection may invoke fireSelectionEvent(event); then may invoke firePostSelectionEvent(new SelectionEvent(e))

A little progress – bug 137822

April 3, 2009

Today I add following code to the line 132 of org.eclipse..server.ui.ServerLaunchConfigurationTab(), then I am able to get the arguments and run the server without exception.

try{
server2.getLaunchConfiguration(true, null);
}catch(Exception ex){}

However, there are two Apach Servers created when I click the new once.
bug137822-two-servers1

Because a new server instance will be created by using the name “Tomcat v6.0 Server at localhost” in the method server.getLauchConfiguration(true,null). So there is a problem to use server.getLauchConfiguration(true,null) to get the configuration.


A summary of investigation – bug 137822

April 2, 2009

I felt I was lost in the forest of the code when I try to use debug again and again. Anyway I write down I already knew on this blog to give a summary of my job. It may be easier to get a hint from somebody who stands out of the forest.

According to the suggestion from Larry Isaacs’s answer dated on March 16 of newsgroup( http://www.eclipse.org/newsportal/thread.php?group=eclipse.webtools&first=101&last=150 ). I copied the arguments from “Open launch configuration” link to the empty text area of “Run -> Run Configurations -> Apache Tomcat -> New -> Argument”, then click “Apply” button and “Run”, the server can run without any exception. Based on Larry’s suggestion and my investigation, there are four possible solutions about bug 137822:

1. When we new a tomcate server, the system set some default value for Program
and VM at the same time.
2. When we click the dropdown list and select one server, then click button
“apply”, the values are set at that time.
3. The system didn’t set values by using the above ways. When we click button
“run”, if the system can’t get any run time arguments, it just pop-ups a dialog
to say no available server rather than throwing a exception.
4. If the Program and VM arguments are empty, just disable the button “run”.

In order to investigate the bug, I found the related the class and method with the above solutions:
1.
1.1 If “Run -> Run Configurations -> Apache Tomcat” is empty, then the method public void setDefaults(ILaunchConfigurationWorkingCopy configuration) of org.eclipse.wst.server.ui.ServerLaunchConfigurationTab.java will be invoked first.
Those line of code is supposed to get the first server from the server combox and set the default sever; however, at this point, no server is selected and no server configuration is set.
1.2 If “Run -> Run Configurations -> Apache Tomcat” is not empty, when click the a server, then method public void createControl(Composite parent) of org.eclipse.wst.server.ui.ServerLaunchConfigurationTab.java will be invoked. This method will created the server combox of Run configurations.

2. the apply button will invoke the method performApply() which in the package org.eclipse.wst.server.ui.ServerLaunchConfigurationTab.

Based on Larry Isaacs’s suggestion (newsgroup dated on april 4), solution 3 and 4 only hidden the problem. So we should get rid of them.


two ways to get stack trace — WTP

March 31, 2009

Ways to get the stack trace:
1. Set some break points on the source code. run it in debug mode. Once the break point was hit, right click Thread then click copy stack, then paste on any editor (such as notepad);
2. If there are some exception when running WTP, then go to Window-> Show View -> Other -> General -> Error log, then go the Error log view and double click any the error.


The package which I checked out-bug137822

March 27, 2009

I checked out several packages for bug 137822:

org.eclipse.jst.server.tomcat.core,
org.eclipse.wst.server.core,
org.eclipse.wst.server.ui

I think it’s a good start to reproduce them and take a look my stack trace first. I hope we can fix this bug together.


WTP-bug 137822 Get the execution path

March 25, 2009

Two different execution paths by running the server in two different ways

=========
From previous comments, we know that the program is executed in two different way for step 1 and step 2, so that the arguments for the Program and VM are set in two different ways. The arguments for Program and VM in step 2 are set properly; however The arguments for Program and VM in step 1 are not set at all. As Tim deBoer said that somewhere the program should call the method setupLaunchConfiguration() to set the arguments. In order to get the execute path by looking at the exception stack Trace I do following things:

1. Created an exception (int i = Integer.parseInt(“my exception”);)
2. Add this exception code in the line 226 of  org.eclipse.wst.server.ui.ServerLaunchConfigurationTab.setDefaults(ILaunchConfigurationWorkingCopy) for step 1;
3. Run the server by Click/Run as –> Run Configuration, then check the Error Log and get the Exception Stack Trace:
Bug 137822 exception stack
bug137822_exception
4. Add this exception code in the line 771 of org.eclipse.jst.server.tomcat.core.internal.TomcatServerBehaviour.setupLaunchConfiguration(ILaunchConfigurationWorkingCopy, IProgressMonitor) for step 2
5. Open the server configuration dialog from the server view and click the link “Open launch configuration” , then check the Error Log and get the Exception Stack Trace:
Bug 137822 regular stack
bug137822_regular

By looking at the stack trace, I found some code in org.eclipse.wst.server.ui.ServerLaunchConfigurationTab.setDefaults() such as :
line 217: if (servers != null) {
server = servers.get(serverCombo.getSelectionIndex());
if (server != null)
((Server) server).setupLaunchConfiguration(configuration, null);
However, the server is null and the configuration is null, that’s why it’s impossible to set the LaunchConfiguration stuff.

As we can see, the rest methods in the stack are in a jar file, and I can make any change in the jar file code. Someone knows how to add some code in a jar file?


More information about the bug 137822

March 16, 2009

With the help from Larry Isaacs in newsgroup, I realize I go in wrong direction. Before I thought first of all, I should find the code which throw the exception. Then I followed the hint and I should be able to find the supposed value for all some variables. Now I knew that I was far away from my way.

Larry Isaacs explained the reason why the server throw the exception in such condition. I reproduced it and displayed the reason here according to Larry Isaacs.

1. When I new a server, and right click and open the configuration window, the program arguments and VM arguemtns in the tab Arguments are empty, that’s why the server can’t load the class and throw the exception.

bug137822-empty1

2.  However,  when we open the server configuration by clicking the tomcat server in the server view and clicking the “open launch configuration” , there are some arguments in the fields of  program arguments and VM arguments in the tab Arguments.

bug137822-correctargument

As Larry Isaacs suggested for me, I should try to set the arguments in the fileds when I run the configurations.


Dig the Bug 137822 – Find the code to throw the exception

March 14, 2009

After the debug, I got the code to throw the exception.

As I expected before, The class Server.java is the key class to start the server service. I set a break point on the method setServerState() of the class Server.java. When I debug it, the following picture is what I got the last line of the code without any exception.

The code throw the exception

As we can see, there is aproblem in the publisher function of ServerBehaviorDelegate.java

publishServer(kind, ProgressUtil.getSubMonitorFor(monitor, 1000));

I must investigate which value is supposed to be for the variables “kind” and “monitor”.  Then  I can fingure out when and where to produce such mistakes.