Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » What's necessary for using uml2 within xtext plugin?
What's necessary for using uml2 within xtext plugin? [message #1102361] Thu, 05 September 2013 17:32 Go to next message
Joe I is currently offline Joe IFriend
Messages: 28
Registered: May 2013
Junior Member
Hi,

I register the uml stuff within the generator with the following code:
val resourceSet = new ResourceSetImpl
resourceSet.getPackageRegistry().put(UMLPackage::eNS_URI, UMLPackage::eINSTANCE)
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource::FILE_EXTENSION, UMLResource.Factory::INSTANCE)
val uriMap = resourceSet.getURIConverter().getURIMap()
val url = getClass().getResource("../libs/org.eclipse.uml2.uml.resources_4.1.0.v20130610-0712.jar").toString
val uri = URI::createURI("jar:"+url+"!/")
uriMap.put(URI::createURI(UMLResource::LIBRARIES_PATHMAP), uri.appendSegment("libraries").appendSegment(""))
uriMap.put(URI::createURI(UMLResource::METAMODELS_PATHMAP), uri.appendSegment("metamodels").appendSegment(""))
uriMap.put(URI::createURI(UMLResource::PROFILES_PATHMAP), uri.appendSegment("profiles").appendSegment(""))


The libs are stored in the neighbor package "libs" and added on the build path.
Concerning the plugin I also add them to the plug-in classpath.

It works like a charm when I test the generator with a junit test, but it fails when I run the project as eclipse application. I get the following errors:
Quote:

!ENTRY org.eclipse.emf.ecore 2 0 2013-09-05 19:13:37.629
!MESSAGE org.eclipse.uml2.uml.internal.impl.UMLFactoryImpl cannot be cast to org.eclipse.uml2.uml.UMLFactory
!STACK 0
java.lang.ClassCastException: org.eclipse.uml2.uml.internal.impl.UMLFactoryImpl cannot be cast to org.eclipse.uml2.uml.UMLFactory
at org.eclipse.uml2.uml.internal.impl.UMLFactoryImpl.init(UMLFactoryImpl.java:250)
at org.eclipse.uml2.uml.UMLFactory.<clinit>(UMLFactory.java:36)
at org.eclipse.uml2.uml.internal.impl.UMLPackageImpl.<init>(UMLPackageImpl.java:1865)
at org.eclipse.uml2.uml.internal.impl.UMLPackageImpl.init(UMLPackageImpl.java:1894)
at org.eclipse.uml2.uml.UMLPackage.<clinit>(UMLPackage.java:82)
at org.xtext.example.mydsl.generator.MyDslGenerator.doGenerate(MyDslGenerator.java:30)
at org.eclipse.xtext.builder.BuilderParticipant.handleChangedContents(BuilderParticipant.java:299)
at org.eclipse.xtext.builder.BuilderParticipant.build(BuilderParticipant.java:229)
at org.eclipse.xtext.builder.impl.RegistryBuilderParticipant.build(RegistryBuilderParticipant.java:60)
at org.eclipse.xtext.builder.impl.XtextBuilder.doBuild(XtextBuilder.java:186)
at org.eclipse.xtext.builder.impl.XtextBuilder.incrementalBuild(XtextBuilder.java:162)
at org.eclipse.xtext.builder.impl.XtextBuilder.build(XtextBuilder.java:95)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:726)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

!ENTRY org.eclipse.emf.ecore 2 0 2013-09-05 19:13:37.637
!MESSAGE org.eclipse.uml2.types.internal.impl.TypesFactoryImpl cannot be cast to org.eclipse.uml2.types.TypesFactory
!STACK 0
java.lang.ClassCastException: org.eclipse.uml2.types.internal.impl.TypesFactoryImpl cannot be cast to org.eclipse.uml2.types.TypesFactory
at org.eclipse.uml2.types.internal.impl.TypesFactoryImpl.init(TypesFactoryImpl.java:41)
at org.eclipse.uml2.types.TypesFactory.<clinit>(TypesFactory.java:34)
at org.eclipse.uml2.types.internal.impl.TypesPackageImpl.<init>(TypesPackageImpl.java:81)
at org.eclipse.uml2.types.internal.impl.TypesPackageImpl.init(TypesPackageImpl.java:112)
at org.eclipse.uml2.types.TypesPackage.<clinit>(TypesPackage.java:66)
at org.eclipse.uml2.uml.internal.impl.UMLPackageImpl.init(UMLPackageImpl.java:1900)
at org.eclipse.uml2.uml.UMLPackage.<clinit>(UMLPackage.java:82)
at org.xtext.example.mydsl.generator.MyDslGenerator.doGenerate(MyDslGenerator.java:30)
at org.eclipse.xtext.builder.BuilderParticipant.handleChangedContents(BuilderParticipant.java:299)
at org.eclipse.xtext.builder.BuilderParticipant.build(BuilderParticipant.java:229)
at org.eclipse.xtext.builder.impl.RegistryBuilderParticipant.build(RegistryBuilderParticipant.java:60)
at org.eclipse.xtext.builder.impl.XtextBuilder.doBuild(XtextBuilder.java:186)
at org.eclipse.xtext.builder.impl.XtextBuilder.incrementalBuild(XtextBuilder.java:162)
at org.eclipse.xtext.builder.impl.XtextBuilder.build(XtextBuilder.java:95)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:726)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)


I uploaded an example project with the same errors to dropbox, maybe it helps for understanding the problem: https://dl.dropboxusercontent.com/u/19175437/problem.zip
Within the generator you can find the registration/pathmap code. When you run an eclipse application, make a new file with the extension "mydsl". Add some code, save it and the errors should occur in the console.

Thanks in advance for any help! These errors are driving me crazy...
Re: What's necessary for using uml2 within xtext plugin? [message #1103301 is a reply to message #1102361] Fri, 06 September 2013 15:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hmmm

can you please elaborate what you actually try todo.
why do you repackage the uml plugin?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: What's necessary for using uml2 within xtext plugin? [message #1104024 is a reply to message #1103301] Sat, 07 September 2013 18:57 Go to previous messageGo to next message
Joe I is currently offline Joe IFriend
Messages: 28
Registered: May 2013
Junior Member
Well, I would also like to use my xtext language inside a standalone application, that's why I thought I should copy the uml2 libs...

So there is a better way of doing it?

Thanks!
Re: What's necessary for using uml2 within xtext plugin? [message #1104064 is a reply to message #1104024] Sat, 07 September 2013 20:29 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

This all seems very strange.

Surely you should be using UM2Ecore to provide *.ecore models that Xtext
works with happily.

I may be mistaken but I doubt that Xtext has any support for UML and I
doubt that there any plans to support the subtleties of associations,
profiles and redefinitions.

If using UML standalone you absolutely must use UMLResourcesUtil.init()
and copying libraries is likely to cause chaos.

Regards

Ed Willink


On 07/09/2013 19:57, Joe I wrote:
> Well, I would also like to use my xtext language inside a standalone
> application, that's why I thought I should copy the uml2 libs...
>
> So there is a better way of doing it?
>
> Thanks!
Re: What's necessary for using uml2 within xtext plugin? [message #1104389 is a reply to message #1104064] Sun, 08 September 2013 08:58 Go to previous messageGo to next message
Joe I is currently offline Joe IFriend
Messages: 28
Registered: May 2013
Junior Member
Ed Willink wrote on Sat, 07 September 2013 16:29
Hi
This all seems very strange.

Surely you should be using UM2Ecore to provide *.ecore models that Xtext
works with happily.

I may be mistaken but I doubt that Xtext has any support for UML and I
doubt that there any plans to support the subtleties of associations,
profiles and redefinitions.

I just want to generate uml models Wink

Ed Willink wrote on Sat, 07 September 2013 16:29

If using UML standalone you absolutely must use UMLResourcesUtil.init()
and copying libraries is likely to cause chaos.

Thanks, I will try this out!
Re: What's necessary for using uml2 within xtext plugin? [message #1108152 is a reply to message #1104389] Fri, 13 September 2013 12:14 Go to previous messageGo to next message
Joe I is currently offline Joe IFriend
Messages: 28
Registered: May 2013
Junior Member
Hi,

I now use UMLResourcesUtil.init() and set the uml2 libs by adding them to the required plug-ins inside the "Dependencies" tab of MANIFEST.MF. I also don't use my lib copies...

But from the moment I add the uml2 plugins, a dsl plugin (i.e. xtext example project) stops working inside an eclipse application...

So what are the steps for adding uml2 libs and using them to generate uml2 models inside the generator?

Thanks!
Re: What's necessary for using uml2 within xtext plugin? [message #1114329 is a reply to message #1108152] Sun, 22 September 2013 15:15 Go to previous message
Joe I is currently offline Joe IFriend
Messages: 28
Registered: May 2013
Junior Member
Ok, I made a silly mistake... I added all uml libs, but when I just add org.eclipse.uml2.uml and org.eclipse.uml2.uml.resources to the dependencies it works fine Smile

However profiles don't work, when I test the generator with junit testcases...
Previous Topic:Import a xtext file into EMF
Next Topic:Two similar rules, but with different cross-references
Goto Forum:
  


Current Time: Tue Apr 16 21:29:09 GMT 2024

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

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

Back to the top