You probably have the .ecore
for your metamodel and you didn't generate the metamodel code (using .genmodel
). The error you have occurs when you try to open your .xmi
file using an EMF tool (Acceleo/QVT...etc). So, many points here ;).
You can deal with static or dynamic instances of your metamodel.
Static instances
Static instances are produced when you generate the code of your metamodel (using a .genmodel
), you register your project as plugin and you create model that conforms to your deployed metamodel. In this case, your metamodel is deployed as an Eclipse plugin and your metamodel is registered in a global registry when the plugin is loaded by Eclipse. In your dev mode routine, the simpliest way of defining your metamodel and developing stuffs around it is to handle two eclipse instances. The first one (I will call it the "original" instance) is the one where your metamodel project is. The second one is launched through the run new eclipse configuration
menu from the original instance (I will call it the "new" instance). So, here is the routine:
- You create your metamodel
- You generate the
.genmodel
linked to your metamodel
- You generate the metamodel code
- You launch your "new" eclipse instance from the original one
- You go through the
file->new->other->Example Model EMF Creation Wizard->your_stuff
wizard to create your model
Now, your model is created and your metamodel is registered in the global registry, so Acceleo file will compile well and your model will be openeable/readeable by any EMF compliant application without extra work. This method is long but it's also the easiest.
If you only want to deal with one Eclipse instance and if you have your metamodel code generated, you can also perform this:
- Link your acceleo project to your metamodel project
- Modify the java file generated by Acceleo and add this in the
registerPackages
method:
resourceSet.getPackageRegistry().put(SomethingPackage.eINSTANCE.getNsURI(), SomethingPackage.eINSTANCE);
This will register your metamodel and the Acceleo transformation should run without any issue. However, I'm not sure this manual step is required if you link your Acceleo project to your metamodel project. I think Acceleo can deal with the metamodel by itself if the metamodel project is in the same workspace (but in case, you can do it manually).
Dynamic instances
In the case you described, you are dealing with dynamic instances. It means that the metamodel code is not generated. ATL can handle dynamic instances so, that's why you were able to generate an .xmi
. By the way, you can create an .xmi
by opening your metamodel, select your root EClass and click on right_click->Create dynamic instance...
.
If you want to deal with this type of instances, you have to register your metamodel manually for Acceleo. To do this, you have to modify the java file generated by Acceleo and add this in the registerPackages method:
File file = new File("path/to/your/metamodel.ecore");
EObject obj = ModelUtils.load(file, resourceSet);
resourceSet.getPackageRegistry().put("metamodel_ns_uri", obj);
(ModelUtils
comes from org.eclipse.acceleo.common.utils
)
Using this, you could be able to generate code from Acceleo with dynamic instance.
Also, just a quick word on Acceleo, if your RESTfulServicePSM
instances will not generate code, you can directly put your @main
annotation on your generateResourceModelClasses
template directly. The Acceleo engine will iterate on each CSharpResourceModel
instances by itself. Oh, and you can put many @main
annotations on many templates, they will be evaluated ;).
EDIT>
I've just seen your problem is fixed, I should have look. Sorry for the long post.
.ecore
or did you want to use dynamic instances as models? Also the URI you use is thensURI
attribute value you set to the root of your metamodel? – Vincent Aranega.ecore
for your metamodel and you didn't generate metamodel code. I post an answer to develop ;) – Vincent Aranega