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 13:32 Go to next message
Joe I is currently offline Joe I
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 11:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6132
Registered: July 2009
Senior Member
Hmmm

can you please elaborate what you actually try todo.
why do you repackage the uml plugin?
Re: What's necessary for using uml2 within xtext plugin? [message #1104024 is a reply to message #1103301] Sat, 07 September 2013 14:57 Go to previous messageGo to next message
Joe I is currently offline Joe I
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 16:29 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4008
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 04:58 Go to previous messageGo to next message
Joe I is currently offline Joe I
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 08:14 Go to previous messageGo to next message
Joe I is currently offline Joe I
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 11:15 Go to previous message
Joe I is currently offline Joe I
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: Mon Jul 28 08:33:50 EDT 2014

Powered by FUDForum. Page generated in 0.01873 seconds