Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Error loading Ecore GenModel in New Xtext Generator (2.10) #41

Closed
fkoenig opened this issue Jul 19, 2016 · 31 comments
Closed

Error loading Ecore GenModel in New Xtext Generator (2.10) #41

fkoenig opened this issue Jul 19, 2016 · 31 comments

Comments

@fkoenig
Copy link

fkoenig commented Jul 19, 2016

I think I found a bug in the new Xtext Generator in Xtext 2.10.
The Generator tries to load an Ecore GenModel referred in the imported GenModel of my Grammar.

I Added projects with this error to this ticket.

My Grammar:
`// automatically generated by Xtext
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals

import "http://www.example.org/testModel"
import "http://www.eclipse.org/emf/2002/Ecore" as ecore

Document returns Document:
{Document}
'Document'
name=ID
'{'
('pages' '{' pages+=Page ("," pages+=Page)* '}')?
'}';

Page returns Page:
{Page}
'Page'
name=ID
'{'
('attributes' '{' attributes+=Attribute ("," attributes+=Attribute)* '}')?
'}';

Attribute returns Attribute:
{Attribute}
'Attribute'
name=ID
'{'
('type' type=[ecore::EClassifier|ID])?
'}';`

Error:

0    [main] INFO  text.xtext.generator.XtextGenerator  - Initializing Xtext generator
6    [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Adding generated EPackage 'org.eclipse.xtext.common.types.TypesPackage'
98   [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project org.xtext.example.mydsl at 'file:/C:/Users/jekkt/workspace/ScenarioTools-Neon-OCL/org.xtext.example.mydsl/'
98   [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project org.xtext.example.mydsl.tests at 'file:/C:/Users/jekkt/workspace/ScenarioTools-Neon-OCL/org.xtext.example.mydsl.tests/'
99   [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project org.xtext.example.mydsl.ide at 'file:/C:/Users/jekkt/workspace/ScenarioTools-Neon-OCL/org.xtext.example.mydsl.ide/'
99   [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project org.xtext.example.mydsl.ui at 'file:/C:/Users/jekkt/workspace/ScenarioTools-Neon-OCL/org.xtext.example.mydsl.ui/'
99   [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project org.xtext.example.mydsl.ui.tests at 'file:/C:/Users/jekkt/workspace/ScenarioTools-Neon-OCL/org.xtext.example.mydsl.ui.tests/'
106  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Using resourceSet registry. The registered Packages will not be registered in the global EPackage.Registry.INSTANCE!
388  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/Xtext/Xbase/XAnnotations' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
390  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/xtext/xbase/Xtype' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
403  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/xtext/xbase/Xbase' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
403  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/xtext/common/JavaVMTypes' from 'platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.genmodel'
426  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.example.org/testModel' from 'platform:/resource/TestModel/model/testModel.genmodel'
426  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/emf/2002/Ecore' from 'platform:/resource/org.eclipse.emf.ecore/model/Ecore.genmodel'
529  [main] ERROR xt.generator.XtextGeneratorLanguage  - [TransformationDiagnostic: null:28 Cannot find compatible feature type in sealed EClass Attribute from imported package http://www.example.org/testModel: The existing reference 'type' has an incompatible type 'null'. The expected type is 'EClassifier' [org.eclipse.emf.ecore.EClassifier]. (ErrorCode: CannotCreateTypeInSealedMetamodel)]
531  [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher  - Problems running workflow org.xtext.example.mydsl.GenerateMyDsl: Problem parsing 'file:/C:/Users/jekkt/workspace/ScenarioTools-Neon-OCL/org.xtext.example.mydsl/../org.xtext.example.mydsl/src/org/xtext/example/mydsl/MyDsl.xtext':
TransformationDiagnostic: null:28 Cannot find compatible feature type in sealed EClass Attribute from imported package http://www.example.org/testModel: The existing reference 'type' has an incompatible type 'null'. The expected type is 'EClassifier' [org.eclipse.emf.ecore.EClassifier]. (ErrorCode: CannotCreateTypeInSealedMetamodel)
java.lang.RuntimeException: Problems running workflow org.xtext.example.mydsl.GenerateMyDsl: Problem parsing 'file:/C:/Users/jekkt/workspace/ScenarioTools-Neon-OCL/org.xtext.example.mydsl/../org.xtext.example.mydsl/src/org/xtext/example/mydsl/MyDsl.xtext':
TransformationDiagnostic: null:28 Cannot find compatible feature type in sealed EClass Attribute from imported package http://www.example.org/testModel: The existing reference 'type' has an incompatible type 'null'. The expected type is 'EClassifier' [org.eclipse.emf.ecore.EClassifier]. (ErrorCode: CannotCreateTypeInSealedMetamodel)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:104)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:62)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:78)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:36)
Caused by: java.lang.IllegalStateException: Problem parsing 'file:/C:/Users/jekkt/workspace/ScenarioTools-Neon-OCL/org.xtext.example.mydsl/../org.xtext.example.mydsl/src/org/xtext/example/mydsl/MyDsl.xtext':
TransformationDiagnostic: null:28 Cannot find compatible feature type in sealed EClass Attribute from imported package http://www.example.org/testModel: The existing reference 'type' has an incompatible type 'null'. The expected type is 'EClassifier' [org.eclipse.emf.ecore.EClassifier]. (ErrorCode: CannotCreateTypeInSealedMetamodel)
    at org.eclipse.xtext.xtext.generator.XtextGeneratorLanguage.initialize(XtextGeneratorLanguage.java:272)
    at org.eclipse.xtext.xtext.generator.StandardLanguage.initialize(StandardLanguage.java:169)
    at org.eclipse.xtext.xtext.generator.XtextGenerator.initialize(XtextGenerator.java:176)
    at org.eclipse.xtext.xtext.generator.XtextGenerator.checkConfigurationInternal(XtextGenerator.java:120)
    at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent2.checkConfiguration(AbstractWorkflowComponent2.java:21)
    at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.preInvoke(Mwe2Bridge.java:65)
    at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.preInvoke(AbstractWorkflowComponent.java:197)
    at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.preInvoke(AbstractCompositeWorkflowComponent.java:29)
    at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:18)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:102)
    ... 4 more
@fkoenig
Copy link
Author

fkoenig commented Jul 19, 2016

The upload failed. So here are the files again...
projects.zip

@cdietrich
Copy link
Member

cdietrich commented Aug 13, 2016

similar problem when referencing "Genmodel.genmodel" and "Xtext.genmodel"

@cdietrich
Copy link
Member

cdietrich commented Aug 13, 2016

i did some debugging on this. basically we have the eclass "eclassififer" twice.

org.eclipse.emf.ecore.impl.EClassImpl@56d93692 (name: EClassifier) (instanceClassName: null) (abstract: true, interface: false)
org.eclipse.emf.ecore.impl.EClassImpl@75f32542 (name: EClassifier) (instanceClassName: null) (abstract: true, interface: false)

once coming from loading the genmodel. the other coming from the epackage registry (via XtextPackage)

isnt the plan to fully ignore the global epackage registry?

Using resourceSet registry. The registered Packages will not be registered in the global EPackage.Registry.INSTANCE!

@meysholdt
Copy link
Contributor

what are the URIs of the two EMF-Resources containing the eclassififers?

@cdietrich
Copy link
Member

@meysholdt
one is platform:/plugin/..../Ecore.ecore and one is EcorePackage.NS_URI

thus if i do something like

class XtextGeneratorResourceSetInitializer {

    public def void initialize(ResourceSet resourceSet, List<String> referencedResources) {
        val delegate = new StandaloneSetup
        delegate.resourceSet = resourceSet
        val ecoreByNsUri = URI.createURI(EcorePackage.eNS_URI)
        URIConverter.URI_MAP => [
            val ecoreByPlatformPluginUri = URI.createURI("platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore")
            val ecoreByPlatformResourceUri = URI.createURI("platform:/resource/org.eclipse.emf.ecore/model/Ecore.ecore")
            if (!containsKey(ecoreByPlatformPluginUri))
                put(ecoreByPlatformPluginUri, ecoreByNsUri)
            if (!containsKey(ecoreByPlatformResourceUri))
            put(ecoreByPlatformResourceUri, ecoreByNsUri)
        ]
        resourceSet.createResource(ecoreByNsUri) => [
            contents += EcorePackage.eINSTANCE
        ]

        referencedResources.forEach[
            loadResource(resourceSet)
        ]
        registerGenModels(resourceSet)
        registerEPackages(resourceSet)
    }

it works but i dont know if this is a good idea

@cdietrich
Copy link
Member

cdietrich commented Aug 15, 2016

actually it is not since it destroys inferred metamodels.

(org.eclipse.xtext.xtext.generator.ecore.EMFGeneratorFragment2.getReferencedEPackages(List)) seems not to work

plus tons of ther places there when generating testlanguages

well the problem is that

resourceSet.createResource(ecoreByNsUri) => [
contents += EcorePackage.eINSTANCE
]

only works once.not for multiple languages

@ebousse
Copy link

ebousse commented Sep 20, 2016

Hello, I encouter the same problem when trying to create the grammar of a DSL that imports Ecore.

My language minitl has an EClass Transformation with a feature inputMetamodels typed by EPackage.

My grammar is:

grammar org.tetrabox.example.MiniTL with org.eclipse.xtext.common.Terminals

import "minitl"
import "http://www.eclipse.org/emf/2002/Ecore" as ecore

Transformation returns Transformation:
    'Transformation'
    '{'
        'inputMetamodel' '(' inputMetamodel+=[ecore::EPackage|EString] ( "," inputMetamodel+=[ecore::EPackage|EString])* ')' 
        'outputMetamodel' '(' outputMetamodel+=[ecore::EPackage|EString] ( "," outputMetamodel+=[ecore::EPackage|EString])* ')' 
    '}';

I have the following error:

Cannot find compatible feature inputMetamodel in sealed EClass
   Transformation from imported package minitl: The existing reference
   'inputMetamodel' has an incompatible type 'null'. The expected
   type is 'EPackage'.

But in minitl the type of the reference is definitely not null :(.

@fkoenig
Copy link
Author

fkoenig commented Sep 29, 2016

Does anyone know some kind of ETA for when this gets resolved?

@cdietrich
Copy link
Member

since nobody is working on this (no time, knowledge or budget) there is no ETA

@dd4g12
Copy link

dd4g12 commented Feb 6, 2017

Hi I have a similar problem, just wondering if you managed to solve this problem.
Thanks,
Dana

@spoenemann
Copy link
Member

The best way to fix the problem in the example project provided by @fkoenig is to open testModel.ecore with a text editor and replace

platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore

with

http://www.eclipse.org/emf/2002/Ecore

The platform:/plugin/ URI scheme does not work properly in a standalone scenario such as the Xtext generator. This has nothing to do with Xtext, it's just the way EMF works. If you really need that kind of URI scheme, you can specialize the Xtext generator by adding these two classes:

MyResourceSetInitializer.xtend

class MyResourceSetInitializer extends XtextGeneratorResourceSetInitializer {
    override def initialize(ResourceSet resourceSet, List<String> referencedResources) {
        resourceSet.packageRegistry.put("platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore", EcorePackage.eINSTANCE)
        super.initialize(resourceSet, referencedResources)
    }
}

MyGeneratorModule.xtend

class MyGeneratorModule extends DefaultGeneratorModule {
    def Class<? extends XtextGeneratorResourceSetInitializer> bindXtextGeneratorResourceSetInitializer() {
        MyResourceSetInitializer
    }
}

Then change the workflow file like this:

    component = XtextGenerator {
        configuration = MyGeneratorModule {
            ...
        }
        ...
    }

@spoenemann
Copy link
Member

spoenemann commented Apr 26, 2017

I prepared PR #325 to improve the situation by printing a more meaningful error message. Now instead of

The existing reference 'type' has an incompatible type 'null'. The expected type is 'EClassifier' [org.eclipse.emf.ecore.EClassifier].

you get

The type of the reference 'type' could not be resolved. The URI is platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EClassifier

Apart from this improvement, I propose to close this issue. We could add more documentation on this topic to the website, but that should be handled in a separate issue in eclipse/xtext.

@cdietrich
Copy link
Member

cdietrich commented Jun 16, 2017

here is another occurence of this.
i think we should find a solution ....

https://www.eclipse.org/forums/index.php/t/1086680/

in this case the ecore does not even use platform:/plugin
and its not working

@szarnekow do you have some ideas on this?

@tjallingran
Copy link

tjallingran commented Oct 26, 2018

TL;DR: Is there a way to get this to work for genmodels other than Ecore.genmodel?

The fix given by @spoenemann above seems to not work for our situation. (That said, @spoenemann: thanks for providing such a well-fleshed-out fix description and explanation of the problem.)

We're running into this issue with xtext 2.12.0, but with another genmodel than the Ecore one. We're using an externally provided metamodel (say, A.ecore) in one of our own metamodels (say, B.ecore). A.ecore is included in an Eclipse plugin (which is part of a feature), so referencing A.ecore by platform:/plugin URI makes sense.

I tried using A.ecore's nsURI in B.ecore instead, as suggested by @spoenemann above. This works for B.ecore itself, but it doesn't combine properly with, say, usedGenPackages="platform:/plugin/com.example.a/model/action.genmodel#//a in B.genmodel.

As there is no nsURI for genmodels (afaik), I can't reference A.genmodel by nsURI. An alternative is removing the reference to A.genmodel from B.genmodel. This (logically) causes the EMF code generator to generate Java code for both A.ecore and B.ecore inside B's Eclipse project. That is not a viable option, as we want to use the Java implementation of A that's in the externally provided Eclipse plugin.

@cdietrich
Copy link
Member

cdietrich commented Oct 26, 2018

Ususally you use

referencedResource=„platform:/resource/xxxx/model/yyyy.genmodel“ in the language section of the workflow (+ maybe a uri mapping)

=> can you give more details what you do

@tjallingran
Copy link

tjallingran commented Oct 26, 2018

We do indeed use

referencedResource="platform:/resource/com.example.b/model/B.genmodel"
referencedResource="platform:/resource/com.example.a/model/A.genmodel"

However, during the execution of the workflow, we get the following output:

1406 [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://com.example.a/A' from 'platform:/resource/com.example.a/model/A.genmodel'
1409 [main] ERROR xt.generator.XtextGeneratorLanguage  - Error loading 'platform:/plugin/com.example.a/model/A.genmodel'

So the genmodel is succesfully registered, but then a second attempt, that tries to use a platform plugin uri, fails.

After nsURI-ing/removing the platform plugin URIs from B.ecore/B.genmodel, the second attempt is no longer performed (but this is not an option).

@tjallingran
Copy link

tjallingran commented Oct 29, 2018

Update: our issue appears to be fixed by changing the dependency on A.genmodel in B.genmodel from a platform plugin URI to a platform resource URI. That is, we went from

usedGenPackages="platform:/plugin/com.example.a/model/action.genmodel#//a"

to

usedGenPackages="platform:/resource/com.example.a/model/action.genmodel#//a"

With this change, the mwe2 workflow executes successfully, both in Eclipse and in our Maven/Tycho build.

@cdietrich
Copy link
Member

i still wonder if adding a uri mapping would have done the same

@asiehsalehi
Copy link

what is the final solution please?
Eclipse Oxygen.3a Release (4.7.3a)
Xtext Complete SDK 2.19.0.v20190902-1322

@cdietrich
Copy link
Member

There is none. Depends what you exactly do and what happens in your case

@asiehsalehi
Copy link

can you help to find out how I can fix it please?

I have implemented the solution suggested by spoenemann (specialize the Xtext generator by adding these two classes), this allows to generate xtext artifacts but the log still shows:
419 [main] ERROR xt.generator.XtextGeneratorLanguage - Error loading 'platform:/plugin/org.eclipse.emf.ecore/model/Ecore.genmodel'

@kthoms
Copy link

kthoms commented Oct 31, 2019

Try to store Ecore.genmodel and add a uri mapping with the standalone setup from a platform:/plugin to platform:/resource uri.

@cdietrich
Copy link
Member

@asiehsalehi any hints on how to reproduce your problem?

@miklossy
Copy link
Contributor

I also encountered this problem while Migrating the Eclipse Xcore Project to the new Xtext Generator Workflow: #563042.

0    [main] WARN  pes.access.impl.DeclaredTypeFactory  - --- xtext.common.types ---------------------------------------------------
0    [main] WARN  pes.access.impl.DeclaredTypeFactory  - ASM library is too old. Falling back to java.lang.reflect API.
1    [main] WARN  pes.access.impl.DeclaredTypeFactory  - Please note that no information about compile time constants is available.
1    [main] WARN  pes.access.impl.DeclaredTypeFactory  - It's recommended to use org.objectweb.asm 8.0.1 or better (Maven group id: org.ow2.asm).
1    [main] WARN  pes.access.impl.DeclaredTypeFactory  - --------------------------------------------------------------------------
527  [main] WARN  lipse.emf.mwe.utils.StandaloneSetup  - Skipping conflicting project org.objectweb.asm at 'archive:file:/C:/Users/miklossy/.p2/pool/plugins/org.objectweb.asm_7.2.0.v20191010-1910.jar!/' and using 'archive:file:/C:/Users/miklossy/.p2/pool/plugins/org.objectweb.asm_8.0.1.v20200420-1007.jar!/' instead.
680  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering platform uri 'C:\Users\miklossy\git\emf\plugins'
2913 [main] INFO  text.xtext.generator.XtextGenerator  - Initializing Xtext generator
2915 [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Adding generated EPackage 'org.eclipse.xtext.common.types.TypesPackage'
2974 [main] WARN  lipse.emf.mwe.utils.StandaloneSetup  - Skipping conflicting project org.objectweb.asm at 'archive:file:/C:/Users/miklossy/.p2/pool/plugins/org.objectweb.asm_8.0.1.v20200420-1007.jar!/' and using 'archive:file:/C:/Users/miklossy/.p2/pool/plugins/org.objectweb.asm_7.2.0.v20191010-1910.jar!/' instead.
2975 [main] WARN  lipse.emf.mwe.utils.StandaloneSetup  - Skipping conflicting project org.objectweb.asm at 'archive:file:/C:/Users/miklossy/.p2/pool/plugins/org.objectweb.asm_7.2.0.v20191010-1910.jar!/' and using 'archive:file:/C:/Users/miklossy/.p2/pool/plugins/org.objectweb.asm_8.0.1.v20200420-1007.jar!/' instead.
3104 [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project org.eclipse.emf.ecore.xcore at 'file:/C:/Users/miklossy/git/emf/plugins/org.eclipse.emf.ecore.xcore/'
3105 [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project org.eclipse.emf.ecore.xcore.tests at 'file:/C:/Users/miklossy/git/emf/tests/org.eclipse.emf.test.ecore.xcore/'
3106 [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project org.eclipse.emf.ecore.xcore.ide at 'file:/C:/Users/miklossy/git/emf/plugins/org.eclipse.emf.ecore.xcore.ui/'
3106 [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project org.eclipse.emf.ecore.xcore.ui at 'file:/C:/Users/miklossy/git/emf/plugins/org.eclipse.emf.ecore.xcore.ui/'
3106 [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project org.eclipse.emf.ecore.xcore.ui.tests at 'file:/C:/Users/miklossy/git/emf/tests/org.eclipse.emf.test.ecore.xcore/'
3111 [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Using resourceSet registry. The registered Packages will not be registered in the global EPackage.Registry.INSTANCE!
3302 [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/Xtext/Xbase/XAnnotations' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
3305 [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/xtext/xbase/Xtype' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
3313 [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/xtext/xbase/Xbase' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
3314 [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/xtext/common/JavaVMTypes' from 'platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.genmodel'
3369 [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/emf/2011/Xcore' from 'platform:/resource/org.eclipse.emf.ecore.xcore/model/Xcore.genmodel'
3369 [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/emf/2002/Ecore' from 'platform:/resource/org.eclipse.emf.ecore/model/Ecore.genmodel'
3369 [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/emf/2002/GenModel' from 'platform:/resource/org.eclipse.emf.codegen.ecore/model/GenModel.genmodel'
3613 [main] ERROR xt.generator.XtextGeneratorLanguage  - [TransformationDiagnostic: null:41 Cannot find compatible feature importedObject in sealed EClass XImportDirective from imported package http://www.eclipse.org/emf/2011/Xcore: The type 'EObject' used in the reference 'importedObject' is inconsistent. Probably this is due to an unsupported kind of metamodel hierarchy. (ErrorCode: CannotCreateTypeInSealedMetamodel)]
3616 [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher  - Problems running workflow org.eclipse.emf.ecore.xcore.Xcore: Problem parsing 'file:/C:/Users/miklossy/git/emf/plugins/org.eclipse.emf.ecore.xcore/../org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/Xcore.xtext':
TransformationDiagnostic: null:41 Cannot find compatible feature importedObject in sealed EClass XImportDirective from imported package http://www.eclipse.org/emf/2011/Xcore: The type 'EObject' used in the reference 'importedObject' is inconsistent. Probably this is due to an unsupported kind of metamodel hierarchy. (ErrorCode: CannotCreateTypeInSealedMetamodel)
java.lang.RuntimeException: Problems running workflow org.eclipse.emf.ecore.xcore.Xcore: Problem parsing 'file:/C:/Users/miklossy/git/emf/plugins/org.eclipse.emf.ecore.xcore/../org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/Xcore.xtext':
TransformationDiagnostic: null:41 Cannot find compatible feature importedObject in sealed EClass XImportDirective from imported package http://www.eclipse.org/emf/2011/Xcore: The type 'EObject' used in the reference 'importedObject' is inconsistent. Probably this is due to an unsupported kind of metamodel hierarchy. (ErrorCode: CannotCreateTypeInSealedMetamodel)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:105)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:63)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:53)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:79)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:37)
Caused by: java.lang.IllegalStateException: Problem parsing 'file:/C:/Users/miklossy/git/emf/plugins/org.eclipse.emf.ecore.xcore/../org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/Xcore.xtext':
TransformationDiagnostic: null:41 Cannot find compatible feature importedObject in sealed EClass XImportDirective from imported package http://www.eclipse.org/emf/2011/Xcore: The type 'EObject' used in the reference 'importedObject' is inconsistent. Probably this is due to an unsupported kind of metamodel hierarchy. (ErrorCode: CannotCreateTypeInSealedMetamodel)
	at org.eclipse.xtext.xtext.generator.XtextGeneratorLanguage.initialize(XtextGeneratorLanguage.java:276)
	at org.eclipse.xtext.xtext.generator.StandardLanguage.initialize(StandardLanguage.java:184)
	at org.eclipse.xtext.xtext.generator.XtextGenerator.initialize(XtextGenerator.java:186)
	at org.eclipse.xtext.xtext.generator.XtextGenerator.checkConfigurationInternal(XtextGenerator.java:140)
	at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent2.checkConfiguration(AbstractWorkflowComponent2.java:23)
	at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.preInvoke(Mwe2Bridge.java:69)
	at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.preInvoke(AbstractWorkflowComponent.java:208)
	at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.preInvoke(AbstractCompositeWorkflowComponent.java:31)
	at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:20)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:103)
	... 4 more

@merks: See the corresponding Gerrit change

@cdietrich I was also wondering whether this configuration is supposed to also work with the new generator workflow out-of-the-box.

@cdietrich
Copy link
Member

No idea what you try to do

@miklossy
Copy link
Contributor

Let me clarify this a little bit.

Currently, the Xcore project uses the old Xtext generator workflow. Since this workflow is deprecated, I am trying to migrate the project to the new Xtext generator workflow.

As a first step, I changed the GenerateXcore.mwe2 workflow file to use the new Xtext generator workflow (org.eclipse.xtext.xtext.generator.*) packages instead of the old deprecated generator workflow (org.eclipse.xtext.generator.*) packages.

As a second step, I tried to execute the updated GenerateXcore.mwe2 workflow and got the exception above.

After some research, I found out that the Xcore.xtext file uses an imported meta-model import "http://www.eclipse.org/emf/2011/Xcore". The Xcore.ecore file contains references to Ecore.ecore via ../../org.eclipse.emf.ecore/model/Ecore.ecore.

Changing that reference to http://www.eclipse.org/emf/2002/Ecore solves the problem and the GenerateXcore.mwe2 workflow can be successfully executed without the exception.

The question is why any change on the Xcore.ecore file is necessary while migrating to the new Xtext generator workflow. Given that it was working with the old generator workflow, I assumed that this will also work with the new generator workflow and no extra changes are necessary on the Xcore.ecore file.

@miklossy
Copy link
Contributor

@szarnekow Do you have any hints on this?

@szarnekow
Copy link
Contributor

I think the registerGeneratedEPackage was crucial in the old workflow for this setup to succeed.

@miklossy
Copy link
Contributor

Adding the

language = StandardLanguage {
	...
	referencedResource = "platform:/resource/org.eclipse.emf.ecore/model/Ecore.ecore"
	...
}

solved the problem at the Xcore project.

Thanks for the hints @cdietrich and @szarnekow !

@wilbert-alberts
Copy link

i still wonder if adding a uri mapping would have done the same

I know, it's almost two years ago but I ran into the same issue and can confirm that I solved it using the uri mapping.

Regards,
Wilbert.

@szarnekow
Copy link
Contributor

Closed as per the last comment.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests