Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » loading .uml / .xmi files in eclipse
loading .uml / .xmi files in eclipse [message #985776] Fri, 16 November 2012 06:53 Go to next message
Toqeer Israr is currently offline Toqeer IsrarFriend
Messages: 4
Registered: November 2012
Junior Member
Hi

I am a complete newbie at Eclipse and UML 2 plugins. I created an activity model in Rational Software Architect and exported as .emx and also as .uml

I am trying to load either of these file in Eclipse such that I would be able to retrieve the model information programatically.

I followed the "improved" tutorial to load the files at https://bugs.eclipse.org/bugs/attachment.cgi?id=217415.


public static void main(String[] args) {
// TODO Auto-generated method stub
PerfEngine engine = new PerfEngine();
engine.analyze();

}

private void analyze() {

ResourceSet resourceSet1 = new ResourceSetImpl();
UML300ResourcesUtil.init(resourceSet1);

URI uri1 = URI.createURI("TMS_xmi.xmi");
Model loadedModel1 = (Model) load(resourceSet1, uri1);
System.out.println(loadedModel1);

ResourceSet resourceSet2 = new ResourceSetImpl();
UML300ResourcesUtil.init(resourceSet2);

URI uri2 = URI.createURI("TMS_uml.uml");
Model loadedModel2 = (Model) load(resourceSet2, uri2);
System.out.println(loadedModel2);

}



I am using the functions from the attached .zip file of the tutorial(link given above) but every time I try to run this, I get the following error message:

Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/emf/mapping/ecore2xml/Ecore2XMLRegistry
at org.eclipse.uml2.uml.resource.UML212UMLResource$Factory.<clinit>(UML212UMLResource.java:31)
at perf.UML300ResourcesUtil.init(UML300ResourcesUtil.java:221)
at perf.PerfEngine.analyze(PerfEngine.java:67)
at perf.PerfEngine.main(PerfEngine.java:61)
Caused by: java.lang.ClassNotFoundException: org.eclipse.emf.mapping.ecore2xml.Ecore2XMLRegistry
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
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)
... 4 more


I really really would appreciate anyone's help in the above or if there is a simpler way of loading the files. At the end of the day, I wish to traverse the meta-model of input model.

Thanks

Toqeer
P.S. I am using:
Eclipse IDE for Java Developers
Version: Juno Service Release 1
Build id: 20120920-0800
Re: loading .uml / .xmi files in eclipse [message #985884 is a reply to message #985776] Fri, 16 November 2012 14:49 Go to previous messageGo to next message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

Hi,

You need to have the org.eclipse.emf.mapping.ecore2xml plug-in in your
run-time configuration if you are trying to load UML2 3.0 models in a
Juno Eclipse configuration.

But, as you are running this as a java application, you need to have
the org.eclipse.emf.mapping.ecore2xml_<version>.jar on your
application's classpath. (where <version> is just some version
identifier for the EMF release)

HTH,

Christian


On 2012-11-16 13:59:33 +0000, Toqeer Israr said:

> Hi
>
> I am a complete newbie at Eclipse and UML 2 plugins. I created an
> activity model in Rational Software Architect and exported as .emx and
> also as .uml
>
> I am trying to load either of these file in Eclipse such that I would
> be able to retrieve the model information programatically.
>
> I followed the "improved" tutorial to load the files at
> https://bugs.eclipse.org/bugs/attachment.cgi?id=217415.
>
>
> public static void main(String[] args) {
> // TODO Auto-generated method stub
> PerfEngine engine = new PerfEngine();
> engine.analyze();
>
> }
>
> private void analyze() {
>
> ResourceSet resourceSet1 = new ResourceSetImpl();
> UML300ResourcesUtil.init(resourceSet1);
>
> URI uri1 = URI.createURI("TMS_xmi.xmi");
> Model loadedModel1 = (Model) load(resourceSet1, uri1);
> System.out.println(loadedModel1);
>
> ResourceSet resourceSet2 = new ResourceSetImpl();
> UML300ResourcesUtil.init(resourceSet2);
>
> URI uri2 = URI.createURI("TMS_uml.uml");
> Model loadedModel2 = (Model) load(resourceSet2, uri2);
> System.out.println(loadedModel2);
>
> }
>
>
>
> I am using the functions from the attached .zip file of the
> tutorial(link given above) but every time I try to run this, I get the
> following error message:
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/eclipse/emf/mapping/ecore2xml/Ecore2XMLRegistry
> at
> org.eclipse.uml2.uml.resource.UML212UMLResource$Factory.<clinit>(UML212UMLResource.java:31)
>
> at perf.UML300ResourcesUtil.init(UML300ResourcesUtil.java:221)
> at perf.PerfEngine.analyze(PerfEngine.java:67)
> at perf.PerfEngine.main(PerfEngine.java:61)
> Caused by: java.lang.ClassNotFoundException:
> org.eclipse.emf.mapping.ecore2xml.Ecore2XMLRegistry
> at java.net.URLClassLoader$1.run(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
> 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)
> ... 4 more
>
>
> I really really would appreciate anyone's help in the above or if there
> is a simpler way of loading the files. At the end of the day, I wish
> to traverse the meta-model of input model.
>
> Thanks
>
> Toqeer
> P.S. I am using:
> Eclipse IDE for Java Developers
> Version: Juno Service Release 1
> Build id: 20120920-0800
> <image><image><image>
Re: loading .uml / .xmi files in eclipse [message #985900 is a reply to message #985884] Fri, 16 November 2012 15:44 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Toqeer, Christain

The tutorial was prepared just during the Juno RCs. Further problems
with UML content registrations showed up and are 'finally' fixed in Juno
SR1.

Whether running standalone or not, content type registrations must be in
the local ResourceSet and a *.uml extension registration must be in the
global registry. This happens pretty automatically within Eclipse, and
can now happen fully by calling UMLResourcesUtil.init(localResourceSet).

UML300ResourcesUtil was an attempt to reverse migrate UMLResourcesUtil
from 4.0 to 3.0. It needs updating to reflect abandoning the option of
using only global registries.

The ecore2xml mapping now uses a local ResourceSet with appropriate
local registrations, so if you use a plugin maifest to compute your
classpath it should be easy.

If you are determined to use your own classpath; good luck.

Regards

Ed Willink


On 16/11/2012 14:49, Christian W. Damus wrote:
> Hi,
>
> You need to have the org.eclipse.emf.mapping.ecore2xml plug-in in your
> run-time configuration if you are trying to load UML2 3.0 models in a
> Juno Eclipse configuration.
>
> But, as you are running this as a java application, you need to have
> the org.eclipse.emf.mapping.ecore2xml_<version>.jar on your
> application's classpath. (where <version> is just some version
> identifier for the EMF release)
>
> HTH,
>
> Christian
>
>
> On 2012-11-16 13:59:33 +0000, Toqeer Israr said:
>
>> Hi
>>
>> I am a complete newbie at Eclipse and UML 2 plugins. I created an
>> activity model in Rational Software Architect and exported as .emx
>> and also as .uml
>>
>> I am trying to load either of these file in Eclipse such that I would
>> be able to retrieve the model information programatically.
>>
>> I followed the "improved" tutorial to load the files at
>> https://bugs.eclipse.org/bugs/attachment.cgi?id=217415.
>>
>>
>> public static void main(String[] args) {
>> // TODO Auto-generated method stub
>> PerfEngine engine = new PerfEngine();
>> engine.analyze();
>>
>> }
>>
>> private void analyze() {
>>
>> ResourceSet resourceSet1 = new ResourceSetImpl();
>> UML300ResourcesUtil.init(resourceSet1);
>>
>> URI uri1 = URI.createURI("TMS_xmi.xmi");
>> Model loadedModel1 = (Model) load(resourceSet1, uri1);
>> System.out.println(loadedModel1);
>>
>> ResourceSet resourceSet2 = new ResourceSetImpl();
>> UML300ResourcesUtil.init(resourceSet2);
>>
>> URI uri2 = URI.createURI("TMS_uml.uml");
>> Model loadedModel2 = (Model) load(resourceSet2, uri2);
>> System.out.println(loadedModel2);
>>
>> }
>>
>>
>>
>> I am using the functions from the attached .zip file of the
>> tutorial(link given above) but every time I try to run this, I get
>> the following error message:
>>
>> Exception in thread "main" java.lang.NoClassDefFoundError:
>> org/eclipse/emf/mapping/ecore2xml/Ecore2XMLRegistry
>> at
>> org.eclipse.uml2.uml.resource.UML212UMLResource$Factory.<clinit>(UML212UMLResource.java:31)
>>
>> at perf.UML300ResourcesUtil.init(UML300ResourcesUtil.java:221)
>> at perf.PerfEngine.analyze(PerfEngine.java:67)
>> at perf.PerfEngine.main(PerfEngine.java:61)
>> Caused by: java.lang.ClassNotFoundException:
>> org.eclipse.emf.mapping.ecore2xml.Ecore2XMLRegistry
>> at java.net.URLClassLoader$1.run(Unknown Source)
>> at java.security.AccessController.doPrivileged(Native Method)
>> 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)
>> ... 4 more
>>
>>
>> I really really would appreciate anyone's help in the above or if
>> there is a simpler way of loading the files. At the end of the day,
>> I wish to traverse the meta-model of input model.
>>
>> Thanks
>>
>> Toqeer
>> P.S. I am using:
>> Eclipse IDE for Java Developers
>> Version: Juno Service Release 1
>> Build id: 20120920-0800
>> <image><image><image>
>
>
Re: loading .uml / .xmi files in eclipse [message #986121 is a reply to message #985900] Mon, 19 November 2012 04:29 Go to previous messageGo to next message
Toqeer Israr is currently offline Toqeer IsrarFriend
Messages: 4
Registered: November 2012
Junior Member
Hello Folks,

So I tried it with:

private void analyze() {
ResourceSet resourceSet1 = new ResourceSetImpl();
// UML300ResourcesUtil.init(resourceSet1);
UMLResourcesUtil.init(resourceSet1);

ResourceSet resourceSet2 = new ResourceSetImpl();
// UML300ResourcesUtil.init(resourceSet2);
UMLResourcesUtil.init(resourceSet2);


URI uri1 = URI.createURI("TMS_xmi.xmi");
Model loadedModel1 = (Model) UMLUtil.load(resourceSet1, uri1,
UMLPackage.Literals.MODEL);
System.out.println(loadedModel1);

URI uri2 = URI.createURI("TMS_uml.uml");
Model loadedModel2 = (Model) UMLUtil.load(resourceSet2, uri2,
UMLPackage.Literals.MODEL);
System.out.println(loadedModel2);


}

and both outputs return the models as null. Output: null null

-----------------

I tried with the "older but updated" tutorial with init of the UML300ResourceUtil. I forgot to mention this in the initial post that with the UML300ResourceUtil code, I was using the "load" function which came with the tutorial and not the UMLUtil.load
The load function which I used with UML300ResourceUtil was:

public static org.eclipse.uml2.uml.Package load(ResourceSet resourceSet,
URI uri) {
Resource resource = resourceSet.createResource(uri);

try {
resource.load(null);
org.eclipse.uml2.uml.Package package_ = (org.eclipse.uml2.uml.Package) resource
.getContents().get(0);
out("Loaded '" + package_.getQualifiedName() + "' from '" + uri
+ "'.");
return package_;
} catch (IOException ioe) {
err(ioe.getMessage());
return null;

}

}

After adding the external libraries as suggested I resolved the initial errors but now I get the following error:
Exception in thread "main" java.lang.NullPointerException
at perf.PerfEngine.load(PerfEngine.java:81)
at perf.PerfEngine.analyze(PerfEngine.java:66)
at perf.PerfEngine.main(PerfEngine.java:51)



Appreciate any help/hints you may suggest.


Thanks

Toqeer
Re: loading .uml / .xmi files in eclipse [message #986137 is a reply to message #986121] Mon, 19 November 2012 07:04 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You force us to guess at how analyze might be invoked. Please provide a
zipped project if you want detailed help.

Regards

Ed Willink


On 19/11/2012 04:29, Toqeer Israr wrote:
> Hello Folks,
>
> So I tried it with:
>
> private void analyze() {
> ResourceSet resourceSet1 = new ResourceSetImpl();
> // UML300ResourcesUtil.init(resourceSet1);
> UMLResourcesUtil.init(resourceSet1);
>
> ResourceSet resourceSet2 = new ResourceSetImpl();
> // UML300ResourcesUtil.init(resourceSet2);
> UMLResourcesUtil.init(resourceSet2);
>
>
> URI uri1 = URI.createURI("TMS_xmi.xmi");
> Model loadedModel1 = (Model) UMLUtil.load(resourceSet1, uri1,
> UMLPackage.Literals.MODEL);
> System.out.println(loadedModel1);
>
> URI uri2 = URI.createURI("TMS_uml.uml");
> Model loadedModel2 = (Model) UMLUtil.load(resourceSet2, uri2,
> UMLPackage.Literals.MODEL);
> System.out.println(loadedModel2);
>
>
> }
>
> and both outputs return the models as null. Output: null null
>
> -----------------
>
> I tried with the "older but updated" tutorial with init of the
> UML300ResourceUtil. I forgot to mention this in the initial post that
> with the UML300ResourceUtil code, I was using the "load" function
> which came with the tutorial and not the UMLUtil.load The load
> function which I used with UML300ResourceUtil was:
>
> public static org.eclipse.uml2.uml.Package load(ResourceSet
> resourceSet,
> URI uri) {
> Resource resource = resourceSet.createResource(uri);
>
> try {
> resource.load(null);
> org.eclipse.uml2.uml.Package package_ =
> (org.eclipse.uml2.uml.Package) resource
> .getContents().get(0);
> out("Loaded '" + package_.getQualifiedName() + "' from '"
> + uri
> + "'.");
> return package_;
> } catch (IOException ioe) {
> err(ioe.getMessage());
> return null;
>
> }
>
> }
>
> After adding the external libraries as suggested I resolved the
> initial errors but now I get the following error:
> Exception in thread "main" java.lang.NullPointerException
> at perf.PerfEngine.load(PerfEngine.java:81)
> at perf.PerfEngine.analyze(PerfEngine.java:66)
> at perf.PerfEngine.main(PerfEngine.java:51)
>
>
>
> Appreciate any help/hints you may suggest.
>
>
> Thanks
>
> Toqeer
Re: loading .uml / .xmi files in eclipse [message #986179 is a reply to message #986137] Mon, 19 November 2012 10:33 Go to previous messageGo to next message
Vlad Varnica is currently offline Vlad VarnicaFriend
Messages: 546
Registered: July 2009
Location: Milton Keynes - UK
Senior Member
I think that RSA is compatible with UML 2.2 or 2.3 therefore you need to use Eclipse 3.7.
Re: loading .uml / .xmi files in eclipse [message #986285 is a reply to message #986137] Mon, 19 November 2012 18:14 Go to previous messageGo to next message
Toqeer Israr is currently offline Toqeer IsrarFriend
Messages: 4
Registered: November 2012
Junior Member
Hello


Thank you for the previous above suggestions. Please see attached the zipped project.
I appreciate your help.

Toqeer
  • Attachment: POS.zip
    (Size: 18.90KB, Downloaded 323 times)
Re: loading .uml / .xmi files in eclipse [message #986314 is a reply to message #986285] Mon, 19 November 2012 21:43 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

I've checked https://bugs.eclipse.org/bugs/attachment.cgi?id=217415; it
still workd on Kepler M3.

Your code seems to completely omit most of GettingStartedUtils.init();
in particular the URI map settings. You'll find them useful.

Regards

Ed Willink


On 19/11/2012 18:14, Toqeer Israr wrote:
> Hello
>
>
> Thank you for the previous above suggestions. Please see attached the zipped project.
> I appreciate your help.
>
> Toqeer
Previous Topic:xmi:id get lost when saving Resource
Next Topic:Empty Build Dependencies
Goto Forum:
  


Current Time: Tue Apr 23 09:01:23 GMT 2024

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

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

Back to the top