Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Problem create model instance with resource
Problem create model instance with resource [message #740774] Tue, 18 October 2011 22:00 Go to next message
Willi  is currently offline Willi Friend
Messages: 13
Registered: October 2011
Junior Member
Hello at all,

i'm new in EMF and facing some problems.
I have generate a model from xsd and have generate the .test .edit and .editor projects.
When i load a xml resource with Java Code all work correct and i get the elements in the file. Like this:

...
		Resource resource = resourceSet.getResource(URI.createURI("file:/c:/mymodel/entitymodel.xml"),true);
	
		try {
			resource.load(options);
		        DocumentRoot root = (DocumentRootImpl)resource.getContents().get(0);
                        root.getEntitymodel().getEntity().get(0);...


But when i start the project and a new eclipse instance is started. And i create there a model and like to add a resource i get a org.eclipse.emf.ecore.xmi.ClassNotFoundException: Class 'entitymodel' is not found or is abstract.

I have searched the web but haven't found a resolution. Have anybody some ideas what i'm doing wrong?

I hope you understand my english...

Thanks Willi
Re: Problem create model instance with resource [message #740995 is a reply to message #740774] Wed, 19 October 2011 04:35 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Willi,

Comments below.

On 19/10/2011 12:00 AM, Willi wrote:
> Hello at all,
>
> i'm new in EMF and facing some problems.
> I have generate a model from xsd and have generate the .test .edit and
> .editor projects. When i load a xml resource with Java Code all work
> correct and i get the elements in the file. Like this:
>
>
> ..
> Resource resource =
> resourceSet.getResource(URI.createURI("file:/c:/mymodel/entitymodel.xml"),true);
XML is a heavily used extension. It's highly likely someone else will
register something to parse it and an editor for it...
>
> try {
> resource.load(options);
> DocumentRoot root =
> (DocumentRootImpl)resource.getContents().get(0);
Why cast to an Impl?
> root.getEntitymodel().getEntity().get(0);...
>
>
> But when i start the project and a new eclipse instance is started.
> And i create there a model and like to add a resource i get a
> org.eclipse.emf.ecore.xmi.ClassNotFoundException: Class 'entitymodel'
> is not found or is abstract.
It will come down to whether your resource factory is registered and
used or not.
> I have searched the web but haven't found a resolution. Have anybody
> some ideas what i'm doing wrong?
For something like *.xml, you're most likely going to need something
like content type recognition. You can request EMF to generate that by
setting a Content Type Identifier in the properties for the GenPackage
(the object below the GenModel in the Generator).

Note that this affects the plugin.xml registrations, so please delete it
so it can be regenerated after the changes.
>
> I hope you understand my english...
>
> Thanks Willi
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Problem create model instance with resource [message #741223 is a reply to message #740995] Wed, 19 October 2011 10:02 Go to previous message
Willi  is currently offline Willi Friend
Messages: 13
Registered: October 2011
Junior Member
Hello Ed Merks,

thank you for your fast response. Your answer help me very much. Now it works.
Yes the cast is not good but it is only copied test code.

Willi
Previous Topic:Deserializing a serialized meta model that contains cross references
Next Topic:Using programatic hbm creation with Teneo - EMF - Hibernate
Goto Forum:
  


Current Time: Thu Mar 28 12:04:34 GMT 2024

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

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

Back to the top