Problem loading UML in stand alone application [message #846630] |
Mon, 16 April 2012 07:45  |
Eclipse User |
|
|
|
Hey,
This might be a simple problem, but I've had no success solving it so far, even though I tried a couple of different solutions found on this forum and in the EMF FAQ. But back to the problem at hand.
I'm trying to load an UML model in a stand alone application, but for most of the solutions I've tried I've gotten the following result: "NoClassDefFoundError".
I'm using the following code
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.uml2.uml.Model;
import org.eclipse.uml2.uml.UMLPackage;
import org.eclipse.uml2.uml.resource.UMLResource;
public class ModelCode {
private URI typesUri = null;
public Model getModel(String pathToModel) {
typesUri = URI.createFileURI(pathToModel);
ResourceSet set = new ResourceSetImpl();
set.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
set.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
UMLPackage.eINSTANCE.eClass();
set.createResource(typesUri);
Resource r = null;
r = set.getResource(typesUri, true);
Model m = (Model) EcoreUtil.getObjectByType(r.getContents(), UMLPackage.Literals.MODEL);
return m;
}
}
When debugging I'm encountering the error at "r = set.getResource(typesUri, true);". The following is the error message I'm getting when trying to run this code.
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/uml2/common/util/CacheAdapter
at org.eclipse.uml2.uml.internal.impl.ElementImpl.getCacheAdapter(ElementImpl.java:818)
at org.eclipse.uml2.uml.internal.impl.ElementImpl.eNotificationRequired(ElementImpl.java:955)
at org.eclipse.uml2.uml.internal.impl.NamedElementImpl.setName(NamedElementImpl.java:267)
at org.eclipse.uml2.uml.internal.impl.PackageImpl.eSet(PackageImpl.java:1455)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:1081)
at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHelperImpl.java:1162)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2658)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setAttribValue(XMLHandler.java:2717)
at org.eclipse.emf.ecore.xmi.impl.SAXXMIHandler.handleObjectAttribs(SAXXMIHandler.java:85)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFactory(XMLHandler.java:2193)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromTypeName(XMLHandler.java:2096)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHandler.java:2031)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.createObject(XMIHandler.java:134)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLHandler.java:1814)
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:169)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.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:242)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1511)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1290)
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:368)
at backboneCode.ModelCode.getModel(ModelCode.java:33)
at eArCon.application.E_ArConHandler.main(E_ArConHandler.java:37)
Caused by: java.lang.ClassNotFoundException: org.eclipse.uml2.common.util.CacheAdapter
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)
... 39 more
Any help will be appreciated.
Thanks!
|
|
|
|
|
|
Re: Problem loading UML in stand alone application [message #1725905 is a reply to message #1725897] |
Tue, 08 March 2016 07:51  |
Eclipse User |
|
|
|
Hi
You really should not use explicit JARs; they keep changing. Use a
tchnology such as MANIFEST.MF that sorts it out for you.
You can see the JAR using Navigate->Open Type Hierarchy, or Show
In->Package EXplorer.
For me, today, it's in org.eclipse.uml2.common_2.1.0.v20160201-0937.jar
Regards
Ed Willink
On 08/03/2016 11:34, Thomas Taeger wrote:
> jy zhang wrote on Fri, 18 May 2012 10:15
>> org.eclipse.uml2.common_1.6.0.v201105021727.jar to your classpath
>
>
> That was in the year 2011. In 2016 adding
> org.eclipse.uml2.common_2.1.0.v20160201-0816.jar instead does not
> resolve the import statement anymore.
>
> Does anybody know which actual jar we have to add today for resolving
> import org.eclipse.uml2.common.util.CacheAdapter; ?
>
> Regards
> Thomas
|
|
|
Powered by
FUDForum. Page generated in 0.08923 seconds