Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 Tools » NoSuchMethodError while trying to get Resource
NoSuchMethodError while trying to get Resource [message #882659] Wed, 06 June 2012 23:43 Go to next message
max power is currently offline max power
Messages: 9
Registered: May 2012
Junior Member
I try to import an xmi file with uml classes inside.

The file:

<?xml version="1.0" encoding="UTF-8"?>
<uml:Package xmi:version="2.1" xmlns:xmi="http:||schema.omg.org/spec/XMI/2.1" xmlns:uml="http:||www.eclipse.org/uml2/3.0.0/UML" xmi:id="_OhYn4KZfEeGHZNv_aIvRtQ">
  <packagedElement xmi:type="uml:Class" xmi:id="_TKSFoKZfEeGHZNv_aIvRtQ" name="ClassA">
    <ownedAttribute xmi:id="_cPGVEKZfEeGHZNv_aIvRtQ" name="surname"/>
  </packagedElement>
  <packagedElement xmi:type="uml:Class" xmi:id="_ZDn3kKZfEeGHZNv_aIvRtQ" name="ClassB">
    <ownedAttribute xmi:id="_jD3NcKZfEeGHZNv_aIvRtQ" name="age"/>
  </packagedElement>
</uml:Package>


I use following code:

		ResourceSet resourceSet = new ResourceSetImpl();

		Registry packageRegistry = resourceSet.getPackageRegistry();

		packageRegistry.put("http:||schema.omg.org/spec/XMI/2.1", UMLPackage.eINSTANCE);

		packageRegistry.put("http:||schema.omg.org/spec/UML/2.1", UMLPackage.eINSTANCE);

		Map<String, Object> extensionToFactoryMap = resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap();

		extensionToFactoryMap.put(XMI2UMLResource.FILE_EXTENSION, new XMIResourceFactoryImpl());
		resourceSet.getLoadOptions().put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);


I have tried several ways of getting the resource:

Resource resource = resourceSet.createResource(uri);
resource.load(file.getInputStream(), null);


or this

Resource resource = resourceSet.getResource(uri, true);


and finally this:

Package root = UML2Util.load(resourceSet, uri, UMLPackage.Literals.PACKAGE);


While getting the resource I always get following exception:

java.lang.NoSuchMethodError: org.eclipse.uml2.uml.internal.impl.ElementImpl.eBasicAdapterArray()[Lorg/eclipse/emf/common/notify/Adapter;
	at org.eclipse.uml2.uml.internal.impl.ElementImpl.eNotify(ElementImpl.java:964)
	at org.eclipse.uml2.uml.internal.impl.NamedElementImpl.setName(NamedElementImpl.java:268)
	at org.eclipse.uml2.uml.internal.impl.ClassImpl.eSet(ClassImpl.java:1563)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:1071)
	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHelperImpl.java:1154)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2643)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setAttribValue(XMLHandler.java:2702)
	at org.eclipse.emf.ecore.xmi.impl.SAXXMIHandler.handleObjectAttribs(SAXXMIHandler.java:85)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFactory(XMLHandler.java:2178)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromTypeName(XMLHandler.java:2081)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHandler.java:2016)
	at org.eclipse.emf.ecore.xmi.impl.XMIHandler.createObject(XMIHandler.java:131)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLHandler.java:1799)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1023)
	at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:87)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1001)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:712)
	at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:167)
	at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
	at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
	at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:181)
	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:180)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1445)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1241)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:255)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:270)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:397)
	at de.infoasset.xmiModelImport.XMImodelImport.importXMImodel(XMImodelImport.java:36)
	at de.infoasset.emf2hybridWiki.handler.SubmitHandler.importXMImodel(SubmitHandler.java:329)
	at de.infoasset.emf2hybridWiki.handler.SubmitHandler.doBusinessLogic(SubmitHandler.java:100)
	at de.infoasset.platform.handler.Handler.doDoDoBusinessLogic(Handler.java:195)
	at de.infoasset.platform.handler.Handler.doDoBusinessLogic(Handler.java:214)
	at de.infoasset.platform.handler.Handler.handleRequestGetStation(Handler.java:173)
	at de.infoasset.platform.handler.Handler.handleRequest(Handler.java:115)
	at de.infoasset.platform.handler.Handler.getResponse(Handler.java:101)
	at de.infoasset.platform.client.RequestDispatcher.handleRequest(RequestDispatcher.java:73)
	at de.infoasset.platform.server.WebServer$1.handle(WebServer.java:209)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:973)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:194)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:907)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
	at de.infoasset.platform.server.WebServer$3.handle(WebServer.java:294)
	at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:47)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)
	at org.eclipse.jetty.server.Server.handle(Server.java:346)
	at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:442)
	at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:941)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:801)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:224)
	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:51)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)
	at java.lang.Thread.run(Unknown Source)


I've been trying to implement the import for two weeks now. Need help!

Many thanks in advance!
Re: NoSuchMethodError while trying to get Resource [message #882781 is a reply to message #882659] Thu, 07 June 2012 07:30 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26054
Registered: July 2009
Senior Member
Max,

You're using an older EMF library/jar with a newer UML.


On 07/06/2012 1:43 AM, max power wrote:
> I try to import an xmi file with uml classes inside.
>
> The file:
> <?xml version="1.0" encoding="UTF-8"?>
> <uml:Package xmi:version="2.1"
> xmlns:xmi="http:||schema.omg.org/spec/XMI/2.1"
> xmlns:uml="http:||www.eclipse.org/uml2/3.0.0/UML"
> xmi:id="_OhYn4KZfEeGHZNv_aIvRtQ">
> <packagedElement xmi:type="uml:Class" xmi:id="_TKSFoKZfEeGHZNv_aIvRtQ"
> name="ClassA">
> <ownedAttribute xmi:id="_cPGVEKZfEeGHZNv_aIvRtQ" name="surname"/>
> </packagedElement>
> <packagedElement xmi:type="uml:Class" xmi:id="_ZDn3kKZfEeGHZNv_aIvRtQ"
> name="ClassB">
> <ownedAttribute xmi:id="_jD3NcKZfEeGHZNv_aIvRtQ" name="age"/>
> </packagedElement>
> </uml:Package>
>
> I use following code:
>
>
> ResourceSet resourceSet = new ResourceSetImpl();
>
> Registry packageRegistry = resourceSet.getPackageRegistry();
>
> packageRegistry.put("http:||schema.omg.org/spec/XMI/2.1",
> UMLPackage.eINSTANCE);
>
> packageRegistry.put("http:||schema.omg.org/spec/UML/2.1",
> UMLPackage.eINSTANCE);
>
> Map<String, Object> extensionToFactoryMap =
> resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap();
>
> extensionToFactoryMap.put(XMI2UMLResource.FILE_EXTENSION, new
> XMIResourceFactoryImpl());
>
> resourceSet.getLoadOptions().put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE,
> Boolean.TRUE);
>
> I have tried several ways of getting the resource:
>
>
> Resource resource = resourceSet.createResource(uri);
> resource.load(file.getInputStream(), null);
>
> or this
>
> Resource resource = resourceSet.getResource(uri, true);
>
> and finally this:
>
> Package root = UML2Util.load(resourceSet, uri,
> UMLPackage.Literals.PACKAGE);
>
> While getting the resource I always get following exception:
>
> java.lang.NoSuchMethodError:
> org.eclipse.uml2.uml.internal.impl.ElementImpl.eBasicAdapterArray()[Lorg/eclipse/emf/common/notify/Adapter;
> at
> org.eclipse.uml2.uml.internal.impl.ElementImpl.eNotify(ElementImpl.java:964)
> at
> org.eclipse.uml2.uml.internal.impl.NamedElementImpl.setName(NamedElementImpl.java:268)
> at
> org.eclipse.uml2.uml.internal.impl.ClassImpl.eSet(ClassImpl.java:1563)
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:1071)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHelperImpl.java:1154)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2643)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setAttribValue(XMLHandler.java:2702)
> at
> org.eclipse.emf.ecore.xmi.impl.SAXXMIHandler.handleObjectAttribs(SAXXMIHandler.java:85)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFactory(XMLHandler.java:2178)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromTypeName(XMLHandler.java:2081)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHandler.java:2016)
> at
> org.eclipse.emf.ecore.xmi.impl.XMIHandler.createObject(XMIHandler.java:131)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLHandler.java:1799)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1023)
> at
> org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:87)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1001)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:712)
> at
> org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:167)
> at
> org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
> Source)
> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
> at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
> at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
> at
> org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
> at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:181)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:180)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1445)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1241)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:255)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:270)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:397)
> at
> de.infoasset.xmiModelImport.XMImodelImport.importXMImodel(XMImodelImport.java:36)
> at
> de.infoasset.emf2hybridWiki.handler.SubmitHandler.importXMImodel(SubmitHandler.java:329)
> at
> de.infoasset.emf2hybridWiki.handler.SubmitHandler.doBusinessLogic(SubmitHandler.java:100)
> at
> de.infoasset.platform.handler.Handler.doDoDoBusinessLogic(Handler.java:195)
> at
> de.infoasset.platform.handler.Handler.doDoBusinessLogic(Handler.java:214)
> at
> de.infoasset.platform.handler.Handler.handleRequestGetStation(Handler.java:173)
> at
> de.infoasset.platform.handler.Handler.handleRequest(Handler.java:115)
> at
> de.infoasset.platform.handler.Handler.getResponse(Handler.java:101)
> at
> de.infoasset.platform.client.RequestDispatcher.handleRequest(RequestDispatcher.java:73)
> at
> de.infoasset.platform.server.WebServer$1.handle(WebServer.java:209)
> at
> org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233)
> at
> org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:973)
> at
> org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:194)
> at
> org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:907)
> at
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
> at
> de.infoasset.platform.server.WebServer$3.handle(WebServer.java:294)
> at
> org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:47)
> at
> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)
> at org.eclipse.jetty.server.Server.handle(Server.java:346)
> at
> org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:442)
> at
> org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:941)
> at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:801)
> at
> org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:224)
> at
> org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:51)
> at
> org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586)
> at
> org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44)
> at
> org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)
> at
> org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)
> at java.lang.Thread.run(Unknown Source)
>
> I've been trying to implement the import for two weeks now. Need help!
>
> Many thanks in advance!
>
Re: NoSuchMethodError while trying to get Resource [message #882823 is a reply to message #882781] Thu, 07 June 2012 09:14 Go to previous messageGo to next message
max power is currently offline max power
Messages: 9
Registered: May 2012
Junior Member
Ed, thank you for your reply.

I am using following jars in my project. I thought these are from the latest releases.

org.eclipse.emf.common_2.7.0.v20110605-0747.jar
org.eclipse.emf.ecore_2.7.0.v20110605-0747.jar
org.eclipse.emf.ecore.xmi_2.7.0.v20110520-1406.jar

org.eclipse.uml2.common_1.6.0.v201105021727.jar
org.eclipse.uml2.uml_3.2.100.v201108110105.jar



The uml jars are from the mdt-uml2-SDK-3.2.1 (plugins folder).

The emf jars are from emf-xsd-SDK-2.7.0.
Re: NoSuchMethodError while trying to get Resource [message #883002 is a reply to message #882823] Thu, 07 June 2012 16:04 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26054
Registered: July 2009
Senior Member
I'm sure EMF 2.7 has that method, so I kind of doubt you're actually
using that in the application you're running. Is it a web server
application?


On 07/06/2012 11:14 AM, max power wrote:
> Ed, thank you for your reply.
>
> I am using following jars in my project. I thought these are from the
> latest releases.
>
>
> org.eclipse.emf.common_2.7.0.v20110605-0747.jar
> org.eclipse.emf.ecore_2.7.0.v20110605-0747.jar
> org.eclipse.emf.ecore.xmi_2.7.0.v20110520-1406.jar
>
> org.eclipse.uml2.common_1.6.0.v201105021727.jar
> org.eclipse.uml2.uml_3.2.100.v201108110105.jar
>
>
>
> The uml jars are from the mdt-uml2-SDK-3.2.1 (plugins folder).
>
> The emf jars are from emf-xsd-SDK-2.7.0.
Re: NoSuchMethodError while trying to get Resource [message #884474 is a reply to message #883002] Mon, 11 June 2012 06:29 Go to previous message
max power is currently offline max power
Messages: 9
Registered: May 2012
Junior Member
This is a web server application. And I figured out the problem: there was another java project that used old libraries and these libraries were somehow applied to the new project, although I explicitly set the newer ones in the Build Path.
Previous Topic:Activity diagram: manipulation with Eclipse
Next Topic:Unable to load UML model in stand alone application
Goto Forum:
  


Current Time: Mon Sep 22 04:17:19 GMT 2014

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

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