|
|
Re: NoClassDefFoundError: org/eclipse/emf/ecore/EPackage [message #1723843 is a reply to message #1723733] |
Thu, 18 February 2016 12:21 |
Florian Goenner Messages: 15 Registered: December 2015 |
Junior Member |
|
|
UPDATE: There still seem to be Errors occuring!
Specifially speaking, the call final Resource resource = resSet.getResource(URI.createFileURI(filePath), true);
where filepath is "C:/Users/Florian/Desktop/workspace/at.jku.sea.cloud.gmf.adapter.plugin/test/default.mindmap" which is a diagram file, I made with the corresponding GMF graphical editor,
returns me the following stacktrace:
java.lang.NoClassDefFoundError: testpackage/mindmap/impl/MapImpl
at testpackage.mindmap.impl.MindmapFactoryImpl.createMap(MindmapFactoryImpl.java:119)
at testpackage.mindmap.impl.MindmapFactoryImpl.create(MindmapFactoryImpl.java:68)
at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createObject(XMLHelperImpl.java:885)
at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createObject(XMLHelperImpl.java:922)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFactory(XMLHandler.java:2222)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType(XMLHandler.java:1366)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XMLHandler.java:1504)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1026)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:77)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1008)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:719)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:163)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(XMLDTDValidator.java:745)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1363)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$ContentDriver.scanRootElementHook(XMLDocumentScannerImpl.java:1292)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3138)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:880)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:649)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:333)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:261)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1297)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:406)
at at.jku.sea.cloud.modeling.util.transformation.model.ModelTransformation.transformECoreFile(ModelTransformation.java:48)
at at.jku.sea.cloud.gmf.adapter.plugin.cloudinteraction.ModelInteraction.checkInModel(ModelInteraction.java:60)
at at.jku.sea.cloud.gmf.adapter.plugin.app.GMFApplication.start(GMFApplication.java:66)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Caused by: java.lang.ClassNotFoundException: testpackage.mindmap.impl.MapImpl
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 49 more
I am aware that I somehow have to make sure, that all the classes in my generated Mindmap Project are loaded during runtime, but I have absolutely no clue how to achieve that, especially, since I have no clue which Classloader is used during runtime that fails at resolving the dependencies. If anyone could give me a hint I'd be really thankful.
[Updated on: Thu, 18 February 2016 12:23] Report message to a moderator
|
|
|
Re: NoClassDefFoundError: org/eclipse/emf/ecore/EPackage [message #1723909 is a reply to message #1723722] |
Fri, 19 February 2016 04:34 |
|
Am 17.02.2016 um 12:16 schrieb Florian Goenner:
> Greetings!
>
> I am currently trying to access the eInstance Field in order to get the corresponding EPackage of my generated Model
> Project. My Model Project is somewhere on my file system but not necessarily in my eclipse workspace.
Why are you dealing with class loaders at all? From your stack trace it seems you're running an Eclipse/OSGi
application. Why don't you deploy your generated models as plugins and leave class loading to OSGi?
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
> However, when trying to access the class like this:
>
> public static Object registerPackage(String rootPathBin, String basePackage, String projectName, String className)
> throws MalformedURLException{
> URLClassLoader urlClassLoader = URLClassLoader.newInstance(new URL[] {new URL(rootPathBin)});
> try{
> Class<?> generatedClassifierClass = urlClassLoader.loadClass(basePackage+"."+projectName+"."+className);
> Field field = generatedClassifierClass.getDeclaredField("eINSTANCE");
> @SuppressWarnings("unused")
> Object classifier = field.get(null);
> return classifier;
> }catch(ClassNotFoundException | NoSuchFieldException
> | SecurityException | IllegalArgumentException | IllegalAccessException c){
> c.printStackTrace();
> return null;
> }
> }
>
> I end up getting the following:
>
>
> java.lang.NoClassDefFoundError: org/eclipse/emf/ecore/EPackage
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
> at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
> at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
> at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
> at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
> at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
> at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:810)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
> at at.jku.sea.cloud.gmf.adapter.plugin.cloudinteraction.ModelInteraction.registerPackage(ModelInteraction.java:68)
> at at.jku.sea.cloud.gmf.adapter.plugin.app.GMFApplication.start(GMFApplication.java:60)
> at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:497)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
> Caused by: java.lang.ClassNotFoundException: org.eclipse.emf.ecore.EPackage
> at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
> at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:810)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
> ... 27 more
>
>
> I am assuming that it has something to do with resolving the emf.ecore plugin.
> Any help would be greatly appreciated!
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
|
|
Re: NoClassDefFoundError: org/eclipse/emf/ecore/EPackage [message #1724130 is a reply to message #1723995] |
Sun, 21 February 2016 15:08 |
Florian Goenner Messages: 15 Registered: December 2015 |
Junior Member |
|
|
In my first post I showed a code snippet which is needed for accessing the eInstance Field of my generated MindmapPackage model class. Currently I am forced to use a predefined Interface for a program, which reads a generated diagram file, made with the GMF graphical editor and transforms it into some other project-related data structure. And this interface needs the value of the eInstance field (EPackage) as a parameter.
Ultimately, what I want to achieve is to read a diagram file - created with the GMF graphical editor - as an ecore Resource and access its contents. My application is currently running in the same workspace where all the projects are generated to. But because model, edit and editor projects are generated during runtime, I cannot deploy them with my application. (The task in the first place was to do everything during runtime)
[Updated on: Sun, 21 February 2016 15:09] Report message to a moderator
|
|
|
Re: NoClassDefFoundError: org/eclipse/emf/ecore/EPackage [message #1724132 is a reply to message #1724130] |
Sun, 21 February 2016 15:37 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
You are not forced to use predefined Interfaces.
Since perhaps Eclipse 3.6, there has been support for dynamic loading of
plugins, so you could generate your plugin then load it. I've never
tried this.
More mundanely you can load your own generated classes. The main gotcha
is that ClassLoader has no unload method, so if you have old classes
lying around you may fnd that stale classes have been loaded before you
generate your new ones. The solution is to use a new ClassLoader to load
your new classes.
My code to do this is:
GIT\org.eclipse.ocl\examples\org.eclipse.ocl.examples.codegen\src\org\eclipse\ocl\examples\codegen\dynamic\ExplicitClassLoader.java
It was inspired by:
http://www.toptal.com/java/java-wizardry-101-a-guide-to-java-class-reloading
For EMF editors, the recent revamp of Ecore Editor by the EMF Forms
project is very close to permitting a Reflective Ecore Editor, so you
may not need to generate it at all.
Regards
Ed Willink
On 21/02/2016 15:08, Florian Goenner wrote:
> In my first post I showed a code snippet which is needed for accessing
> the eInstance Field of my generated MindmapPackage model class.
> Currently I am forced to use a predefined Interface for a program,
> which reads a generated diagram file, made with the GMF graphical
> editor and transforms it into some other project-related data
> structure. And this interface needs the value of the eInstance field
> (EPackage) as a parameter.
> Ultimately, what I want to achieve is to read a diagram file, which
> was created with the GMF graphical editor as an ecore Resource and
> access its contents. My application is currently running in the same
> workspace where all the projects are generated to. But because model,
> edit and editor projects are generated during runtime, I cannot deploy
> them with my application. (The task in the first place was to do
> everything during runtime)
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03871 seconds