What's necessary for using uml2 within xtext plugin? [message #1102361] |
Thu, 05 September 2013 17:32 |
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...
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03703 seconds