Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » newly created EMF editor does not find the document element's class
newly created EMF editor does not find the document element's class [message #420744] Wed, 09 July 2008 12:10 Go to next message
Michael Moser is currently offline Michael MoserFriend
Messages: 914
Registered: July 2009
Senior Member
I just created a new EMF project plus model based on an XML schema file.
This gave me a .genmodel file which I opened and issued a Generator =>
Generate All on it to generate me the corresponding .edit, .editor and
..tests projects (plus the model src-files in the original project).

I then created a Run-configuration using Run-configurations... => ... =>
Plug-ins-tab => "plug-ins selected below only", where I first deselected
all, then selected the 4 projects above and then clicked the Add
Required Plugins button. Finally I hit the Run button.

The runtime eclipse starts up, I create a new project, copy an .xml file
into the project that corresponds to the original schema into the
project and Open it using the above newly created editor. This yields me
a "ClassNotFoundException": Class 'MainElementNameHere' not found, i.e.
the class corresponding to the model's outermost (or document) element.

Searching through the 4 projects directories, there is indeed no
'MainElementNameHere.class file anywhere, only a
'MainElementNameHereType.class' (note the suffix "Type" here).

What am I missing here???

This is using eclipse Ganymed (i.e. v3.4) with the corresponding
emf-xsd-sdo-SDK (v2.4.0).


Inspecting the schema file, the only thing that comes to my mind is,
that the root element directly starts with a type declaration, i.e.
like:
---------------
<xs:schema ...>
<xs:element name="RootElementName">
<xs:complexType ...>
...
</xs:complexType>
</xs:element>
</xs:schema>
---------------

and NOT like:

---------------
<xs:schema ...>
<xs:element name="rootElementName" type="RootElementNameType" ...>
</xs:element>
<xs:complexType name="RootElementNameType">
...
</xs:complexType>
</xs:schema>
---------------

I.e. there is no "...Type" declaration for the outermost document
element. But can that be the reason for the above problem???
Do XML schemas have to abide to some structuring convention to work with
EMF? That would really astound me! Or what could be the reason for this
class not found?

Michael
Re: newly created EMF editor does not find the document element's class [message #420745 is a reply to message #420744] Wed, 09 July 2008 12:21 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Michael,

Comments below.


Michael Moser wrote:
> I just created a new EMF project plus model based on an XML schema
> file. This gave me a .genmodel file which I opened and issued a
> Generator => Generate All on it to generate me the corresponding
> .edit, .editor and .tests projects (plus the model src-files in the
> original project).
>
> I then created a Run-configuration using Run-configurations... => ...
> => Plug-ins-tab => "plug-ins selected below only", where I first
> deselected all, then selected the 4 projects above and then clicked
> the Add Required Plugins button. Finally I hit the Run button.
>
> The runtime eclipse starts up, I create a new project, copy an .xml
> file into the project that corresponds to the original schema into the
> project and Open it using the above newly created editor. This yields
> me a "ClassNotFoundException": Class 'MainElementNameHere' not found,
> i.e. the class corresponding to the model's outermost (or document)
> element.
You're sure it conforms? Did you rename it to conform to your editor's
expected file extension? Is that extension also the one for which your
generated resource factory is registered in the model's plugin.xml?
>
> Searching through the 4 projects directories, there is indeed no
> 'MainElementNameHere.class file anywhere, only a
> 'MainElementNameHereType.class' (note the suffix "Type" here).
>
> What am I missing here???
One question mark is usually enough. The rest is drama. :-P
>
> This is using eclipse Ganymed (i.e. v3.4) with the corresponding
> emf-xsd-sdo-SDK (v2.4.0).
>
>
> Inspecting the schema file, the only thing that comes to my mind is,
> that the root element directly starts with a type declaration, i.e. like:
> ---------------
> <xs:schema ...>
> <xs:element name="RootElementName">
> <xs:complexType ...>
The name of an anonymous complex type will be the element name followed
by "Type".
> ...
> </xs:complexType>
> </xs:element>
> </xs:schema>
> ---------------
>
> and NOT like:
>
> ---------------
> <xs:schema ...>
> <xs:element name="rootElementName" type="RootElementNameType" ...>
> </xs:element>
> <xs:complexType name="RootElementNameType">
> ...
> </xs:complexType>
> </xs:schema>
> ---------------
>
> I.e. there is no "...Type" declaration for the outermost document
> element. But can that be the reason for the above problem???
No.
> Do XML schemas have to abide to some structuring convention to work
> with EMF?
No.
> That would really astound me!
Me too.
> Or what could be the reason for this class not found?
My guess would be that you aren't using the generated resource factory
to load your resource. In EMF 2.4, the GenPackage has nice new options
that let you specify you want content type-based processing (by
specifying a Content Type Identifier) and allows you to specify the
extension of your file. With the combination of the two, you can have
lots of models that all use "xml" as their extension and the right
editor will open based on the the content type (which is determined from
the namespace of the root element). Keep in mind that the plugin.xmls
will not regenerate once they exist, so changes here will not be
reflected unless you delete them and regenerate them.
>
> Michael
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: newly created EMF editor does not find the document element's class [message #420772 is a reply to message #420745] Thu, 10 July 2008 11:23 Go to previous messageGo to next message
Michael Moser is currently offline Michael MoserFriend
Messages: 914
Registered: July 2009
Senior Member
Hi Ed,
glad to know you are still around!

Ed Merks wrote:
>> ...
> You're sure it conforms? Did you rename it to conform to your
> editor's expected file extension? Is that extension also the one for
> which your generated resource factory is registered in the model's
> plugin.xml?


Yes, it conforms. But the hints re. the extension helped! Renaming the
file from .xml to the given extension allowed me to open the file.
But what I don't understand here: I had not just clicked Open, but
rather Open with... and then explicitly selected the desired Editor.
And still got that error. So, obviously the extension still has a say in
that case, which I find rather odd and unexpected.

>> Searching through the 4 projects directories, there is indeed no
>> 'MainElementNameHere.class file anywhere, only a
>> 'MainElementNameHereType.class' (note the suffix "Type" here).
>>
>> What am I missing here???
> One question mark is usually enough. The rest is drama. :-P

This was more an attempt to express the degree of my confusion ;-)

>> Or what could be the reason for this class not found?
> My guess would be that you aren't using the generated resource factory
> to load your resource. In EMF 2.4, the GenPackage has nice new
> options that let you specify you want content type-based processing
> (by specifying a Content Type Identifier) and allows you to specify
> the extension of your file. With the combination of the two, you can
> have lots of models that all use "xml" as their extension and the
> right editor will open based on the the content type (which is
> determined from the namespace of the root element). Keep in mind
> that the plugin.xmls will not regenerate once they exist, so changes
> here will not be reflected unless you delete them and regenerate them.

I'll try that immediately! Sounds *very* useful!

Thanks for the hints and cheers,
Michael
Re: newly created EMF editor does not find the document element's class [message #420775 is a reply to message #420772] Thu, 10 July 2008 11:33 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Michael,

Comments below.

Michael Moser wrote:
> Hi Ed,
> glad to know you are still around!
Was there ever any doubt. :-P
>
> Ed Merks wrote:
>>> ...
>> You're sure it conforms? Did you rename it to conform to your
>> editor's expected file extension? Is that extension also the one for
>> which your generated resource factory is registered in the model's
>> plugin.xml?
>
>
> Yes, it conforms. But the hints re. the extension helped! Renaming the
> file from .xml to the given extension allowed me to open the file.
> But what I don't understand here: I had not just clicked Open, but
> rather Open with... and then explicitly selected the desired Editor.
All the generated editors just use whatever resource factory is
registered/applicable for the resource being opened. So while you might
force some editor to open a resource with an extension it wouldn't
normally handle, that doesn't mean it will end up using the right
resource factory.
>
> And still got that error. So, obviously the extension still has a say
> in that case, which I find rather odd and unexpected.
With support for content types, it's a bit more flexible. But even
then, it's generally necessary to tell Eclipse about the extensions it
should considered for checking a given content type...
>
>>> Searching through the 4 projects directories, there is indeed no
>>> 'MainElementNameHere.class file anywhere, only a
>>> 'MainElementNameHereType.class' (note the suffix "Type" here).
>>>
>>> What am I missing here???
>> One question mark is usually enough. The rest is drama. :-P
>
> This was more an attempt to express the degree of my confusion ;-)
Hehehe. It worked well.
>
>>> Or what could be the reason for this class not found?
>> My guess would be that you aren't using the generated resource factory
>> to load your resource. In EMF 2.4, the GenPackage has nice new
>> options that let you specify you want content type-based processing
>> (by specifying a Content Type Identifier) and allows you to specify
>> the extension of your file. With the combination of the two, you can
>> have lots of models that all use "xml" as their extension and the
>> right editor will open based on the the content type (which is
>> determined from the namespace of the root element). Keep in mind
>> that the plugin.xmls will not regenerate once they exist, so changes
>> here will not be reflected unless you delete them and regenerate them.
>
> I'll try that immediately! Sounds *very* useful!
Yes, the content type stuff is very nice. Though I'm not totally
thrilled with how it's supported in the platform...
>
> Thanks for the hints and cheers,
> Michael
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: newly created EMF editor does not find the document element's class [message #420778 is a reply to message #420775] Thu, 10 July 2008 11:42 Go to previous messageGo to next message
Michael Moser is currently offline Michael MoserFriend
Messages: 914
Registered: July 2009
Senior Member
Ed Merks wrote:
>>> My guess would be that you aren't using the generated resource
>>> factory to load your resource. In EMF 2.4, the GenPackage has nice
>>> new options that let you specify you want content type-based
>>> processing (by specifying a Content Type Identifier) and allows you
>>> to specify the extension of your file. With the combination of the
>>> two, you can have lots of models that all use "xml" as their
>>> extension and the right editor will open based on the the content
>>> type (which is determined from the namespace of the root element).
>>> Keep in mind that the plugin.xmls will not regenerate once they
>>> exist, so changes here will not be reflected unless you delete them
>>> and regenerate them.
>>
>> I'll try that immediately! Sounds *very* useful!
> Yes, the content type stuff is very nice. Though I'm not totally
> thrilled with how it's supported in the platform...

I just tried it:
I added ",xml" to the extensions (since the description says: ... comma
seperated list...) and I copy-pasted the namespace string of the root
element into the "Content Type Identifier" field.
I then deleted all created stuff and did another "Create All". I also
double checked and these new values did indeed make it into the
plugin.xml file.

Still, when I start the editor and try to open the file (either just
double-clicking it or again, selecting the correct editor), I get that
same ClassNotFoundException again.

Any further things one needs to add or enter? Some flag missing or such?
Is there maybe some description of this feature so that I don't have to
bother you here?

Michael
Re: newly created EMF editor does not find the document element's class [message #420782 is a reply to message #420778] Thu, 10 July 2008 12:09 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Michael,

Comments below.

Michael Moser wrote:
> Ed Merks wrote:
>>>> My guess would be that you aren't using the generated resource
>>>> factory to load your resource. In EMF 2.4, the GenPackage has nice
>>>> new options that let you specify you want content type-based
>>>> processing (by specifying a Content Type Identifier) and allows you
>>>> to specify the extension of your file. With the combination of the
>>>> two, you can have lots of models that all use "xml" as their
>>>> extension and the right editor will open based on the the content
>>>> type (which is determined from the namespace of the root element).
>>>> Keep in mind that the plugin.xmls will not regenerate once they
>>>> exist, so changes here will not be reflected unless you delete them
>>>> and regenerate them.
>>>
>>> I'll try that immediately! Sounds *very* useful!
>> Yes, the content type stuff is very nice. Though I'm not totally
>> thrilled with how it's supported in the platform...
>
> I just tried it:
> I added ",xml" to the extensions (since the description says: ...
> comma seperated list...) and I copy-pasted the namespace string of the
> root element into the "Content Type Identifier" field.
I'm not sure the Eclipse platform will be happy if it's not an
identifier, so it might well be the case that it won't work...
> I then deleted all created stuff and did another "Create All". I also
> double checked and these new values did indeed make it into the
> plugin.xml file.
For the model and the editor?
>
> Still, when I start the editor and try to open the file (either just
> double-clicking it or again, selecting the correct editor), I get that
> same ClassNotFoundException again.
>
> Any further things one needs to add or enter? Some flag missing or
> such? Is there maybe some description of this feature so that I don't
> have to bother you here?
Have you check with the debugger that your generated resource factory is
being used to create the resource?
>
> Michael
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[Teneo] Problems with EMF delete
Next Topic:synchronize 2 instances of the same model
Goto Forum:
  


Current Time: Wed Apr 24 18:38:56 GMT 2024

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

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

Back to the top