Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » HOW to register UML resources?
HOW to register UML resources? [message #631318] Thu, 07 October 2010 03:31 Go to next message
hutzu  is currently offline hutzu
Messages: 15
Registered: September 2010
Junior Member
I am already have a ecore parser with OCL ,so I always want to do little change to parser UML with OCL.
But so far , it seems more difficult than ecore .
In ecore:
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(
"ecore", new EcoreResourceFactoryImpl());

URI myEcoreURI = URI.createFileURI(file.getAbsolutePath()); //file is .ecore file.
Resource myEcoreResource = resourceSet.getResource(myEcoreURI, true);

i can easily get my resource.

But in UML:
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "uml", new UMLResourceFactoryImpl());
URI UMLuri = URI.createFileURI(umlfile.getAbsolutePath()); umlfile is .uml file.
***Resource resource = resourceSet.getResource(UMLuri, true);

I got exception about my resources...OH my goodness!

Exception in thread "main" java.lang.NoSuchMethodError: org.eclipse.emf.ecore.resource.URIConverter.createInputStrea m(Lorg/eclipse/emf/common/util/URI;Ljava/util/Map;)Ljava/io/ InputStream;
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(X MLHandler.java:2533)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefi x(XMLHandler.java:2421)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1299)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1468)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:1019)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.javple

Please help me!!!
how to get my UML resources?
best regards
hutzu
Re: HOW to register UML resources? [message #631321 is a reply to message #631318] Thu, 07 October 2010 04:59 Go to previous messageGo to next message
Rafael Chaves is currently offline Rafael Chaves
Messages: 161
Registered: July 2009
Senior Member
Hutzu,

A NoSuchMethodError exception means the client code (in this case, UML2) was compiled against a version of the provider code (in this case, EMF) that defined the method, but it is being run against another that does not have the method.

You need to ensure you use a UML2 version that matches the EMF version you are using.

See:

http://www.eclipse.org/modeling/mdt/downloads/?project=uml2

for the available UML2 versions and the corresponding build dependencies (at least for more recent UML2 releases).

Cheers,

Rafael
http://abstratt.com
Re: HOW to register UML resources? [message #631966 is a reply to message #631321] Mon, 11 October 2010 05:00 Go to previous message
hutzu  is currently offline hutzu
Messages: 15
Registered: September 2010
Junior Member
Thanks a lot,Rafael
it really work~

My objective is to parse class diagram with OCL.
In ecore , first i need to parse ecore diagram to get "ArrayList<EPackageImpl> ".
shall i do the same thing in UML2 class diagram?

To write a parser to get ArrayList<EPackageImpl> , and then register the UML2
am i right?

best regards
hutzu
Previous Topic:How to add child nodes using the reflective API of EMF?
Next Topic:[EMF / GMF / UML] Modify model element cause diagram corrupted
Goto Forum:
  


Current Time: Thu Sep 18 03:48:24 GMT 2014

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

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