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

Bug 312050

Summary: [Move to EMF Facet] Fails to load catalog elements because metamodel is overwritten by AcceleoBuilder
Product: [Modeling] MoDisco Reporter: Nicolas Bros <nicolas.bros>
Component: InfrastructureAssignee: Project Inbox <modisco.web-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P5 CC: gdupe
Version: 0.8.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
stacktrace
gdupe: iplog-
patch
none
example project none

Description Nicolas Bros CLA 2010-05-07 08:47:56 EDT
- Install MoDisco and Acceleo SDK in Eclipse 3.6M7
- Checkout all plug-ins from "https://dev.eclipse.org/svnroot/modeling/org.eclipse.gmt.modisco/plugins/branches/0_8_0".
- Do a full clean

You get several "Failed to load" errors on QuerySets, Facets and UiCustom (attached).

After debugging, I found out the corresponding Resources in the MoDiscoResourceSet contained DynamicEObjectImpl objects, instead of the expected generated implementation classes.

Several of the MoDisco projects that were checked-out are Acceleo projects, so have the Acceleo builder enabled.

AcceleoBuilder registers all ecore files it finds in Acceleo projects and their dependencies, putting a dynamic version of the metamodel into the EPackage.Registry.

After this, EClassifier#isInstance returns false when asked whether OCLModelQueryImpl is an instance of ModelQuery (it should be true of course).

The reason for this is that these metaclasses now reside in two different metamodels: the one for which an implementation was generated, and the one that was loaded dynamically.

And this is what is causing the aforementioned "Failed to load" errors.
Comment 1 Nicolas Bros CLA 2010-05-07 08:49:35 EDT
Created attachment 167459 [details]
stacktrace
Comment 2 Nicolas Bros CLA 2010-05-07 10:12:31 EDT
*** Bug 305831 has been marked as a duplicate of this bug. ***
Comment 3 Nicolas Bros CLA 2010-10-18 08:30:53 EDT
Created attachment 181087 [details]
patch

Anyway, here is a patch that fixes the problem, by removing only javadoc comments as the comment suggests, and putting back removed comments in the unhandled comments list.
Comment 4 Nicolas Bros CLA 2010-10-18 08:32:32 EDT
Scratch that! Wrong bug.
Comment 5 Nicolas Bros CLA 2010-10-19 06:12:37 EDT
Created attachment 181165 [details]
example project

Here is a project that shows the problem:
- Import project bug312050 from the attached zip
- open A.xmi in the model browser
- Add the single instance of metaclass A in this model to the Query Execution view
- execute query A::myQuery2 using the Query Execution view

you get a message in the log giving the identity of the metaclass:
metaclass A: org.eclipse.emf.ecore.impl.EClassImpl@461984

- Do "Project > Clean..." on the bug312050 project
- the query A::myQuery2 disappears from the Query Execution View, because the metamodel changed, and the instance of metaclass A that was added in the view is suddenly no more an instance of the metaclass A in the re-loaded metamodel. So, the query is not applicable to it anymore.
- close and re-open A.xmi
- Add the single instance of metaclass A in this model to the Query Execution view
- execute query A::myQuery2 using the Query Execution view

you get a new message in the log, with a different ID for the metaclass, indicating it is not the same metaclass anymore:
metaclass A: org.eclipse.emf.ecore.impl.EClassImpl@1be72d6
Comment 6 Nicolas Bros CLA 2010-10-19 06:46:30 EDT
Actually, this is not conclusive, because A.xmi contains a dynamic instance.
I need to find a better example.
Comment 7 Nicolas Bros CLA 2010-10-19 09:38:18 EDT
See: org.eclipse.acceleo.common.utils.ModelUtils.registerEcorePackages(String pathName). This is where Acceleo registers the EPackages.
Comment 8 Gregoire Dupe CLA 2011-09-28 07:14:59 EDT
We will switch to EMF Facet before to try to solve such bugs. => P5