Skip to main content



      Home
Home » Modeling » EMF » Error in package registration while loading state machine from .uml
icon5.gif  Error in package registration while loading state machine from .uml [message #1732751] Thu, 19 May 2016 10:13 Go to next message
Eclipse UserFriend
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 237 times)
  • Attachment: model.uml
    (Size: 14.60KB, Downloaded 248 times)
Re: Error in package registration while loading state machine from .uml [message #1732973 is a reply to message #1732751] Mon, 23 May 2016 09:38 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: Error in package registration while loading state machine from .uml [message #1733010 is a reply to message #1732973] Mon, 23 May 2016 06:00 Go to previous messageGo to next message
Eclipse UserFriend
Ed, Thanks for your reply.
 UMLResourcesUtil.init(set);
is throwing this runtime error
java.lang.NoClassDefFoundError: org/eclipse/uml2/types/TypesPackage

I tried refreshing/cleaning the project, but still it's this runtime errror. Any idea?
Re: Error in package registration while loading state machine from .uml [message #1733058 is a reply to message #1733010] Tue, 24 May 2016 03:09 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

> UMLResourcesUtil.init(set); is throwing this runtime error java.lang.NoClassDefFoundError: org/eclipse/uml2/types/TypesPackage


Your problem seems to be a missing jar in the classpath.

From the list of jars in your previous post it seems you are using
Eclipse UML2 5.1.2

> 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
>

the missing class org/eclipse/uml2/types/TypesPackage
is in jar

org.eclipse.uml2.types_2.0.0.v20160201-0816.jar


You may also found later that you will need :

org.eclipse.uml2.uml.resources_5.1.0.v20160201-0816.jar

Setting up properly the classpath of an Eclipse UML2 standalone program
requires some time and lot of patience, and unfortunately is not
properly documented as the versions evolve, although you find many
useful discussions in the UML2 newsgroup

My own personal approach is to start with a classpath including ALL the
plugins in the "UML2 runtime" zip, and from there removing jars that I
suspect I don't need (mainly edit and codegen named jars) one by one
until I get the minimal classpath.

To download the runtime zip go to
http://www.eclipse.org/modeling/mdt/downloads/?project=uml2

and select "runtime" in the release 5.1.2 section

or directly

http://www.eclipse.org/modeling/download.php?file=/modeling/mdt/uml2/downloads/drops/5.1.2/R201602010816/mdt-uml2-runtime-5.1.2.zip



regards

German Vega
Re: Error in package registration while loading state machine from .uml [message #1733131 is a reply to message #1733058] Tue, 24 May 2016 12:10 Go to previous messageGo to next message
Eclipse UserFriend
Vega,
Great! It solves the issue. Now I am getting some more error. I hope UML2 runtime will fix those.
Thanks a lot.

[Updated on: Tue, 24 May 2016 05:06] by Moderator

Re: Error in package registration while loading state machine from .uml [message #1754027 is a reply to message #1732751] Mon, 13 February 2017 17:32 Go to previous messageGo to next message
Eclipse UserFriend
Can you help me with the same problem?
Re: Error in package registration while loading state machine from .uml [message #1754125 is a reply to message #1754027] Tue, 14 February 2017 11:03 Go to previous message
Eclipse UserFriend
What exactly is not working for you? what are you trying to do?
Previous Topic:[XCORE] Modify "Couldn't resolve reference" error
Next Topic:Releasing memory when closing a model
Goto Forum:
  


Current Time: Sat Jul 19 08:48:33 EDT 2025

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

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

Back to the top