Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Unexpected java.lang.IllegalStateException: No context available outside of the request service life
Unexpected java.lang.IllegalStateException: No context available outside of the request service life [message #677488] Wed, 08 June 2011 16:24 Go to next message
Arnaud MERGEY is currently offline Arnaud MERGEYFriend
Messages: 243
Registered: March 2010
Location: France
Senior Member
Hello,

I have an issue and I cannot figure out if it comes from RAP or from something wrong in my code.

In our RAP application, we have declared our own extension point, so users can extends our application by providing their own plugin, defining this Extension.

Users can upload their plugin directly from our RAP application.

In the Action allowing to upload and install new plugin, I execute this code.

FileInputStream stream = new FileInputStream(uploadedFile);
try {
bundleContext.installBundle(location, stream).start();
} finally {
stream.close();
}


By doing this we have the exception copied above, but the action is working as expected, the newly uploaded plugin is installed and available to the application,
It is just "ugly" for us to have this exception we cannot catch.

After some investigation, it seems that a org.eclipse.core.runtime.IRegistryChangeEvent is fired, to a org.eclipse.core.runtime.IRegistryChangeListener registered by org.eclipse.ui.internal.menus.WorkbenchMenuService because the bundle I start programmatically declare a new extension instance of our extension point.


The exception occurs because this event is processed in a Thread named "Worker-1", so outside the UI Thread, and the code call Platform.getWorkbench(), in WorkbenchMenuService:

// RAP [bm]: extracted listener to detach it on session timeout
final IExtensionRegistry registry = Platform.getExtensionRegistry();
final IRegistryChangeListener registryChangeListener = new IRegistryChangeListener() {
public void registryChanged(final IRegistryChangeEvent event) {
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
public void run() {
handleRegistryChanges(event);
}
});
}
};


I noticed that this listener is unregistered if the session timeout, so as a workaround, I delegate the bundle starting in background thread, and I kill the http session, I have no exception, but the user has to refresh the page after installing the plugin, that is not a big deal.

I am just wondering why RegistryChangeEvent are processed in a background thread, as they need some code to be executed in UIThread, and I am wondering if there can be some other issue because of this.

The exception is:

java.lang.IllegalStateException: No context available outside of the request service lifecycle.
at org.eclipse.rwt.internal.service.ContextProvider.getContext(ContextProvider.java:105)
at org.eclipse.rwt.internal.service.ContextProvider.getStateInfo(ContextProvider.java:153)
at org.eclipse.rwt.SessionSingletonBase.getInstance(SessionSingletonBase.java:82)
at org.eclipse.ui.internal.Workbench.getInstance(Workbench.java:653)
at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:94)
at org.eclipse.ui.internal.menus.WorkbenchMenuService$1.registryChanged(WorkbenchMenuService.java:265)
at org.eclipse.core.internal.registry.ExtensionRegistry$2.run(ExtensionRegistry.java:922)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.registry.ExtensionRegistry.processChangeEvent(ExtensionRegistry.java:920)
at org.eclipse.core.runtime.spi.RegistryStrategy.processChangeEvent(RegistryStrategy.java:260)
at org.eclipse.core.internal.registry.osgi.ExtensionEventDispatcherJob.run(ExtensionEventDispatcherJob.java:50)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)




Re: Unexpected java.lang.IllegalStateException: No context available outside of the request service [message #680421 is a reply to message #677488] Thu, 09 June 2011 15:55 Go to previous message
Arnaud MERGEY is currently offline Arnaud MERGEYFriend
Messages: 243
Registered: March 2010
Location: France
Senior Member
In order to illustrate the issue, I manage to write a simple snippet to reproduce it.

By launching snippet.ise, and clicking on the coolbar item, the java.lang.IllegalStateException occurs
Previous Topic:When will File upload & download widgets will available?
Next Topic:Upload widget relies on internal RWT code that has changed after M6
Goto Forum:
  


Current Time: Tue Sep 24 23:21:49 GMT 2024

Powered by FUDForum. Page generated in 0.03794 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top