Bug 580733 - Unable to load class ExtendedCommonNavigator (sphinx.emf.explorer), cannot exit Eclipse
Summary: Unable to load class ExtendedCommonNavigator (sphinx.emf.explorer), cannot ex...
Status: CLOSED FIXED
Alias: None
Product: Sphinx
Classification: Automotive
Component: Core (show other bugs)
Version: 0.13.0   Edit
Hardware: All All
: P3 critical (vote)
Target Milestone: 0.13.1   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-09-14 02:00 EDT by Ansgar Radermacher CLA
Modified: 2022-09-23 04:54 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ansgar Radermacher CLA 2022-09-14 02:00:06 EDT
I have trouble with the nightly CI build of Sphinx and earlier versions in current Eclipse versions (2022-03 and 2022-06): I'm getting exceptions related to class loading of Sphinx plugins that not only affected Sphinx itself but even prevent to close Eclipse (as new Exceptions are produced during close), therefore I use a high severity.
The error is shown below.

The erroneous behavior is caused by an immediate start of workspace listeners in the activators of the sphinx platform and sphinx EMF plugin. Apparently, the workspace can be still unavailable when plugins are started. An exception during plugin startup prevents the whole plugin from being charged.

An option that works is to delay the listener start via newly scheduled jobs, as shown below. A better option might be not to use the static getWorkspace() method 



org.eclipse.core.runtime.CoreException: Plug-in org.artop.aal.examples.explorer was unable to load class org.eclipse.sphinx.emf.explorer.ExtendedCommonNavigator.
	at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.throwException(RegistryStrategyOSGI.java:212)
	at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:198)
	at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:920)
	at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:246)
	at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:63)
	at org.eclipse.ui.internal.registry.ViewDescriptor.createView(ViewDescriptor.java:61)
...
Caused by: java.lang.IllegalStateException: Workspace is already closed or not ready yet. Consider tracking the org.eclipse.core.resources.IWorkspace service (using your favorite technique, e.g. Declarative Services, ServiceTracker, Blueprint, ...) instead of calling the static method here to prevent such issues!
	at org.eclipse.core.resources.ResourcesPlugin.getWorkspace(ResourcesPlugin.java:456)
	at org.eclipse.sphinx.platform.internal.Activator.start(Activator.java:71)
	at org.eclipse.osgi.internal.framework.BundleContextImpl$2.run(BundleContextImpl.java:818)
	at org.eclipse.osgi.internal.framework.BundleContextImpl$2.run(BundleContextImpl.java:1)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:569)

Possible workaround:

-- a/plugins/org.eclipse.sphinx.emf/src/org/eclipse/sphinx/emf/Activator.java
+++ b/plugins/org.eclipse.sphinx.emf/src/org/eclipse/sphinx/emf/Activator.java
@@ -15,6 +15,10 @@
  */
 package org.eclipse.sphinx.emf;
 
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.emf.common.EMFPlugin;
 import org.eclipse.emf.common.util.ResourceLocator;
 import org.eclipse.sphinx.emf.internal.ecore.proxymanagement.ProxyHelperAdapterFactory;
@@ -93,7 +97,14 @@ public final class Activator extends EMFPlugin {
                public void start(BundleContext context) throws Exception {
                        super.start(context);
 
+                       Job job = new Job("start synchronizing") {
+                               @Override
+                               public IStatus run(IProgressMonitor monitor) {
                                        startWorkspaceSynchronizing();
+                                       return Status.OK_STATUS;
+                               }
+                       };
+                       job.schedule();
 
                        ProxyHelperAdapterFactory.INSTANCE.start();


diff --git a/plugins/org.eclipse.sphinx.platform/src/org/eclipse/sphinx/platform/internal/Activator.java b/plugins/org.eclipse.sphinx.platform/src/org/eclipse/sphinx/platform/internal/Activator.java
index 69716475..9f164726 100644
--- a/plugins/org.eclipse.sphinx.platform/src/org/eclipse/sphinx/platform/internal/Activator.java
+++ b/plugins/org.eclipse.sphinx.platform/src/org/eclipse/sphinx/platform/internal/Activator.java
@@ -16,7 +16,11 @@ package org.eclipse.sphinx.platform.internal;
 
 import org.eclipse.core.resources.IResourceChangeListener;
 import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.sphinx.platform.IExtendedPlatformConstants;
 import org.eclipse.sphinx.platform.internal.util.ContentTypeIdCachePurger;
 import org.eclipse.sphinx.platform.util.ExtendedPlatform;
@@ -67,8 +71,15 @@ public class Activator extends Plugin {
 
                System.setProperty(IExtendedPlatformConstants.SYSTEM_PROPERTY_PLATFORM_FEATURE_VERSION, ExtendedPlatform.getFeatureVersion());
 
+               Job job = new Job("start listener") {
+                       @Override
+                       public IStatus run(IProgressMonitor monitor) {
                                contentTypeIdPropertyInvalidator = new ContentTypeIdCachePurger();
                                ResourcesPlugin.getWorkspace().addResourceChangeListener(contentTypeIdPropertyInvalidator);
+                               return Status.OK_STATUS;
+                       }
+               };
+               job.schedule();
        }
Comment 1 Ansgar Radermacher CLA 2022-09-16 04:22:52 EDT
I've done some additional tests. Eclipse 2022-03 is NOT concerned by the bug (sorry about the mistake). However, Eclipse 2022-09 is concerned as well, but it's possible to exit Eclipse, therefore I reduce severity. The error is not reproducible after a restart via Eclipse, i.e. in particular not after the first restart when installing Sphinx in a fresh Eclipse installation. The bug is reproducible only if you exit and then manually start Eclipse again.
Comment 2 Balazs Grill CLA 2022-09-21 07:05:22 EDT
Finally, I managed to reproduce the bug. For reference, it occurs when a sphinx editor was opened during previous shutdown, causing an early start and an exception during sphinx.platform activation.
Comment 3 Eclipse Genie CLA 2022-09-22 08:14:55 EDT
New Gerrit change created: https://git.eclipse.org/r/c/sphinx/org.eclipse.sphinx/+/195971
Comment 5 Balazs Grill CLA 2022-09-23 04:54:29 EDT
fix merged