Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Referencing other models and problems with services(Models are registered multiple times and VSM services are not found anymore)
Referencing other models and problems with services [message #1842547] Wed, 23 June 2021 05:54 Go to next message
Roman Wirtz is currently offline Roman WirtzFriend
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"?>



   <extension point="org.eclipse.emf.ecore.generated_package">
      <!-- @generated secrima -->

   <extension point="org.eclipse.emf.ecore.generated_package">
      <!-- @generated secrima -->

   <extension point="org.eclipse.emf.ecore.generated_package">
      <!-- @generated secrima -->


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)
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 #1842550 is a reply to message #1842547] Wed, 23 June 2021 07:55 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7518
Registered: July 2009
Senior Member

You are probably right that the multiple plugin entries are a problem. It is also possible that during development you copied from one place to another so there might be some vintage droppings too.

The @generated secrima guard is supposed to suppress duplicates. Is there a spelling problem whereby secrima is/was different to the genmodel modelName? Inconsistent upper/lowercase letters in the Windows file system might be a cause.

If the above doesn't solve it, it's probably a bug raise a Bugzilla with the repro.

To workaround, set the "Plugin Key" property in the templates and merge section of the genmodel root properties to blank. This stops the auto-generation of the duplicates, allowing you to reduce to just one. I then change to e.g, <!-- @generated secrima NOT ->


Ed Willink
Re: Referencing other models and problems with services [message #1842590 is a reply to message #1842550] Thu, 24 June 2021 14:01 Go to previous messageGo to next message
Glenn Plouhinec is currently offline Glenn PlouhinecFriend
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.


Glenn Plouhinec - Obeo

Need training or professional services for Sirius?
Re: Referencing other models and problems with services [message #1842714 is a reply to message #1842547] Tue, 29 June 2021 13:14 Go to previous message
Roman Wirtz is currently offline Roman WirtzFriend
Messages: 2
Registered: November 2018
Junior Member
Hello everyone,

first of all thank you very much for your replies and the support.

After having some other issues with the models I now managed to get thinks working with your comments and some additional adjustments:

- I removed all generated files and the *.edit and *.editor projects making sure that no old code is available. Furthermore, I delated all entries in the plugin.xml and the exported packages in the MANIFEST.
- I checked all base packages (the one for problem frames was missing).
- I generated the problemframes since it has no references to other models.
- I added the dependencies to other models as mentioned by Glenn.
- In the gen model of the referencing model, I further added the gen models of the referenced models using the attribute usedGenPackages.

After that, I could generate all models without any manual adjustments. There are no duplicate models in the plugin.xml anymore, and the services are working properly.

The warning that the same models have been registered several times has been resolved, too.

Thank you very much again!

Best regards,
Previous Topic:Installing Sirius 6.5.1 on Eclipse 2021-06 Modeling fails
Next Topic:Javadoc building problem
Goto Forum:

Current Time: Mon Oct 03 22:24:11 GMT 2022

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

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

Back to the top