Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Class 'System' is not found or is abstract
[Acceleo] Class 'System' is not found or is abstract [message #895088] Wed, 11 July 2012 16:31 Go to next message
Toni Marin is currently offline Toni MarinFriend
Messages: 7
Registered: October 2011
Junior Member
Hi everyone,

We are trying to generate Lydia code from an xmi file. But we get the error "Class 'System' is not found or is abstract".

SO, we are using our own ecore metamodel. All packages are registered in the generated java file (I read it is not possible to register the metamodel alone when it is made of different packages, but all packages have to be individualy registered).
We use Indigo version.
The input model is an .xmi file. Here is the code we use for registering the factory resource:
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl());


The heading of the input model is:
<?xml version="1.0" encoding="ASCII"?>
<STRUCT:[b]System[/b] xmi:version="2.0"
    xmlns:STRUCT="http: //zuse.ucc.ie/itobo/structure"   
    xmlns:DX="http: //zuse.ucc.ie/itobo/diagnosis"
    xmlns:PL="http: //zuse.ucc.ie/itobo/propositionallogic" 
    name="main">


All this packages are registered in the generated java file.

resourceSet.getPackageRegistry().put("http: //zuse.ucc.ie/itobo/structure", org.eclipse.emf.ecore.EcorePackage.eINSTANCE);


However registering everything, the error "class "System" is not found or is abstract" still comes up.

Also, sometimes the error "emtl file is not found" appears (may be significant(?))

Any help will be greatly appreciated.

Cheers

[Updated on: Thu, 12 July 2012 14:35]

Report message to a moderator

Re: [Acceleo] Class 'System' is not found or is abstract [message #895367 is a reply to message #895088] Thu, 12 July 2012 15:10 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 413
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

This means that you are registering the package of the Ecore meta-model "EcorePackage.eINSTANCE" to handle all occurrences of the URI "http: //zuse.ucc.ie/itobo/structure".
resourceSet.getPackageRegistry().put("http: //zuse.ucc.ie/itobo/structure", org.eclipse.emf.ecore.EcorePackage.eINSTANCE);


You code should look like this:
resourceSet.getPackageRegistry().put("http: //zuse.ucc.ie/itobo/structure", ie.ucc.zuse.package.where.your.emf.code.is.generated.by.the.genmodel.NameOfYourRootPackage.eINSTANCE);


Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau & @acceleo
Google+: stephane.begaudeau & acceleo
Blog: http://stephanebegaudeau.tumblr.com
Acceleo Documentation: http://docs.obeonetwork.com/acceleo



[Updated on: Thu, 12 July 2012 15:11]

Report message to a moderator

Re: [Acceleo] Class 'System' is not found or is abstract [message #895848 is a reply to message #895367] Mon, 16 July 2012 09:54 Go to previous messageGo to next message
Toni Marin is currently offline Toni MarinFriend
Messages: 7
Registered: October 2011
Junior Member
Hi Stephane,

I am a little confused. The project has no genmodel. It has the mtl file, the generated java file, the ecore meta-model and the xmi input model.

Please see here a screenshot of the project explorer and the registerPackages() function in Generate.java:
https: //dl.dropbox.com/u/50566170/Screenshot.png (remove space)

Does the project require a genmodel?

Regards and Thanks,

[Updated on: Mon, 16 July 2012 09:57]

Report message to a moderator

Re: [Acceleo] Class 'System' is not found or is abstract [message #895856 is a reply to message #895848] Mon, 16 July 2012 10:33 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4184
Registered: July 2009
Senior Member
Hi

On 16/07/2012 10:54, Toni Marin wrote:
> https: //dl.dropbox.com/u/50566170/Screenshot.png

Ecore is pretty good but it is not magic.

When you specify

resourceSet.getPackageRegistry().put("...",
org.eclipse.emf.ecore.EcorePackage.eINSTANCE);

you specify that the functionality of the "..." model has been compiled
into the EcorePackage.eINSTANCE. You have therefore specified that six
of your models are identical to the standard Ecore.

You can use dynamic Ecore to avoid genmodel and Java files, but you must
create an EPackage. So something like

Resource resource =
resourceSet.getResource("file:/location/of/hybridautomaton.ecore", true);
EPackage ePackage = (EPackage) resource.getContents().get(0);
EPackage.Registry.INSTANCE.put(ePackage.getNsURI(), ePackage);

for each of your models.

Regards

Ed Willink
Re: [Acceleo] Class 'System' is not found or is abstract [message #898065 is a reply to message #895856] Wed, 25 July 2012 17:36 Go to previous messageGo to next message
Toni Marin is currently offline Toni MarinFriend
Messages: 7
Registered: October 2011
Junior Member
Thanks Ed,

I added this code:

Resource resource = 
            		resourceSet.getResource(URI.createFileURI("./src/org/itobo/modeltotext/common/System.ecore"), true);
            
            		EPackage ePackage = (EPackage) resource.getContents().get(0);
            		EPackage.Registry.INSTANCE.put(ePackage.getNsURI(), ePackage);


But this applies only to the ecore meta-model. How can each ePackake be registered since they are all share the same ecore meta-model path?

Same error "class not found" comes up.


Cheers and Thanks

[Updated on: Wed, 25 July 2012 17:48]

Report message to a moderator

Re: [Acceleo] Class 'System' is not found or is abstract [message #898085 is a reply to message #898065] Wed, 25 July 2012 18:31 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4184
Registered: July 2009
Senior Member
On 25/07/2012 18:36, Toni Marin wrote:
> Thanks Ed,
>
> I have tried adding to the code:
> Resource resource =
> resourceSet.getResource(URI.createFileURI("./src/org/itobo/modeltotext/common/System.ecore"),
> true);
> EPackage ePackage = (EPackage)
> resource.getContents().get(0);
> EPackage.Registry.INSTANCE.put(ePackage.getNsURI(), ePackage);
>
> But this can only be applied for the ecore meta-model (I cannot put a
> path for each ePackage, since they are in System.ecore).

Yes you can. You just need to modify resource.getContents().get(0) to
navigate to them.
>
> I am still getting the same error of class not found.
>
> Any thoughts?
>
> Thanks
Re: [Acceleo] Class 'System' is not found or is abstract [message #898362 is a reply to message #898085] Thu, 26 July 2012 09:29 Go to previous messageGo to next message
Toni Marin is currently offline Toni MarinFriend
Messages: 7
Registered: October 2011
Junior Member
Thanks, I tried that with this code:

Resource resource = resourceSet.getResource(URI.createFileURI("./src/org/itobo/modeltotext/common/System.ecore"), true);
            
for (Iterator iter = resource.getContents().iterator(); iter.hasNext();) {
          	EPackage element = (EPackage) iter.next();
           	resourceSet.getPackageRegistry().put(element.getNsURI(), element);
}


It only iterates on the main package not entering the sub-packages where the actual classes are (see dl.dropbox.com/u/50566170/Ecore.png).

I know this is more like a java question, but any help is very welcome,

Thanks

[Updated on: Thu, 26 July 2012 09:46]

Report message to a moderator

Re: [Acceleo] Class 'System' is not found or is abstract [message #898389 is a reply to message #898362] Thu, 26 July 2012 10:13 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4184
Registered: July 2009
Senior Member
Hi

Try

for (TreeIterator<EObject> tit = resource.getAllContents();
tit.hasNext(); ) {
EObject eObject = tit.next();
if (eObject instanceof EPackage) {
...
}
}

or program the nested descent yourself.

Regards

Ed Willink




On 26/07/2012 10:29, Toni Marin wrote:
> Thanks Ed,
>
> I tried that with this code:
>
> Resource resource =
> resourceSet.getResource(URI.createFileURI("./src/org/itobo/modeltotext/common/System.ecore"),
> true);
> for (Iterator iter = resource.getContents().iterator();
> iter.hasNext();) {
> EPackage element = (EPackage) iter.next();
> resourceSet.getPackageRegistry().put(element.getNsURI(), element);
> }
>
> Debugging it, I found out that it only iterates on the main package
> not entering the sub-packages where the actual classes are. (see
> https:// dl.dropbox.com/u/50566170/Ecore.png) (remove space)
>
> This is more like a java question, but any help is very welcome,
>
> Thanks
Re: [Acceleo] Class 'System' is not found or is abstract [message #898537 is a reply to message #898389] Thu, 26 July 2012 14:32 Go to previous message
Toni Marin is currently offline Toni MarinFriend
Messages: 7
Registered: October 2011
Junior Member
That worked!

Thanks a million,

Antonio
Previous Topic:[Acceleo] Removing duplicate in collection
Next Topic:[Acceleo] how to create a compiler with xtext and Acceleo ?
Goto Forum:
  


Current Time: Wed Dec 17 21:31:13 GMT 2014

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

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