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

Bug 467860

Summary: "Could not find Java extension class" error when disabling a Viewpoint with non-unique name
Product: [Modeling] Sirius Reporter: Pierre-Charles David <pierre-charles.david>
Component: CoreAssignee: Cedric Brun <cedric.brun>
Status: CLOSED FIXED QA Contact: Pierre-Charles David <pierre-charles.david>
Severity: normal    
Priority: P3 CC: laurent.fasani
Version: unspecifiedKeywords: triaged
Target Milestone: 3.0.0   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/48598
https://git.eclipse.org/r/48599
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=a9a8b6e508436998209dd5f21f6b6b683041c3a3
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=a7a3d50497c2224e94b58d6bdd0c4a39e785b3ee
Whiteboard:

Description Pierre-Charles David CLA 2015-05-21 09:42:54 EDT
Steps to reproduce, on Sirius master (~3.0.0rc1a):
1. Launch a runtime where both Ecore Tools (Mars version) and org.eclipse.sirius.sample.ecore.design are installed. They both define a viewpoint named "Design" and the issue seems related to this.
2. Create a basic Modeling project and an empty Ecore file inside.
3. Expand the Ecore semantic model and right-click on the root package, and dismiss the menu. This step seems required to ensure all the plugins/classes related to the issue are loaded.
4. Open the "Viewpoint Selection" dialog on the project, and enable one of the two "Design" viewpoints available.
5. Make sure the Error log view is open and clear it if needed.
6. Re-open the "Viewpoint Selection" dialog, de-select the currently select "Design" viewpoint and select the other one => one or more messages appear in the error log of the form ""Could not find Java extension class XXX".

When disabling the "Design" viewpoint provided by Ecore Tools, I get:
  Could not find Java extension class org.eclipse.emf.ecoretools.design.service.DesignServices

When disabling the "Design" viewpoint provided by org.eclipse.sirius.sample.ecore.design, I get:
  Could not find Java extension class org.eclipse.sirius.ecore.design.service.DesignServices
  Could not find Java extension class org.eclipse.sirius.ecore.design.service.EReferenceServices
  Could not find Java extension class org.eclipse.sirius.ecore.design.service.EcoreService

I have not (yet) checked if the messages cause actual problems in the behavior of the system afterwards.
Comment 1 Pierre-Charles David CLA 2015-05-21 10:31:38 EDT
The following patch *seems* to fix the issue, but I'm not familiar enough with that part of the code to be sure if it's a good idead or not:

diff --git src/org/eclipse/sirius/common/tools/api/interpreter/JavaExtensionsManager.java src/org/eclipse/sirius/common/tools/api/interpreter/JavaExtensionsManager.java
index 5dfdc0c..5ae5a95 100644
--- src/org/eclipse/sirius/common/tools/api/interpreter/JavaExtensionsManager.java
+++ src/org/eclipse/sirius/common/tools/api/interpreter/JavaExtensionsManager.java
@@ -588,6 +589,8 @@
                     plugins.add(pluginCandidate.segment(1));
                 }
             }
+        } else {
+            clearImports();
         }
         updateScope(plugins, prjs);
     }
Comment 2 Pierre-Charles David CLA 2015-05-22 08:35:26 EDT
I've pushed a draft with the previous patch as https://git.eclipse.org/r/48461 to see what Gerrit says.
Comment 3 Laurent Fasani CLA 2015-05-22 09:26:05 EDT
(In reply to Pierre-Charles David from comment #0)
The scenario in comment #0 don't lead to the issue
Below is the modified scenario (modified step : 3-4-6)
Steps to reproduce, on Sirius master (~3.0.0rc1a):
1. Launch a runtime where both Ecore Tools (Mars version) and org.eclipse.sirius.sample.ecore.design are installed. They both define a viewpoint named "Design" and the issue seems related to this.
2. Create a basic Modeling project and an empty Ecore file inside.
3. Open the "Viewpoint Selection" dialog on the project, and enable both available "Design" viewpoints.
4. Expand the Ecore semantic model and right-click on the root package, and dismiss the menu. This step seems required to ensure all the plugins/classes related to the issue are loaded.
5. Make sure the Error log view is open and clear it if needed.
6. Re-open the "Viewpoint Selection" dialog, deselect one of the selected "Design" viewpoint => one or more messages appear in the error log of the form ""Could not find Java extension class XXX".
Comment 4 Cedric Brun CLA 2015-05-26 04:23:08 EDT
This is actually not linked to the fact that Viewpoints have the same names, but is a linked to a lack in the protocol/API for interpreters : one can't tell an IInterpreter : here are your qualified class names to imports AND the classpath scope in a single call. When the JavaExtensionManager is called with an "updateScope" and already have registered qualified class names, it will try to reload those classes eagerly (this is done in org.eclipse.sirius.business.internal.session.danalysis.DAnalysisSessionImpl.configureInterpreter()) through         

        this.interpreter.setProperty(IInterpreter.FILES, null);
        this.interpreter.setProperty(IInterpreter.FILES, filePaths);

=> services can't be loaded, an error is logged

And the very next method call: 
     InterpreterRegistry.prepareImportsFromSession(this.interpreter, this);

will end up clearing the imports and then setting the new imports

=> the services are loaded correctly

Indeed the patchset at https://git.eclipse.org/r/48461 makes the error disappear as it's clearing the import while updating the scope but it will only work if the client code *re-add the imports* after such call (and I suspect it is the case through the Sirius code)

This problem appeared with the introduction of JavaExtensionManager as this class is not "lazy" and will try to load as-soon as the configuration (scope or imports) changed while other implementations are just "keeping this data around" and will initialize/load the classes during request evaluation.
Comment 5 Eclipse Genie CLA 2015-05-26 05:07:38 EDT
New Gerrit change created: https://git.eclipse.org/r/48598
Comment 6 Eclipse Genie CLA 2015-05-26 05:07:39 EDT
New Gerrit change created: https://git.eclipse.org/r/48599
Comment 9 Pierre-Charles David CLA 2015-05-27 05:11:35 EDT
Fixed.
Comment 10 Pierre-Charles David CLA 2015-05-27 05:18:49 EDT
Verified on Sirius 3.0.0rc2.
Comment 11 Pierre-Charles David CLA 2015-06-24 11:13:55 EDT
Available in Sirius 3.0.0. See https://wiki.eclipse.org/Sirius/3.0.0.