Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 375811

Summary: NullPointerException on HttpServiceTracker.close()
Product: [RT] RAP Reporter: Arian Storch <storch>
Component: WorkbenchAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: 1.5 M6   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Arian Storch CLA 2012-04-02 03:05:09 EDT
Build Identifier: 

I've got the following situation:

Plug-in A depends on "org.eclipse.rap.ui" which depends on "org.eclipse.rap.ui.workbench".

I've written some JUnit-Tests for Plug-in A which are summarized in a Plug-in B. So this depends on A.

The tests themselfs are running without problems. 

But everytime a NullPointerException is thrown. I could locate and solve the problem like this:

The Exception occurs on invoking the HttpServiceTracker.close(). (org.eclipse.rap.ui.internal.servlet) 

Especially on the following lines:

=== #108 - #115
public void close() {
    super.close();
    httpContextTracker.close();    
    ApplicationLauncherTracker.close();  <-------
}
===

I've solved the problem very simple but it works:

===
public void close() {
    super.close();
    httpContextTracker.close();
    
    if(ApplicationLauncherTracker != null) { 
    	ApplicationLauncherTracker.close();
    }
}
===

I suggest a similar default implementation.

Reproducible: Always
Comment 1 Ivan Furnadjiev CLA 2012-04-02 06:39:57 EDT
Which version of RAP are you using? With the introduction of "org.eclipse.rap.rwt.osgi" bundle in 1.5 a lot of code has been changed there.
Comment 2 Arian Storch CLA 2012-04-02 07:11:12 EDT
This bug also occurs with RAP 1.5M6.
Comment 3 Ivan Furnadjiev CLA 2012-04-02 10:21:56 EDT
Arian, there is no more call too applicationLauncherTracker.close() in HttpServiceTracker.close(). Could you attach a stack trace from the NPE with 1.5M6?
Comment 4 Arian Storch CLA 2012-04-02 10:39:53 EDT
Hi Ivan,

here it is:



org.osgi.framework.BundleException: Exception in org.eclipse.ui.internal.WorkbenchPlugin.stop() of bundle org.eclipse.rap.ui.workbench.
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.stop(BundleContextImpl.java:791)
	at org.eclipse.osgi.framework.internal.core.BundleHost.stopWorker(BundleHost.java:510)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.suspend(AbstractBundle.java:566)
	at org.eclipse.osgi.framework.internal.core.Framework.suspendBundle(Framework.java:1207)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.decFWSL(StartLevelManager.java:592)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:257)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.shutdown(StartLevelManager.java:215)
	at org.eclipse.osgi.framework.internal.core.InternalSystemBundle.suspend(InternalSystemBundle.java:284)
	at org.eclipse.osgi.framework.internal.core.Framework.shutdown(Framework.java:693)
	at org.eclipse.osgi.framework.internal.core.Framework.close(Framework.java:600)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.shutdown(EclipseStarter.java:398)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:198)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Caused by: java.lang.NullPointerException
	at org.eclipse.rap.ui.internal.servlet.HttpServiceTracker.close(HttpServiceTracker.java:111)
	at org.eclipse.ui.internal.WorkbenchPlugin.stop(WorkbenchPlugin.java:1340)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl$2.run(BundleContextImpl.java:771)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.stop(BundleContextImpl.java:764)
	... 19 more
Root exception:
java.lang.NullPointerException
	at org.eclipse.rap.ui.internal.servlet.HttpServiceTracker.close(HttpServiceTracker.java:111)
	at org.eclipse.ui.internal.WorkbenchPlugin.stop(WorkbenchPlugin.java:1340)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl$2.run(BundleContextImpl.java:771)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.stop(BundleContextImpl.java:764)
	at org.eclipse.osgi.framework.internal.core.BundleHost.stopWorker(BundleHost.java:510)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.suspend(AbstractBundle.java:566)
	at org.eclipse.osgi.framework.internal.core.Framework.suspendBundle(Framework.java:1207)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.decFWSL(StartLevelManager.java:592)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:257)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.shutdown(StartLevelManager.java:215)
	at org.eclipse.osgi.framework.internal.core.InternalSystemBundle.suspend(InternalSystemBundle.java:284)
	at org.eclipse.osgi.framework.internal.core.Framework.shutdown(Framework.java:693)
	at org.eclipse.osgi.framework.internal.core.Framework.close(Framework.java:600)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.shutdown(EclipseStarter.java:398)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:198)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Comment 5 Ivan Furnadjiev CLA 2012-04-02 10:51:44 EDT
Arian, this stack trace does not fit to 1.5M6. Probably, it is from 1.5M5. Could you check again with 1.5M6 and attach a stack trace against 1.5M6? We did some changes/refactorins related to service tracker in M6.
Comment 6 Arian Storch CLA 2012-04-02 10:56:38 EDT
Hi Ivan,

I'm sorry, you are totally right! I was running RAP 1.5M5.

With M6 it works fine.

Thanks for your advice!
Comment 7 Ivan Furnadjiev CLA 2012-04-02 11:02:58 EDT
(In reply to comment #6)
> With M6 it works fine.
Fixed in 1.5M6 by the re-factorings did in HttpServiceTracker.