Error in package registration while loading state machine from .uml [message #1732751] |
Thu, 19 May 2016 14:13 |
Syed Samsul Arefin Messages: 17 Registered: May 2016 |
Junior Member |
|
|
Hi,
I am quite new in this field and it's maybe an awkward question. I have a model that contains two state machines. I need to parse this uml in a standalone application. I believe EMF would save tons of time. So, I read EMF tutorial and wrote this code to load the uml file.
public static void main(String[] args) {
ResourceSet set = new ResourceSetImpl();
set.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
set.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
Resource res = set.getResource(URI.createFileURI("resources/model.uml"), true);
res.getContents().get(0);
}
but it gives me the following error,
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/uml2/types/TypesPackage
at org.eclipse.uml2.uml.internal.impl.UMLPackageImpl.init(UMLPackageImpl.java:1907)
at org.eclipse.uml2.uml.UMLPackage.<clinit>(UMLPackage.java:83)
at mp.m2bt.BTGenerator.main(BTGenerator.java:31)
Caused by: java.lang.ClassNotFoundException: org.eclipse.uml2.types.TypesPackage
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 3 more
I am using the following external jars
org.eclipse.emf.common_2.11.1.v20160208-0816.jar
org.eclipse.emf.ecore.xmi_2.11.1.v20160208-0816.jar
org.eclipse.emf.ecore_2.11.2.v20160208-0816.jar
org.eclipse.emf.mapping.ecore2xml_2.9.0.v20160208-0841.jar
org.eclipse.uml2.common_2.1.0.v20160201-0816.jar
org.eclipse.uml2.uml_5.1.2.v20160201-0816.jar
I also checked these links but still no luck.
https://www.eclipse.org/forums/index.php/t/360956/
and stackoverflow links:
/questions/34055936/how-can-i-load-a-papyrus-uml-model-by-using-java
/questions/13881825/load-uml-statechart-model-with-emf-that-has-an-applied-profile
/questions/1404343/eclipse-modelling-framework-emf-how-to-get-the-domainmodel-from-a-magicdraw-u
I am not sure what did I do wrong. So, could anybody please help me? Thanks.
-
Attachment: model.uml
(Size: 14.60KB, Downloaded 206 times) -
Attachment: model.uml
(Size: 14.60KB, Downloaded 216 times)
|
|
|
Re: Error in package registration while loading state machine from .uml [message #1732973 is a reply to message #1732751] |
Mon, 23 May 2016 13:38 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
By now you should find many links that tell you that you must call
UMLResourcesUtil.init().
Regards
Ed Willink
On 23/05/2016 06:33, Syed Samsul Arefin wrote:
> Hi,
> I am quite new in this field and it's maybe an awkward question. I have a model that contains two state machines. I need to parse this uml in a standalone application. I believe EMF would save tons of time. So, I read EMF tutorial and wrote this code to load the uml file.
>
>
>
> public static void main(String[] args) {
> ResourceSet set = new ResourceSetImpl();
> set.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
> set.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
>
> Resource res = set.getResource(URI.createFileURI("resources/model.uml"), true);
> res.getContents().get(0);
> }
>
>
>
> but it gives me the following error,
>
>
> Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/uml2/types/TypesPackage
> at org.eclipse.uml2.uml.internal.impl.UMLPackageImpl.init(UMLPackageImpl.java:1907)
> at org.eclipse.uml2.uml.UMLPackage.<clinit>(UMLPackage.java:83)
> at mp.m2bt.BTGenerator.main(BTGenerator.java:31)
> Caused by: java.lang.ClassNotFoundException: org.eclipse.uml2.types.TypesPackage
> at java.net.URLClassLoader.findClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> ... 3 more
>
>
> I am using the following external jars
>
> org.eclipse.emf.common_2.11.1.v20160208-0816.jar
> org.eclipse.emf.ecore.xmi_2.11.1.v20160208-0816.jar
> org.eclipse.emf.ecore_2.11.2.v20160208-0816.jar
> org.eclipse.emf.mapping.ecore2xml_2.9.0.v20160208-0841.jar
> org.eclipse.uml2.common_2.1.0.v20160201-0816.jar
> org.eclipse.uml2.uml_5.1.2.v20160201-0816.jar
>
> I also checked these links but still no luck.
>
> https://www.eclipse.org/forums/index.php/t/360956/
>
> and stackoverflow links:
> /questions/34055936/how-can-i-load-a-papyrus-uml-model-by-using-java
>
> /questions/13881825/load-uml-statechart-model-with-emf-that-has-an-applied-profile
>
> /questions/1404343/eclipse-modelling-framework-emf-how-to-get-the-domainmodel-from-a-magicdraw-u
>
> I am not sure what did I do wrong. So, could anybody please help me? Thanks.
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03832 seconds