Howto implement own serializiation format? [message #556621] |
Thu, 02 September 2010 07:04 |
Michael Frey Messages: 48 Registered: August 2010 |
Member |
|
|
Hi,
I've created a ecore model from a mdl file, created the corresponding gencore file and generated the code from the gencore file. While EMF has a own serialization mechanism based on XMI I want to support my project with a own serializiation mechanism. I've had a look on the EMF book as well as on the FAQ but I haven't found what I'm looking for. Maybe somebody can point me into the right direction or to the corresponding section in the documentation for my intents?
Thanks in advance!
Regards,
Michael
[Updated on: Thu, 02 September 2010 07:40] Report message to a moderator
|
|
|
|
|
|
|
|
Re: Howto implement own serializiation format? [message #558818 is a reply to message #556621] |
Tue, 14 September 2010 14:21 |
Michael Frey Messages: 48 Registered: August 2010 |
Member |
|
|
Hi,
I've tried to implement my own serialization format but I'm running into some trouble. I've got four projects which were generated from the genmodel.
- de.hs_rm.cs.vs.owl
- de.hs_rm.cs.vs.owl.edit
- de.hs_rm.cs.vs.owl.editor
- de.hs_rm.cs.vs.owl.tests
So far, I've done the following steps:
1. I've created a class OWLResourceFactoryImpl which implements Resource.Factory
2. Also I've created a class OWLResourceImpl which extends the ResourceImpl class and overwrites doSave and doLoad methods
3. I've added a extension point to de.hs_rm.cs.vs.owl plugin:
<extension point="org.eclipse.emf.ecore.extension_parser">
<parser type="owl" class="owl.util.OWLResourceFactoryImpl">
</extension>
If I try to run the code I get a NoClassDefFoundError (the exception is caused while I'm calling the constructor of OWLResourceImpl in the OWLResourceFactoryImpl createResource method).
I've had a look on the EMF book and there is a description in the EMF Persistence API chapter (pages 457 and following). The book states that I should for stand alone applications add the following code:
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("owl", new OWLResourceFactoryImpl());
I'm not really sure where I should put the code. I've added the code in the createModel() method in the OWLEditor class in the de.hs_rm.cs.vs.owl.editor plugin but I'm not really sure that this is the right place. If I run the code as eclipse application I get still the NoClassDefFoundError Exception So probably that was not the right place to put the code.
Maybe somebody knows what I'm missing? Thanks in advance!
Michael
[Updated on: Tue, 14 September 2010 14:39] Report message to a moderator
|
|
|
|
Re: Howto implement own serializiation format? [message #558829 is a reply to message #558825] |
Tue, 14 September 2010 14:52 |
Michael Frey Messages: 48 Registered: August 2010 |
Member |
|
|
Hi,
Ed Merks wrote on Tue, 14 September 2010 10:29 |
That sounds more like a classpath issue. Is the util folder listed in
the bundle manifests's packages?
l
|
The util folder/package is exported in the manifest file.
Ed Merks wrote on Tue, 14 September 2010 10:29 |
Look at the XyzExample. java in the *.owl.tests project.
l
|
There is no such file.
Ed Merks wrote on Tue, 14 September 2010 10:29 |
The editor isn't stand alone though so no need for that.
|
I've removed it.
Ed Merks wrote on Tue, 14 September 2010 10:29 |
> but I'm not really sure that this is the right place.
No.
|
I've thought so.
Ed Merks wrote on Tue, 14 September 2010 10:29 |
> If I run the code as eclipse application I get an NullPointerException.
What's null?
|
Okay. I've fixed that. The problem was that I've added the wrong class to the getExtensionToFactoryMap, so the exception is still a NoClassDefFoundError Exception and it still seems that the class OwlResourceImpl is not found.
Ed Merks wrote on Tue, 14 September 2010 10:29 |
> Maybe somebody knows what I'm missing? Thanks in advance!
Be sure the util package is an exported package.in the manifest.
|
The package is exported. So the stacktrace states the exception is caused while I'm calling the constructor of OwlResourceImpl in the createResource method of the OwlResourceFactoryImpl class. Which confuses me most is the fact that both classes reside in the same package. Suggestions how to debug that? I've added a breakpoint to the constructor call but the next step is obviously the NoClassDefFoundError.
Regards,
Michael
|
|
|
Re: Howto implement own serializiation format? [message #558842 is a reply to message #556621] |
Tue, 14 September 2010 15:19 |
Michael Frey Messages: 48 Registered: August 2010 |
Member |
|
|
Hi,
I've tracked the problem down. So far it seems to be a problem with the library I'm using in my OwlResourceFactoryImpl. I've would expected another exception. If I remove the corresponding code the methods for loading and saving are called.
I've added the lib directory (where the library resides) to the bundle classpath as well as to the binary build (bin.include in build.properties) and it's still not working.
*confused*
Michael
[Updated on: Tue, 14 September 2010 15:22] Report message to a moderator
|
|
|
|
|
Re: Howto implement own serializiation format? [message #559213 is a reply to message #558979] |
Thu, 16 September 2010 02:28 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Michael,
Comments below.
Michael Frey wrote:
> Hi,
>
> I've created a lib/ directory where I've put my library. The directory
> resides in my de.hs_rm.cs.vs.dsm.owl plugin. I've added the library to
> the build path (Project Properties -> Java Build Path)
Don't ever do that. Edit only the MANIFEST.MF.
> as well as to the bundle classpath (Manifest.mf) and to the
> bin.include section in the build.properties.
That part sounds good, but if you made a mistake, the direct build path
update would mask it as compile time only for it to come back at runtime.
> What exactley do you mean by runtime workbench?
When you launch a second Eclipse in order to run or debug it.
> If I'm writing code in my plugin everything seems to work fine
> (packages and classes of the library are resolved by eclipse).
At build time...
> If I run the plugins as eclipse application I get an
> NoClassesDefFoundError exception (and that's probably what you meant
> by runtime workbench).
Yes.
> I've had a look on my run configuration and set the "Clear
> configuration area before launching" to true, but nothing changes.
> I have no clue why it's not working.
From the context menu for the project, use PDE Tools -> Update
Classpath to ensure that the build path reflects exactly what's in the
MANIFEST. If you have compile problems, fix them by editing the
MANIFEST.MF.
> Regards,
> Michael
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.04929 seconds