Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF Serialization Problem
EMF Serialization Problem [message #423878] Wed, 08 October 2008 15:23 Go to next message
Kamesh Sampath is currently offline Kamesh SampathFriend
Messages: 213
Registered: July 2009
Senior Member
Hi,

I am facing a seralization issue with EMF - XML Serialization , when I
serialize my Model to XML its working properly , but when i try to load
the same using the following code snippet , I am getting the usual
ClassNotFoundException
"org.eclipse.emf.ecore.xmi.ClassNotFoundException: Class 'page' not found"


public static final String FILE_NAME =
" file:///D:/pde/workspace/com.sk.wikclipse.gen/src/test.wpage";

public static void loadModel() {
URI fileURI = URI.createURI(FILE_NAME);
Resource resource = new XMLResourceImpl(fileURI);
try {
resource.load(null);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

The Generated Model file :

<?xml version="1.0" encoding="UTF-8"?>
<wikclipse:page xmlns:wikclipse="http://sk.com/model/wikclipse"
wikclipse:pageTitle="RedHat SOA Solution Stack"
wikclipse:parentPage="OpenSource-Assets">
<wikclipse:content>
<wikclipse:heading headingType="h1.">
<wikclipse:headingText>Purpose</wikclipse:headingText>
</wikclipse:heading>
<wikclipse:paragraph>
<wikclipse:text><![CDATA[<Purpose>]]></wikclipse:text>
</wikclipse:paragraph>
</wikclipse:content>
</wikclipse:page>

Can you please help me where I am going wrong. Is there any place I need
to add a code in the generated model code to avoid this error .

Thanks in advance.

Kamesh

}
Re: EMF Serialization Problem [message #423880 is a reply to message #423878] Wed, 08 October 2008 16:46 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Kamesh,

Comments below.


Kamesh Sampath wrote:
> Hi,
>
> I am facing a seralization issue with EMF - XML Serialization , when I
> serialize my Model to XML its working properly , but when i try to
> load the same using the following code snippet , I am getting the
> usual ClassNotFoundException
> "org.eclipse.emf.ecore.xmi.ClassNotFoundException: Class 'page' not
> found"
>
>
> public static final String FILE_NAME =
> " file:///D:/pde/workspace/com.sk.wikclipse.gen/src/test.wpage";
>
> public static void loadModel() {
> URI fileURI = URI.createURI(FILE_NAME);
> Resource resource = new XMLResourceImpl(fileURI);
You generally should be using a factory to create resources. Invoke
"Generate Test Code" and look at how the generated XyzExample.java in
the *.tests project does it. I imagine the resource you used to save
was the one created by the generated
XyzResourceFactoryImpl.createResource...
> try {
> resource.load(null);
> } catch (IOException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
>
> The Generated Model file :
> <?xml version="1.0" encoding="UTF-8"?>
> <wikclipse:page xmlns:wikclipse="http://sk.com/model/wikclipse"
> wikclipse:pageTitle="RedHat SOA Solution Stack"
> wikclipse:parentPage="OpenSource-Assets">
> <wikclipse:content>
> <wikclipse:heading headingType="h1.">
> <wikclipse:headingText>Purpose</wikclipse:headingText>
> </wikclipse:heading>
> <wikclipse:paragraph>
> <wikclipse:text><![CDATA[<Purpose>]]></wikclipse:text>
> </wikclipse:paragraph>
> </wikclipse:content>
> </wikclipse:page>
>
> Can you please help me where I am going wrong. Is there any place I
> need to add a code in the generated model code to avoid this error .
> Thanks in advance.
>
> Kamesh
>
> }
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: EMF Serialization Problem [message #423891 is a reply to message #423880] Thu, 09 October 2008 05:41 Go to previous messageGo to next message
Kamesh Sampath is currently offline Kamesh SampathFriend
Messages: 213
Registered: July 2009
Senior Member
Ed,

Thanks for the reponse. I do understand your info with respect to creating
and reading the EMF resource. I was trying to simulate the error I was
getting when i was using EMF with OAW . My Model gets seralized as XML
with custom metadata information, when that model is loaded using the OAW
workflow, I get the same error , hence i tried to do the same with the
*Example class generated by the EMF plugin and got the same error. Still
wondering what I am missing which causes this error. I added the XSI and
other schema information but still get the same error.

Any pointers in this regard will help me.

Also whats the difference between the XMLResource. OPTION_SCHEMA_LOCATION
and XMLResource.OPTION_SCHEMA_LOCATION_IMPLEMENTATION , when i used the
former i dont see the schema location attached to the serailized model but
when I use the later then i could see the SCHEMA_LOCATION in my seralized
file. Will this help me in resolving the classnotfound error or anyother
global change will resolve the error ?

-Kamesh
Re: EMF Serialization Problem [message #423897 is a reply to message #423891] Thu, 09 October 2008 10:34 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Kamesh,

Comments below.

Kamesh Sampath wrote:
> Ed,
>
> Thanks for the reponse. I do understand your info with respect to
> creating and reading the EMF resource. I was trying to simulate the
> error I was getting when i was using EMF with OAW . My Model gets
> seralized as XML with custom metadata information, when that model is
> loaded using the OAW workflow, I get the same error , hence i tried to
> do the same with the *Example class generated by the EMF plugin and
> got the same error. Still wondering what I am missing which causes
> this error. I added the XSI and other schema information but still get
> the same error.
Is the workflow running as a stand alone process as opposed to started
as an OSGi application? In that case no plugin registration takes
places and hence registrations of which factories are associated with
which file extensions are likely to be missing.
> Any pointers in this regard will help me.
> Also whats the difference between the XMLResource. OPTION_SCHEMA_LOCATION
It tells it to write a schema location if the ePackage.nsURI() is
different from ePackage.eResource().getURI().
> and XMLResource.OPTION_SCHEMA_LOCATION_IMPLEMENTATION
Rather than write out the location URI, it writes out the name of the
EPackage's generated interface, e.g, java:org.example.XyzPackage (or
something like that).
> , when i used the former i dont see the schema location attached to
> the serailized model
By default for generated models, the package's nsURI and the package's
resource's URI are the same.
> but when I use the later then i could see the SCHEMA_LOCATION in my
> seralized file.
I don't think this will solve the problem. For a model based on an XML
Schema, it's important that an XMLResourceImpl configured with options
like what you see in your generated XyzResourceFactoryImpl as used.
> Will this help me in resolving the classnotfound error or anyother
> global change will resolve the error ?
No. Try to find out from the oAW folks how you're suppose to be able to
ensure that your resource factory registrations will be taken into
account. I'll try to ask about these issues when I get a chance to talk
with them next week...
>
> -Kamesh
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Why doesn't AbstractEMFOperation rollback on ERROR Status?
Next Topic:Restrict model modifications - ItemProvider.createCommand?
Goto Forum:
  


Current Time: Tue Apr 16 12:38:28 GMT 2024

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

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

Back to the top