Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Cannot access EClass objects declared in a referenced .ecore file(from a Java Service)
[Acceleo] Cannot access EClass objects declared in a referenced .ecore file [message #1698102] Thu, 11 June 2015 09:21 Go to next message
Francois Cabrol is currently offline Francois CabrolFriend
Messages: 32
Registered: January 2015
Hi everyone,

I am currently working on an Acceleo project based on the Ecore metamodel. The main .ecore file used as the input of the Acceleo scripts contains references to another .ecore file (base.ecore) contained in another project of the workspace. File base.ecore mainly contains declarations for abstract classes and interfaces which are extended/implemented in the main .ecore file.

I created a Java service with a method isSpecification(EClass eClass) returning true if eClass extends/implements the Specification type, defined in base.ecore.

The problem is that this method always returns false. When I try to debug my code, I can see that all super types of parameter eClass are unresolved proxies, so none of these super types can be equal to my Specification type.

What is the correct way to have these proxies automatically resolved ?

Thanks in advance,


[Updated on: Thu, 11 June 2015 09:26]

Report message to a moderator

Re: [Acceleo] Cannot access EClass objects declared in a referenced .ecore file [message #1698376 is a reply to message #1698102] Mon, 15 June 2015 08:15 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 458
Registered: April 2010
Location: Nantes (France)
Senior Member


When Acceleo loads your model, it uses the standard mechanisms of EMF. You may have to register some additional information for a stand alone usage that EMF in Eclipse would register for you. Those proxies should be resolved automatically by EMF. Could you add to this discussion a simple example of your project showing the issue? The problem may come from the URIs used in your main ecore file to reference the base ecore file. If those URIs are NsURIs for example, EMF would expect to find your base ecore model as a registered EPackage in the package registry of your resource set.


Stephane Bégaudeau, Obeo
Re: [Acceleo] Cannot access EClass objects declared in a referenced .ecore file [message #1707150 is a reply to message #1698376] Wed, 02 September 2015 15:14 Go to previous message
Francois Cabrol is currently offline Francois CabrolFriend
Messages: 32
Registered: January 2015
Hi again,

I had solved the problem temporarily by launching my MTL scripts using the Acceleo Plugin Application Runner. But I switched to Eclipse Mars where this strategy is discouraged (and does not really work).

So I reverted to the Java Application Runner, and my initial problem remains, which is: the classes of the base.ecore model referenced in the specific.ecore model used as input in my Acceleo run configuration appear as proxies, so statements like these:


are never true, even if aClass extends rootEClass.

Here is an extract of my specific.ecore file, which is the input file of the Acceleo script. It defines an abstract class named RootClass extending class Root of the base.ecore model.

<eClassifiers xsi:type="ecore:EClass" name="RootClass" eSuperTypes="../../thales.thav.dsi.em.common.model/model/base.ecore#//Specification ../../thales.thav.dsi.em.common.model/model/base.ecore#//Root #//profiles/ProfileA #//profiles/ProfileB">
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="#//String">
    <eStructuralFeatures xsi:type="ecore:EReference" name="classgena" lowerBound="1"
        upperBound="-1" eType="#//gen/ClassGenA" containment="true"/>

When I evaluate statement rootEClass.isSuperTypeOf(aClass) in one java service of the Acceleo script with rootEClass set to Root EClass (using BasePackage.eINSTANCE.getRoot()), and aClass set to RootClass EClass, it returns false.

In debug mode, I can see that rootEClass evaluates to:
org.eclipse.emf.ecore.impl.EClassImpl@e6619b (name: Root) (instanceClassName: null) (abstract: true, interface: true)

and aClass.getESuperTypes() evaluates to:
[org.eclipse.emf.ecore.impl.EClassImpl@c4176a (eProxyURI: file:/D:/Projets/EM-GENERATOR/src/code/specifem/thales.thav.dsi.em.common.model/model/base.ecore#//Specification), org.eclipse.emf.ecore.impl.EClassImpl@1dd4c3d (eProxyURI: file:/D:/Projets/EM-GENERATOR/src/code/specifem/thales.thav.dsi.em.common.model/model/base.ecore#//Root), org.eclipse.emf.ecore.impl.EClassImpl@1b83ac6 (name: ProfileA) (instanceClassName: null) (abstract: true, interface: false), org.eclipse.emf.ecore.impl.EClassImpl@1ab8b7 (name: ProfileB) (instanceClassName: null) (abstract: true, interface: false)]

which explains that my type Root cannot be found in the list of RootClass's super types.

I tried the following workarounds:
- replace ../.. in specific.ecore file with plugin:/platform or plugin:/resource URIs
- calling EcoreUtil.resolveAll(BasePackage.eINSTANCE) at various places of the code (in my Java Service or in method registerPackages of the Java file generated by Acceleo to run the script)
- calling resourceSet.getPackageRegistry().put(BasePackage.eINSTANCE.getNsURI(), BasePackage.eINSTANCE) in the same places

but I still have the same behaviour.

Does someone have a clue ?

Thank you,

Previous Topic:[Acceleo] Logging / Debugging
Next Topic:Xtend files compile in plugin environment
Goto Forum:

Current Time: Thu Jul 18 02:10:43 GMT 2024

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

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

Back to the top