Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Obscure error while saving an output model...
Obscure error while saving an output model... [message #1818679] Sun, 22 December 2019 21:46 Go to next message
Olivier Hurez-Martin is currently offline Olivier Hurez-MartinFriend
Messages: 20
Registered: May 2019
Junior Member
Hello,

I am using ATL 4.1.0 on Eclipse 2019-09, trying to convert some ATL 2006 script into EMFTVM.

While my output file gets created when using ATL 2006 using the ANT task atl.saveModel, the EMFTVM equivalent of the latter, emftvm.saveModel, bugs out with the following output:

        [echo] Saving OWL model as Ecore to file:/D:\Dev\XYZ\SomeProject/target/models/SomeModelName/SomeModelFile.ecore
[emftvm.saveModel] java.lang.IllegalArgumentException: The feature 'resource' is not a valid feature
[emftvm.saveModel] 	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eOpenGet(BasicEObjectImpl.java:1062)
[emftvm.saveModel] 	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1015)
[emftvm.saveModel] 	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1003)
[emftvm.saveModel] 	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getValue(XMLHelperImpl.java:302)
[emftvm.saveModel] 	at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveEObjectSingle(XMLSaveImpl.java:1882)
[emftvm.saveModel] 	at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.writeTopAttributes(XMLSaveImpl.java:624)
[emftvm.saveModel] 	at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1249)
[emftvm.saveModel] 	at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1224)
[emftvm.saveModel] 	at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XMLSaveImpl.java:2716)
[emftvm.saveModel] 	at org.eclipse.emf.ecore.xmi.impl.XMISaveImpl.writeTopObjects(XMISaveImpl.java:84)
[emftvm.saveModel] 	at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveImpl.java:595)
[emftvm.saveModel] 	at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl.java:251)
[emftvm.saveModel] 	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doSave(XMLResourceImpl.java:389)
[emftvm.saveModel] 	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1475)
[emftvm.saveModel] 	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1044)
[emftvm.saveModel] 	at org.eclipse.m2m.atl.emftvm.ant.SaveModelTask.saveToURI(SaveModelTask.java:152)
[emftvm.saveModel] 	at org.eclipse.m2m.atl.emftvm.ant.SaveModelTask.saveToNsuri(SaveModelTask.java:126)
[emftvm.saveModel] 	at org.eclipse.m2m.atl.emftvm.ant.SaveModelTask.innerExecute(SaveModelTask.java:110)
[emftvm.saveModel] 	at org.eclipse.m2m.atl.emftvm.ant.EMFTVMTask.execute(EMFTVMTask.java:98)
[emftvm.saveModel] 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
[emftvm.saveModel] 	at sun.reflect.GeneratedMethodAccessor334.invoke(Unknown Source)
[emftvm.saveModel] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[emftvm.saveModel] 	at java.lang.reflect.Method.invoke(Method.java:498)
[emftvm.saveModel] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
[emftvm.saveModel] 	at org.apache.tools.ant.Task.perform(Task.java:350)
[emftvm.saveModel] 	at org.apache.tools.ant.Target.execute(Target.java:449)
[emftvm.saveModel] 	at org.apache.tools.ant.Target.performTasks(Target.java:470)
[emftvm.saveModel] 	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1388)
[emftvm.saveModel] 	at org.apache.tools.ant.Project.executeTarget(Project.java:1361)
[emftvm.saveModel] 	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[emftvm.saveModel] 	at org.eclipse.ant.internal.core.ant.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:39)
[emftvm.saveModel] 	at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
[emftvm.saveModel] 	at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:715)
[emftvm.saveModel] 	at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:535)
[emftvm.saveModel] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[emftvm.saveModel] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[emftvm.saveModel] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[emftvm.saveModel] 	at java.lang.reflect.Method.invoke(Method.java:498)
[emftvm.saveModel] 	at org.eclipse.ant.core.AntRunner.run(AntRunner.java:374)
[emftvm.saveModel] 	at org.eclipse.ant.internal.launching.launchConfigurations.AntLaunchDelegate.lambda$0(AntLaunchDelegate.java:272)
[emftvm.saveModel] 	at java.lang.Thread.run(Thread.java:748)

BUILD FAILED
D:D:\Dev\XYZ\SomeProject\build.xml:100: java.lang.IllegalArgumentException: The feature 'resource' is not a valid feature


Apparently, this is raised by the following method of the class org.eclipse.emf.ecore.impl.BasicEObjectImpl:

public Object eOpenGet(EStructuralFeature eFeature, boolean resolve)
  {
    EStructuralFeature openFeature = ExtendedMetaData.INSTANCE.getAffiliation(eClass(), eFeature);
    if (openFeature != null)
    {
      if (!FeatureMapUtil.isFeatureMap(openFeature))
      {
        openFeature = ExtendedMetaData.INSTANCE.getGroup(openFeature);
      }
      FeatureMap featureMap = (FeatureMap)eGet(openFeature);
      return ((FeatureMap.Internal)featureMap).get(eFeature, resolve);
    }
    else
    {
      throw new IllegalArgumentException("The feature '" + eFeature.getName() + "' is not a valid feature");
    }
  }


My ATL skills being at their infancy, could someone give me a few pointers as to how to troubleshoot this?

I already configured the 'match' and 'trace' output models as mentioned in https://wiki.eclipse.org/ATL/EMFTVM#Advanced_tracing but could not relate the produced output to the type of error at hand (no occurrence of 'resource' in there...)

Thank you for any research direction!

-- Olivier.
Re: Obscure error while saving an output model... [message #1818681 is a reply to message #1818679] Mon, 23 December 2019 07:58 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 581
Registered: September 2012
Location: Belgium
Senior Member

EMF is trying to save something "non-EMF" to file. Can you provide a zip file of an example project?

Cheers,
Dennis
Re: Obscure error while saving an output model... [message #1818695 is a reply to message #1818679] Mon, 23 December 2019 14:55 Go to previous messageGo to next message
Olivier Hurez-Martin is currently offline Olivier Hurez-MartinFriend
Messages: 20
Registered: May 2019
Junior Member
Thank you for your prompt answer :-)
I will try and isolate the problem in a smaller project for your examination.


I did find a 'resource' in the target model (specifically, in the eOpposite attribute of the uriRef structural feature of an OWL!RDFSResource)

OWL is the output metamodel of the ATL transform at hand....

Extract from OWL.ecore (from ODM):
    <eClassifiers xsi:type="ecore:EClass" name="RDFSResource">
      <eStructuralFeatures xsi:type="ecore:EReference" name="uriRef" ordered="false" upperBound="-1" eType="/0/URIReference" containment="true" eOpposite="/0/URIReference/resource"/>
      ...
    </eClassifiers>


Could that '/0/URIReference/resource' be the same 'resource' the error message from the exception mentioned above refers to?

[Updated on: Mon, 23 December 2019 15:03]

Report message to a moderator

Re: Obscure error while saving an output model... [message #1819356 is a reply to message #1818679] Mon, 13 January 2020 17:25 Go to previous messageGo to next message
Olivier Hurez-Martin is currently offline Olivier Hurez-MartinFriend
Messages: 20
Registered: May 2019
Junior Member
Hello again...

Back to this issue.... Thanks to your last note on it, I believe I went somewhat past the original problem, by using a built-in XML resource factory implementation for the output model, and a couple of corrections to the ATL scripts, to errors pointed the new ATL compiler pointed out after upgrade to Eclipse EMF 2019-12 and ATL 4.2.

I am still stuck however, and cannot figure out how to get the same result through the Java program as that obtained using the ANT driven transformation (with exact same ATL scripts).

Note the Java program in its current state works for a simple, one-step example, that only requires built-in resource factories.

However, the transformation I am interested in is akin to Guillaume Hillairet's work found at https://www.eclipse.org/atl/usecases/ODMImplementation/ and requires two main steps:

    UML/SysML -> ODM (OWL Ecore)
    ODM -> XML

plus a final XML -> RDF/XML projection that used to leverage an extra Eclipse plugin while Guillaume was working with ATL2006, and I still need to figure out how to replace with EMFTVM.

After adaptation, the two main steps above appear to work fine with EMFTVM driven by ANT tasks.
Not so with Java!

I believe I am very close to a similar execution environment setup through Java as the one configured with ANT, yet something is amiss, that I need help with. Specifically, the output of the first step of the transformation (that ought to conform to built-in Ecore metamodel) results in an essentially empty output model.

BTW, while working with Java, I miss the output from the ATL transformation debug statements (there must be a way to enable that, perhaps with Log4J configuration?)

I included a test Eclipse project [moved to a more recent post] that provides self standing excerpts of the UML/SysML ATL scripts, the ANT build.xml configuration that works, and the Java program with a couple of JUnit test cases in
/TestEMFTVM/src/test/java/atltest/m2m/runner/SysML2OWLTests.java


    test_simple_transformation demonstrates the program works for the trivial transformation example.
    test_transformation reproduces the issue at hand: incomplete output from first of two-step transformation.


Finally, I gather the last step needs to be handled much differently with EMFTVM than with ATL2006, through a dedicated OWL RDF/XML resource factory implementation, that would replace the second step entirely. I looked into such projects as Jena (AFAIK, does not directly interface with EMF), EODM (defunct?), Eclipse rdf4j (any examples of use of RDFXMLWriterFactory with EMFTVM?), emf4sw and its successor emftriple (abandoned?). Those last two, while promising, are built against long retired libraries, namely HP's Jena. I could not find any updated library for RDF/XML serialization (or alternative) of an EMFTVM output model that conforms to ODM. At the moment, I am considering two options: Update relevant parts of emftriple to build against latest Jena, or writing an XML parser to convert the output of the second stage of the transformation (which I know is incomplete) to RDF/XML. Did I miss anything?

Thank you!

-- Olivier.

[Updated on: Tue, 28 January 2020 16:00]

Report message to a moderator

Re: Obscure error while saving an output model... [message #1819386 is a reply to message #1819356] Tue, 14 January 2020 10:03 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 581
Registered: September 2012
Location: Belgium
Senior Member

Olivier Hurez-Martin wrote on Mon, 13 January 2020 18:25
Finally, I gather the last step needs to be handled much differently with EMFTVM than with ATL2006, through a dedicated OWL RDF/XML resource factory implementation, that would replace the second step entirely. I looked into such projects as Jena (AFAIK, does not directly interface with EMF), EODM (defunct?), Eclipse rdf4j (any examples of use of RDFXMLWriterFactory with EMFTVM?), emf4sw and its successor emftriple (abandoned?). Those last two, while promising, are built against long retired libraries, namely HP's Jena. I could not find any updated library for RDF/XML serialization (or alternative) of an EMFTVM output model that conforms to ODM. At the moment, I am considering two options: Update relevant parts of emftriple to build against latest Jena, or writing an XML parser to convert the output of the second stage of the transformation (which I know is incomplete) to RDF/XML. Did I miss anything?


There's also https://github.com/owlcs/owlapi , but this does not integrate with EMF.


Cheers,
Dennis
Re: Obscure error while saving an output model... [message #1819399 is a reply to message #1819386] Tue, 14 January 2020 15:24 Go to previous messageGo to next message
Olivier Hurez-Martin is currently offline Olivier Hurez-MartinFriend
Messages: 20
Registered: May 2019
Junior Member
Thank you Dennis!
I was unaware of that one. It appears quite active... I'll look into it.
Re: Obscure error while saving an output model... [message #1819659 is a reply to message #1819399] Mon, 20 January 2020 14:52 Go to previous messageGo to next message
Olivier Hurez-Martin is currently offline Olivier Hurez-MartinFriend
Messages: 20
Registered: May 2019
Junior Member
Hello again,

I still can't figure out why the first stage of the UML to OWL transformation in the attached project using EMFTVM won't produce a result when run using the included Java program (driven by the JUnit test test_transformation() within the file /TestEMFTVM/src/test/java/atltest/m2m/runner/SysML2OWLTests.java) , while it does work alright when run using the ANT tasks in /TestEMFTVM/build.xml.

Could someone help me out with that?

Thank you!

-- Olivier
Re: Obscure error while saving an output model... [message #1819675 is a reply to message #1819659] Tue, 21 January 2020 05:41 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 581
Registered: September 2012
Location: Belgium
Senior Member

I haven't found time yet: thanks for the extra hint though!

Cheers,
Dennis
Re: Obscure error while saving an output model... [message #1820717 is a reply to message #1819675] Mon, 27 January 2020 15:25 Go to previous messageGo to next message
Olivier Hurez-Martin is currently offline Olivier Hurez-MartinFriend
Messages: 20
Registered: May 2019
Junior Member
I found out the OWL.ecore file I am using has 3 EPackage definitions in it and first come is not the main one (RDFS package rather than OWL).

Also, the EPackage definitions do not provide nsURI (nor nsPrefix) attribute values.

So I tried and used the following function to load all packages instead of that found in many examples around, that only load the head of the list, based on the (weak?) assumption it would be the top one:

	public static void registerAllEPackages(ResourceSet rs, Resource resource) {
		EList<EObject> eObjList = resource.getContents();
		EPackage.Registry registry = rs.getPackageRegistry();
		
		// Enable extended meta-data; unsure we may need that here as well (not done in any example but ATLauncher)...
		ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(registry);
		rs.getLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);    
	    
		eObjList.forEach(eObject -> {
			if (eObject instanceof EPackage) {
				EPackage p = (EPackage)eObject;
				String nsURI = p.getNsURI();
		        	if (nsURI == null || nsURI.length() == 0) {
					nsURI = p.getName();
				}
				if (nsURI != null) {
					registry.put(nsURI, p);
				}
			}
		});
	}


Does that look legit?

While the Java program still processes the usual simple transformation sample (Class to Relational) successfully, it still silently fails on the first stage of the UML/SysML model transformation to OWL...

See attached testEMFTVM sample project.

What really throws me is that the same transformations run fine using the ANT tasks.

Any way to turn on the EMFTVM traces (the way one can see them when using the ANT tasks) and get insight on what's going on?

Thanks,

-- Olivier.




[Updated on: Tue, 28 January 2020 16:03]

Report message to a moderator

Re: Obscure error while saving an output model... [message #1820788 is a reply to message #1820717] Tue, 28 January 2020 22:46 Go to previous messageGo to next message
Olivier Hurez-Martin is currently offline Olivier Hurez-MartinFriend
Messages: 20
Registered: May 2019
Junior Member

In the attached project above, it appears as though UML stereotypes are not available to the ATL script when run from EMFTVM ANT tasks (while they are when run from a presumably equivalent Eclipse EMFTVM launch configuration).

Indeed, SysML stereotypes from the input model such as "Blocks:Block" won't trigger the filter of the following rule:

helper context UML!Element def: isStereotypeApplied(name : String) : Boolean =
	not self.getAppliedStereotype(name).oclIsUndefined();

-- SysML block (UML Class stereotype)
rule Block2OWLClass {
	from
		cb : UML!Class(cb.isStereotypeApplied('SysML::Blocks::Block'))
	
	using {
		owner : UML!Class = cb.owner;
		cbname : String = owner.name + '.' + cb.name;
	}

	to
		boc : OWL!OWLClass(
				uriRef <- Sequence {urirf},
				subClassOf <-
					Sequence {thisModule.ToURIReferenceClass(thisModule.COMPONENT_CLASS_URI)}
					->union(cb.general)
					->union(
					 	cb.ownedAttribute.debug('Parts')
						->select(p | p.type.debug('Type').isSysMLBlockStereotyped())
						->collect(p | thisModule.Composite2OWLRestriction(p))),
				label <- Sequence {label}
			),
		label : OWL!PlainLiteral(lexicalForm <- cb.name),
		urirf : OWL!URIReference(fragmentIdentifier <- lname, uri <- u_r_i),
		lname : OWL!LocalName(name <- cbname),
		u_r_i : OWL!UniformResourceIdentifier(name <- cb.addNamespace(cbname))
		
	do {
		cbname.debug('Transforming Block');
		--cb.getStereotype().getQualifiedName().debug(cbname + ' stereotype');
		boc;
	}
}


What am I missing?

Thanks,

-- Olivier.

[Updated on: Wed, 05 February 2020 15:49]

Report message to a moderator

Re: Obscure error while saving an output model... [message #1821102 is a reply to message #1820788] Wed, 05 February 2020 16:07 Go to previous messageGo to next message
Olivier Hurez-Martin is currently offline Olivier Hurez-MartinFriend
Messages: 20
Registered: May 2019
Junior Member
How can I get the output of debug statements within ATL scripts, such as cls.debug('class'), directed to the console, when running from Java?

I only get those when running the same scripts from a launch configuration or an ANT script.

It would be helpful to see where the script fails when run from Java, as it then produces an empty output, as opposed to the expected output when run from a launch configuration, and a partial output when run from ANT tasks!

I tried ATLLogger.getLogger().setLevel(Level.FINEST) and tweaks to the Java logger configuration, to no affect at all.

Thanks,

-- Olivier.

[Updated on: Wed, 05 February 2020 16:42]

Report message to a moderator

Re: Obscure error while saving an output model... [message #1823709 is a reply to message #1821102] Tue, 31 March 2020 13:47 Go to previous messageGo to next message
Olivier Hurez-Martin is currently offline Olivier Hurez-MartinFriend
Messages: 20
Registered: May 2019
Junior Member
Ok... I give up. Any easy way to convert my ATL scripts to QVT or am I looking at a complete rewrite?
Re: Obscure error while saving an output model... [message #1823813 is a reply to message #1821102] Thu, 02 April 2020 13:09 Go to previous messageGo to next message
Andon¡ Reteg¡ is currently offline Andon¡ Reteg¡Friend
Messages: 4
Registered: February 2020
Junior Member
Hi Olivier!

Im currently working on a model transformation project and I have the same problem. When I launch my transformation with Eclipse launch configuration it works, but when I try it with Java it doesn't. It gives me an empty output.

I also think that it would be useful to have some type of debug messages to find out where exactly the transformation is failing. Did you find out any way of doing it?
Re: Obscure error while saving an output model... [message #1823875 is a reply to message #1823813] Fri, 03 April 2020 11:54 Go to previous messageGo to next message
Andon¡ Reteg¡ is currently offline Andon¡ Reteg¡Friend
Messages: 4
Registered: February 2020
Junior Member
Hi again!

After debugging the code and looking into the ATL source code I found a way of getting the running debug information using Java launcher.

In order to do this, you have to put the "step" value to "true" (not a boolean, a String) in the options map ( Map<String, Object> options ) when calling the EMFVM.java launch() function. If you are not using EMFVM.java for the execution, I suposse there is an equivalent function used to start the transformation that will ask you for this variable. This triggers the "debug" variable in ASMOperation.java that makes all the transformation information appear in the console.

I'll attach some images in order to make this easier to understand and feel free to ask anything.

Hope this helps :)
Re: Obscure error while saving an output model... [message #1824011 is a reply to message #1823875] Mon, 06 April 2020 13:35 Go to previous message
Olivier Hurez-Martin is currently offline Olivier Hurez-MartinFriend
Messages: 20
Registered: May 2019
Junior Member
Neat! I'll try that out as soon as I get back to that project...
Thank you Andon!
Previous Topic:ATL plugin - stereotype is not applicable error
Next Topic:Problem with Child and Parent Elements in resulting XMI File
Goto Forum:
  


Current Time: Sat Nov 11 08:18:14 GMT 2023

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

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

Back to the top