Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » EOL Script error in standalone execution: The feature 'x' is not a valid feature(Error, EOL Standalone)
EOL Script error in standalone execution: The feature 'x' is not a valid feature [message #1862126] Tue, 14 November 2023 12:26 Go to next message
Thomas Stifter is currently offline Thomas StifterFriend
Messages: 5
Registered: September 2021
Junior Member
Good afternoon,

I am facing an "IllegalArgumentException: The feature 'rows' is not a valid feature" when trying to execute an EOL script, and cannot figure out what I am doing wrong. Running it with a run config in Eclipse as EOL program it works fine, however.

The script takes in two models referred to as "MM" (metamodel) and "m" (model). What it does is it calculates a measure based on the content of the metamodel and the model. For instance, I pass in a "Table.ecore" as "MM" and an instance of this model as "m" as follows:

 final EolModule module = new EolModule();

            try {
               module.parse(new File("model_cov.eol"));
               
               final String sourceMM = "metamodels/Table.ecore";
               final String sourceModel = "models/Table.xmi";
               final String mmSourceMM = "http://www.eclipse.org/emf/2002/Ecore";

              // Add to EPackage registry, resource set with load option for XMLResource.OPTION_EXTENDED_META_DATA
              registerMM(sourceMM);
               registerMM(mmSourceMM);
               
               final EmfModel emfModelMM = new EmfModel();
               emfModelMM.setName("MM"); 
               emfModelMM.setModelFile(sourceMM); 
               
               final EmfModel emfModelM = new EmfModel();
               emfModelM.setName("m");
               emfModelM.setModelFile(sourceModel); 
               emfModelM.setMetamodelFileUri(URI.createFileURI(sourceMM));

               emfModelMM.load();
               emfModelM.load();

               module.getContext().getModelRepository().addModel(emfModelMM);
               module.getContext().getModelRepository().addModel(emfModelM);

               module.execute();
            . . . 
            } catch(final Exception e) {
               // TODO Auto-generated catch block
               // DynamicEObjectImpl a;
               e.printStackTrace();
            }


The"not a valid feature ..." error occurs in the following function where "i" is a DynamicEObjectImpl of "m" and "self" is an EReferenceImpl with name "rows".

operation MM!EReference getSize(i: Any) : Integer {
	return i.eGet(self).size() * r_weight;
} 



Is there an obvious reason why this occurs? As metioned it is running fine with an Eclipse run configuration and declaring the two models. Am thankful for any hints.


Re: EOL Script error in standalone execution: The feature 'x' is not a valid feature [message #1862131 is a reply to message #1862126] Tue, 14 November 2023 14:50 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

Hi Thomas,

Could you please share a runnable version of this code (that includes the respective metamodels, models, pom/gradle files etc.) in a zip file/git repo we can use to reproduce the behaviour you're encountering?

Thanks,
Dimitris
Re: EOL Script error in standalone execution: The feature 'x' is not a valid feature [message #1862133 is a reply to message #1862126] Tue, 14 November 2023 15:00 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

Off the top of my head, I suspect that what happens is that you actually have multiple in-memory copies of the metamodel: the copy that is in your EPackage registry, the copy that you are using as a model in your EOL script, and the copy that you ask Epsilon to instantiate via the use of setMetamodelFileUri(...) instead of just setMetamodelUri(...) (which would reuse the copy in your package registry). You're trying to do x.eGet(f) where x conforms to one of the in-memory copies of the metamodel, and f belongs to another in-memory copy of the metamodel - this may not work in Ecore as it heavily uses object identity (sameness).

Since it looks like sourceModel conforms to sourceMM, I think it'd be much simpler to only use sourceModel from your EOL script, and then use object.eClass when you want to check the EClass that an object belongs to. That way you only need to register your metamodel as usual, and then refer to it by EPackage URI from your code.

[Updated on: Tue, 14 November 2023 15:01]

Report message to a moderator

Re: EOL Script error in standalone execution: The feature 'x' is not a valid feature [message #1862150 is a reply to message #1862133] Wed, 15 November 2023 13:56 Go to previous messageGo to next message
Thomas Stifter is currently offline Thomas StifterFriend
Messages: 5
Registered: September 2021
Junior Member
First of all, thanks for the help! I first thought about Antonio's reference to in-memory copies of the same metamodel. So I removed the ".setMetamodelFileUri(...)" part, and lo and behold, it works!

But strangely, in one case the mentioned error still occurs. Namely, when I use the Ecore model as metamodel, one with nsURI/ns "http://www.eclipse.org/emf/2002/Ecore". In this case, I get the mentioned error, specifically "The feature 'abstract' is not a valid feature".

I attach a minimal example project (zip) for the case described so that the error can be reproduced.

[Updated on: Wed, 15 November 2023 15:56]

Report message to a moderator

Re: EOL Script error in standalone execution: The feature 'x' is not a valid feature [message #1862160 is a reply to message #1862150] Wed, 15 November 2023 22:59 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

Hi Thomas,

Tweaking your code as follows seems to be doing the trick.

package eol;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.OutputStream;
import java.io.PrintStream;

import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.epsilon.emc.emf.EmfMetaModel;
import org.eclipse.epsilon.emc.emf.EmfModel;
import org.eclipse.epsilon.eol.EolModule;

public class EolTest {

   public static void main(String[] args) {

      System.setProperty("org.eclipse.emf.ecore.EPackage.Registry.INSTANCE", "org.eclipse.emf.ecore.impl.EPackageRegistryImpl");

      final EolModule module = new EolModule();

      try {
         module.parse(new File("model_cov.eol"));

         final OutputStream outputStream = new ByteArrayOutputStream();
         final String sourceModel = "models/ecore.xmi";

         EPackage.Registry.INSTANCE.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);

         final EmfMetaModel emfModelMM = new EmfMetaModel("MM", EcorePackage.eNS_URI);
         emfModelMM.load();
         
         final EmfModel emfModelM = new EmfModel();
         emfModelM.setName("m");
         emfModelM.setModelFile(sourceModel);
         emfModelM.setMetamodelUri(EcorePackage.eNS_URI);
         emfModelM.load();

         module.getContext().setOutputStream(new PrintStream(outputStream));
         module.getContext().getModelRepository().addModel(emfModelMM);
         module.getContext().getModelRepository().addModel(emfModelM);

         module.execute();

         emfModelMM.dispose();
         emfModelM.dispose();

         String output = outputStream.toString();
         System.out.println(output);
         
      } catch (final Exception e) {
         e.printStackTrace();
      }

   }

}


Thanks,
Dimitris
Re: EOL Script error in standalone execution: The feature 'x' is not a valid feature [message #1862450 is a reply to message #1862160] Tue, 05 December 2023 18:08 Go to previous message
Thomas Stifter is currently offline Thomas StifterFriend
Messages: 5
Registered: September 2021
Junior Member
Indeed, this is it. I'm not quite sure why it has to work like this in one case, but that's how everything works for my purposes. Thank you very much!
Previous Topic:Unable to generate .diagram folder using Eugenia
Next Topic:Issue with the '*]' character sequence in the generated text
Goto Forum:
  


Current Time: Sat Apr 27 12:48:20 GMT 2024

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

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

Back to the top