Home » Modeling » EMF » Load model file: Class not found
| |
Re: Load model file: Class not found [message #516743 is a reply to message #516436] |
Wed, 24 February 2010 23:08 |
No real name Messages: 62 Registered: July 2009 |
Member |
|
|
Hi Ed,
I started FunctionBlocksExample.java, but I got the same Exception.
I tested the EMF-Tree-Editor and noticed that the top level element in
the an FBType file is not FBType but DocumentRoot so I inserted a
DocumentRoot in the file that I try to load. Then I got the Exception
'Feature DocumentRoot not found' instead of 'Class FBType not found'.
I don't understand why he thinks of 'DocumentRoot' as a feature, I just
surrounded the FBType with the lines
<functionblocks:DocumentRoot xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:functionblocks="http://kieler.cs.cau.de/functionblocks/">
and
</functionblocks:DocumentRoot>
and deleted the 'functionblocks:' in front of the FBType tags.
The most interesting thig is, that even if I try to load a file
which I created with the generated tree editor, I get those exceptions.
What could cause this?
Regards,
Matthias
Ed Merks wrote:
> Matthias,
>
> Comments below.
>
> Matthias Schmeling wrote:
>> Hi,
>>
>> I am trying to load a model file. The code I use is this:
>>
>> ------------------------------------------------------------ ------------
>> 01 // open file wizard
>> 02 FileDialog dialog = new FileDialog(activeEditor.getSite().getShell(),
>> SWT.SINGLE);
>> 03 String fileName = dialog.open();
>> 04 05 // read file
>> 06 ResourceSet resourceSet = new ResourceSetImpl();
>> 07 resourceSet.getPackageRegistry().put(FunctionblocksPackage.e NS_URI,
>> FunctionblocksPackage.eINSTANCE);
>> 08 Resource resource =
>> resourceSet.getResource(URI.createFileURI(fileName), true);
>> 09 10 EList<EObject> contents =
>> resource.getContents();
>> ------------------------------------------------------------ ------------
>>
>> However, I get a ClassNotFoundException. It says it cannot find a
>> certain class called 'FBType', but it is definitely in the package.
>> I was told that it might help to activate the package by inserting
>> 'FunctionblocksPackage q = FunctionblocksPackage.eINSTANCE;' in line 09.
>> This didn't help either. Can you help me? I don't understand why the
>> class cannot be found.
> Have you tried running the generated FunctionblocksExample.java thats in
> the *.tests project if you invoke Generate Test Code...? That should
> work out of the box.
>>
>> Thanks in advance,
>> Matthias
|
|
|
Re: Load model file: Class not found [message #516745 is a reply to message #516743] |
Wed, 24 February 2010 23:20 |
Ed Merks Messages: 33141 Registered: July 2009 |
Senior Member |
|
|
Matthias,
Comments below.
Matthias Schmeling wrote:
> Hi Ed,
>
> I started FunctionBlocksExample.java, but I got the same Exception.
Can you tell what resource factory it's using.
> I tested the EMF-Tree-Editor and noticed that the top level element in
> the an FBType file is not FBType but DocumentRoot so I inserted a
> DocumentRoot in the file that I try to load.
If you see a DocumentRoot element, that tells me you've saved a schema
based model with a XMIResourceImpl or an XMLResourceImpl without the
OPTION_EXTENDED_META_DATA.
> Then I got the Exception 'Feature DocumentRoot not found' instead of
> 'Class FBType not found'.
>
> I don't understand why he thinks of 'DocumentRoot' as a feature, I just
> surrounded the FBType with the lines
>
> <functionblocks:DocumentRoot xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:functionblocks="http://kieler.cs.cau.de/functionblocks/">
Yep, and XMI serialization.
>
> and
>
> </functionblocks:DocumentRoot>
>
> and deleted the 'functionblocks:' in front of the FBType tags.
> The most interesting thig is, that even if I try to load a file
> which I created with the generated tree editor, I get those exceptions.
> What could cause this?
Not using the right resource. If you run the generated example without
options, it produces a trivial instance. That instance should load.
And that's how your editor should be saving as well, as long as it's
actually using the generated resource factory to create the resource.
>
> Regards,
> Matthias
>
> Ed Merks wrote:
>> Matthias,
>>
>> Comments below.
>>
>> Matthias Schmeling wrote:
>>> Hi,
>>>
>>> I am trying to load a model file. The code I use is this:
>>>
>>> ------------------------------------------------------------ ------------
>>>
>>> 01 // open file wizard
>>> 02 FileDialog dialog = new
>>> FileDialog(activeEditor.getSite().getShell(),
>>> SWT.SINGLE);
>>> 03 String fileName = dialog.open();
>>> 04 05 // read file
>>> 06 ResourceSet resourceSet = new ResourceSetImpl();
>>> 07 resourceSet.getPackageRegistry().put(FunctionblocksPackage.e NS_URI,
>>> FunctionblocksPackage.eINSTANCE);
>>> 08 Resource resource =
>>> resourceSet.getResource(URI.createFileURI(fileName), true);
>>> 09 10 EList<EObject> contents =
>>> resource.getContents();
>>> ------------------------------------------------------------ ------------
>>>
>>>
>>> However, I get a ClassNotFoundException. It says it cannot find a
>>> certain class called 'FBType', but it is definitely in the package.
>>> I was told that it might help to activate the package by inserting
>>> 'FunctionblocksPackage q = FunctionblocksPackage.eINSTANCE;' in line
>>> 09.
>>> This didn't help either. Can you help me? I don't understand why the
>>> class cannot be found.
>> Have you tried running the generated FunctionblocksExample.java thats
>> in the *.tests project if you invoke Generate Test Code...? That
>> should work out of the box.
>>>
>>> Thanks in advance,
>>> Matthias
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Goto Forum:
Current Time: Thu Apr 25 19:29:25 GMT 2024
Powered by FUDForum. Page generated in 0.03213 seconds
|