Referencing other models and problems with services [message #1842547] |
Wed, 23 June 2021 05:54 |
Roman Wirtz Messages: 2 Registered: November 2018 |
Junior Member |
|
|
Good morning everyone,
I am using Sirius and EMF for developing a model-based tool supporting the application of different methods in the context of my thesis.
The tool consists of three models (i) problemframes, (ii) riskcatalog, and (iii) secrima. The catalog metamodel imports elements from the problem frame metamodel, and the secrima metamodel imports elements from both, the catalog and the problem frame.
For developing purposes, I have all these metamodels in one Obeo instance (see screenshot). The Sirius files for the graphical modelers are contained in another instance which I start from inside this first Obeo instance.
I added the referenced models as dependencies and used the "Add Existing elements" tool for extending the metamodel with these existing elements.
Afterwards, I generate the complete model code.
When starting the second instance, I get the message that some of the models are registered several times. Accept that I can select the metamodels several times from the registry, the modelers are working correctly and I can create model instances with my tools.
However, there is an issue with the Java services of the VSMs. When only having one model, e.g. the problemframes model that does not reference other models, in the first instance, the Java services can be used without any problems.
As soon as I add other metamodels referencing this first model to the workspace, e.g. the secrima model, the services are not found anymore. However, there is no error or warning message.
I am struggling with this issue for some weeks now but do not find any solution that may work.
I think the problem may be somewhere around the plugin.xml of the extended models. For the secrima model, it looks like the following:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<!--
-->
<plugin>
<extension point="org.eclipse.emf.ecore.generated_package">
<!-- @generated secrima -->
<package
uri="..."
class="de.unidue.swe.rwirtz.secrima.SecrimaPackage"
genModel="model/secrima.genmodel"/>
</extension>
<extension point="org.eclipse.emf.ecore.generated_package">
<!-- @generated secrima -->
<package
uri="..."
class="problemframes.ProblemframesPackage"
genModel="model/secrima.genmodel"/>
</extension>
<extension point="org.eclipse.emf.ecore.generated_package">
<!-- @generated secrima -->
<package
uri="..."
class="riskcatalog.RiskcatalogPackage"
genModel="model/secrima.genmodel"/>
</extension>
</plugin>
Remark: I had to remove the uri from the file in the forum, because they were considered as external links which are not allowed to be added to this topic.
When removing the extension points of the referenced models, I got new exceptions like:
!ENTRY org.eclipse.emf.ecore 2 0 2021-06-23 07:50:42.382
!MESSAGE class problemframes.impl.ProblemframesFactoryImpl cannot be cast to class problemframes.ProblemframesFactory (problemframes.impl.ProblemframesFactoryImpl is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @3ad794d; problemframes.ProblemframesFactory is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @5b7aadea)
!STACK 0
java.lang.ClassCastException: class problemframes.impl.ProblemframesFactoryImpl cannot be cast to class problemframes.ProblemframesFactory
I found old articles explaining how to reference models, but most of them explain the steps I already performed or seems to be that old that they cannot be used anymore.
Do you have any hints how to solve this issue?
Many thanks in advance and best regards,
Roman Wirtz
|
|
|
|
Re: Referencing other models and problems with services [message #1842590 is a reply to message #1842550] |
Thu, 24 June 2021 14:01 |
Glenn Plouhinec Messages: 22 Registered: April 2020 |
Junior Member |
|
|
Hello Roman,
I notice that your ClassCastException refers to two different packages: problemframes.impl.ProblemframesFactoryImpl and problemframes.ProblemframesFactory. I couldn't reproduce your problem exactly but I had some trouble with dependencies when I was generating code and I think your problem might be similar.
I created 3 Ecore Modeling Projects, "ecore.project1" "ecore.project2" "ecore.project3", with ecore models that have similar dependencies to yours: project2 uses elements from project1, and project3 uses elements from the other two. If I do a "Generate Model Code" on Project3 and all its dependencies, the code of the 3 models is generated in ecore.project3. Your ClassCastException makes me think that you must have some "problemframes" code generated in a place where it should not be. It is better to generate only the code for model 3 in ecore.project3, as well as the code for model 2 in ecore.project2 and model 1 in ecore.project1.
Before generating the code, it may be useful to fill in the "Base Package" field of the ecore packages in the genmodel.
In your case you may need to add in de.unidue.swe.rwirtz.riskcatalog/model/riskcatalog.genmodel > Riskcatalog: (in the Properties view)
- Problemframes "Base Package" = de.unidue.swe.probarisk
And in de.unidue.swe.rwitz.secrima/model/secrima.genmodel > Secrima: (in Properties view)
- Problemframes "Base Package" = de.unidue.swe.probarisk
- Riskcatalog "Base Package" = de.unidue.swe.rwirtz
Do not forget to add the necessary plugin dependencies in the plugin.xml. Finally a "Generate All" can be performed on de.unidue.swe.rwirtz.riskcatalog/model/riskcatalog.genmodel > Riskcatalog > Riskcatalog and de.unidue.swe.rwitz.secrima/model/secrima.genmodel > Secrima > Secrima.
This should give you a good base for your generated code. Add the necessary dependencies to the *.edit and *.editor projects, fix the few trivial errors you may have in the Error Log, and you can also remove the extension points in the plugin.xml as you did before.
I hope this can help you.
Regards,
Glenn
Glenn Plouhinec - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
|
Powered by
FUDForum. Page generated in 0.04007 seconds