Home » Modeling » ATL » Problems with ATL Programatically
Problems with ATL Programatically [message #1750275] |
Mon, 19 December 2016 12:41 |
|
Hello,
I found this topic "https://www.eclipse.org/forums/index.php/t/1066454/0/unread/" and it save me a lot of time, thank you very much to the authors.
However i still have a problem. When i run the ATL with Eclipse Launcher, the ATL runs perfectly, but programatically throws the following exception.
Exception:
Exception in thread "main" org.eclipse.m2m.atl.emftvm.util.VMException: Cannot set properties for regular objects: null
at Object::refSetValue(propname: String, value: Object) : Object(OCL)
Local variables: [OclUndefined, 'type', 'teste']
at static EMFTVM!ExecEnv::createSteriotype(nameSteriotype: String, typeSteriotype: String) : KDM!Stereotype#7(file:///teste_1.atl#[25:3-25:103])
Local variables: [nameSteriotype: String = 'teste', typeSteriotype: String = 'teste']
at rule createSteriotypes@applier#12(file:///teste_1.atl#[18:18-18:62])
Local variables: [__trace__: TRACE!TraceLink = 4a00d9cf:TRACE!TraceLink, segment: KDM!Segment = 6aa8e115:KDM!Segment, violationExtensionFamily: KDM!ExtensionFamily = 6f1c29b7:KDM!ExtensionFamily]
at static EMFTVM!ExecEnv::main() : Object(file:///teste_1.atl)
Local variables: []
at org.eclipse.m2m.atl.emftvm.util.OCLOperations$18.execute(OCLOperations.java:503)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.invoke(CodeBlockImpl.java:2357)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.internalExecute(CodeBlockImpl.java:854)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.execute(CodeBlockImpl.java:726)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.invokeStatic(CodeBlockImpl.java:2459)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.internalExecute(CodeBlockImpl.java:858)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.execute(CodeBlockImpl.java:726)
at org.eclipse.m2m.atl.emftvm.impl.RuleImpl$WithApplierWithoutPostApplyCbState.applyFor(RuleImpl.java:1210)
at org.eclipse.m2m.atl.emftvm.impl.RuleImpl$IsNotAbstractState.apply(RuleImpl.java:986)
at org.eclipse.m2m.atl.emftvm.impl.RuleImpl.apply(RuleImpl.java:2213)
at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl.matchAllSingle(ExecEnvImpl.java:2244)
at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl.run(ExecEnvImpl.java:2092)
at br.ufscar.kdm_manager.core.executionEngines.atlEngine.impl.atlEngines.ATLExecutionEngineUniqueParameters.launch(ATLExecutionEngineUniqueParameters.java:115)
at br.ufscar.kdm_manager.core.executionEngines.atlEngine.impl.atlEngines.ATLExecutionEngineUniqueParameters.main(ATLExecutionEngineUniqueParameters.java:143)
ATL:
-- @nsURI KDM=http://www.eclipse.org/MoDisco/kdm/kdm
-- @atlcompiler emftvm
module teste_1;
create OUT : KDM
refining IN : KDM;
rule createSteriotypes{
from
segment: KDM!Segment
to
segmentTo: KDM!Segment(
extension <- violationExtensionFamily
),
violationExtensionFamily: KDM!ExtensionFamily(
name <- 'API-VIOLATIONS STERIOTYPES',
stereotype <- thisModule.createSteriotype('teste','teste'),
stereotype <- thisModule.createSteriotype('teste2','teste2')
)
}
helper def : createSteriotype(nameSteriotype: String, typeSteriotype: String) :
KDM!Stereotype =
KDM!Stereotype.newInstance().refSetValue('name', nameSteriotype).refSetValue('type', typeSteriotype)
;
Could someone help me?
|
|
|
Re: Problems with ATL Programatically [message #1751045 is a reply to message #1750275] |
Tue, 03 January 2017 21:08 |
|
Somehow, your second invocation of "refSetValue()" is called on OclUndefined instead of the KDM!Stereotype instance. I'm not sure why. I should warn you that the reflective way of creating new metaclass instances -- "KDM!Stereotype.newInstance()" -- is not as safe as using a called or lazy rule. There were a couple other problems with your transformation re. property multiplicity (your code would only work with the normal ATL runtimes, not EMFTVM). Here's the code that works for me:
-- @nsURI KDM=http://www.eclipse.org/MoDisco/kdm/kdm
-- @atlcompiler emftvm
module teste_1;
create OUT : KDM
refining IN : KDM;
rule createSteriotypes{
from
segment: KDM!Segment
to
segmentTo: KDM!Segment(
extension <- Sequence{violationExtensionFamily}
),
violationExtensionFamily: KDM!ExtensionFamily(
name <- 'API-VIOLATIONS STERIOTYPES',
stereotype <- Sequence{
thisModule.createSteriotype('teste','teste'),
thisModule.createSteriotype('teste2','teste2')}
)
}
lazy rule createSteriotype {
from
nameSteriotype : String,
typeSteriotype : String
to
stereotype : KDM!Stereotype (
name <- nameSteriotype,
type <- typeSteriotype)
}
Cheers,
Dennis
|
|
|
Re: Problems with ATL Programatically [message #1752296 is a reply to message #1751045] |
Fri, 20 January 2017 17:05 |
|
Dear Dennis Wagelaar,
Thanks a lot for the help.
Sorry for waiting to respond, the end of the year and deadlines were crazy.
I did not know it's not so safe to use ".newInstance ()" as using a call or lazy rule.
After today I will use more lazy rules.
With this ATL code the execution works perfectly.
Thank you very much.
One more question I did not find an answer.
With the line Eclipse Launch throws the following exception and without the line runs perfectly.
org.eclipse.m2m.atl.engine.emfvm.VMException: Parsing error, line 1 column 1: Premature ending of the file.
Java Stack:
org.eclipse.m2m.atl.engine.emfvm.VMException: Parsing error, line 1 column 1: Premature ending of the file.
at org.eclipse.m2m.atl.engine.emfvm.ASMXMLReader.read(ASMXMLReader.java:66)
at org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMLauncher.loadModule(EMFVMLauncher.java:179)
at org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMLauncher.getASMFromObject(EMFVMLauncher.java:191)
at org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMLauncher.internalLaunch(EMFVMLauncher.java:158)
at org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMUILauncher.launch(EMFVMUILauncher.java:46)
at org.eclipse.m2m.atl.core.service.LauncherService.launch(LauncherService.java:136)
at org.eclipse.m2m.atl.core.ui.launch.AtlLaunchConfigurationDelegate.launchOrDebug(AtlLaunchConfigurationDelegate.java:300)
at org.eclipse.m2m.atl.core.ui.launch.AtlLaunchConfigurationDelegate.launch(AtlLaunchConfigurationDelegate.java:237)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:885)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:739)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1039)
at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1256)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: org.eclipse.m2m.atl.engine.emfvm.ASMXMLReaderException; lineNumber: 1; columnNumber: 1; Parsing error, line 1 column 1: Premature ending of the file.
at org.eclipse.m2m.atl.engine.emfvm.ASMXMLReader.fatalError(ASMXMLReader.java:189)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.eclipse.m2m.atl.engine.emfvm.ASMXMLReader.read(ASMXMLReader.java:62)
... 12 more
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Premature ending of the file.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
... 27 more
Already programmatically is the opposite, without the line throws the following exception and with the line works perfectly.
Exception in thread "main" org.eclipse.m2m.atl.emftvm.util.VMException: Error during module loading: Module teste_nome_classe not found
at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl.loadModule(ExecEnvImpl.java:1265)
at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl.loadModule(ExecEnvImpl.java:1217)
at br.ufscar.kdm_manager.core.executionEngines.atlEngine.impl.atlEngines.ATLExecutionEngineUniqueParameters2.launch(ATLExecutionEngineUniqueParameters2.java:101)
at br.ufscar.kdm_manager.core.executionEngines.atlEngine.impl.atlEngines.ATLExecutionEngineUniqueParameters2.main(ATLExecutionEngineUniqueParameters2.java:157)
Caused by: org.eclipse.m2m.atl.emftvm.util.ModuleNotFoundException: Module teste_nome_classe not found
at org.eclipse.m2m.atl.emftvm.util.DefaultModuleResolver.resolveModule(DefaultModuleResolver.java:77)
at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl.loadModule(ExecEnvImpl.java:1238)
... 3 more
Could you explain the difference to me?
|
|
| |
Re: Problems with ATL Programatically [message #1752327 is a reply to message #1752313] |
Sat, 21 January 2017 15:08 |
|
Hi louis andia
Thanks for the answer.
I already read this wiki, but did not realize it.
I've found this difference strange, further by the fact that this line is only a comment in ATL and automatically modify the compiler.
Well, anyway, thanks for the explanation.
And Dennis, thanks again for the help with the ATL code.
|
|
|
Re: Problems with ATL Programatically [message #1752331 is a reply to message #1752327] |
Sat, 21 January 2017 17:36 |
|
Hello again folks,
I'm new in ATL and I have one more problem.
I know that EMFTVM (in the refining module) see the IN and OUT model are one and the same model.
But I'm trying to use two IN models where one model gets elements from the other (keeping the elements from the first one and copying the elements from the second one to the first).
On models loading if I try to use
env.registerInOutModel("IN", inModel);
env.registerInputModel("IN2", inModel2);
i get the exception
Exception in thread "main" org.eclipse.m2m.atl.emftvm.util.VMException: java.lang.IllegalArgumentException: Cannot set properties of 64e7619d:Segment, as it is contained in an input model
at rule copySteriotypes@applier#3(file:///teste_2.atl#[15:4-15:21])
Local variables: [__trace__: TRACE!TraceLink = 329dbdbf:TRACE!TraceLink, segment: KDM!Segment = 64e7619d:Segment, test: KDM!ExtensionFamily = 1b266842:ExtensionFamily]
at static EMFTVM!ExecEnv::main() : Object(file:///teste_2.atl)
Local variables: []
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.internalExecute(CodeBlockImpl.java:987)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.execute(CodeBlockImpl.java:726)
at org.eclipse.m2m.atl.emftvm.impl.RuleImpl$WithApplierWithoutPostApplyCbState.applyFor(RuleImpl.java:1210)
at org.eclipse.m2m.atl.emftvm.impl.RuleImpl$IsNotAbstractState.apply(RuleImpl.java:986)
at org.eclipse.m2m.atl.emftvm.impl.RuleImpl.apply(RuleImpl.java:2213)
at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl.matchAllSingle(ExecEnvImpl.java:2244)
at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl.run(ExecEnvImpl.java:2092)
at br.ufscar.kdm_manager.core.executionEngines.atlEngine.impl.atlEngines.ATLExecutionEngineRefiningModuleTwoParameters.launch(ATLExecutionEngineRefiningModuleTwoParameters.java:299)
at br.ufscar.kdm_manager.core.executionEngines.atlEngine.impl.atlEngines.ATLExecutionEngineRefiningModuleTwoParameters.main(ATLExecutionEngineRefiningModuleTwoParameters.java:355)
Caused by: java.lang.IllegalArgumentException: Cannot set properties of 64e7619d:Segment, as it is contained in an input model
at org.eclipse.m2m.atl.emftvm.util.EMFTVMUtil.set(EMFTVMUtil.java:560)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.set(CodeBlockImpl.java:1691)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.internalExecute(CodeBlockImpl.java:777)
... 8 more
and if i try to use
env.registerInOutModel("IN", inModel);
env.registerInputModel("IN2", inModel2);
i get the exception
Exception in thread "main" org.eclipse.m2m.atl.emftvm.util.VMException: java.util.ConcurrentModificationException
at public java.lang.Object org.eclipse.m2m.atl.emftvm.util.LazyCollection.iterate(java.lang.Object,org.eclipse.m2m.atl.emftvm.CodeBlock)
Local variables: []
at static EMFTVM!ExecEnv::getAllStereotype() : KDM!Stereotype#5(file:///teste_2.atl#[24:2-27:3])
Local variables: []
at rule copySteriotypes@applier#10(file:///teste_2.atl#[19:18-19:47])
Local variables: [__trace__: TRACE!TraceLink = 4b34fff9:TRACE!TraceLink, segment: KDM!Segment = 495ee280:Segment, test: KDM!ExtensionFamily = 421e361:ExtensionFamily]
at static EMFTVM!ExecEnv::main() : Object(file:///teste_2.atl)
Local variables: []
at org.eclipse.m2m.atl.emftvm.util.EMFTVMUtil.invokeNative(EMFTVMUtil.java:1139)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.invoke(CodeBlockImpl.java:2353)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.internalExecute(CodeBlockImpl.java:854)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.execute(CodeBlockImpl.java:726)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.invokeStatic(CodeBlockImpl.java:2401)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.internalExecute(CodeBlockImpl.java:858)
at org.eclipse.m2m.atl.emftvm.impl.CodeBlockImpl.execute(CodeBlockImpl.java:726)
at org.eclipse.m2m.atl.emftvm.impl.RuleImpl$WithApplierWithoutPostApplyCbState.applyFor(RuleImpl.java:1210)
at org.eclipse.m2m.atl.emftvm.impl.RuleImpl$IsNotAbstractState.apply(RuleImpl.java:986)
at org.eclipse.m2m.atl.emftvm.impl.RuleImpl.apply(RuleImpl.java:2213)
at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl.matchAllSingle(ExecEnvImpl.java:2244)
at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl.run(ExecEnvImpl.java:2092)
at br.ufscar.kdm_manager.core.executionEngines.atlEngine.impl.atlEngines.ATLExecutionEngineRefiningModuleTwoParameters.launch(ATLExecutionEngineRefiningModuleTwoParameters.java:299)
at br.ufscar.kdm_manager.core.executionEngines.atlEngine.impl.atlEngines.ATLExecutionEngineRefiningModuleTwoParameters.main(ATLExecutionEngineRefiningModuleTwoParameters.java:355)
Caused by: java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.checkForComodification(Unknown Source)
at java.util.ArrayList$Itr.next(Unknown Source)
at org.eclipse.m2m.atl.emftvm.util.LazyCollection$UnionIterator.next(LazyCollection.java:807)
at org.eclipse.m2m.atl.emftvm.util.LazyCollection$UnionIterator.next(LazyCollection.java:802)
at org.eclipse.m2m.atl.emftvm.util.LazyCollection.iterate(LazyCollection.java:2287)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.m2m.atl.emftvm.util.EMFTVMUtil.invokeNative(EMFTVMUtil.java:1133)
... 13 more
regarding the ATL the code is
-- @nsURI KDM=http://www.eclipse.org/MoDisco/kdm/kdm
-- @nsURI KDM2=http://www.eclipse.org/MoDisco/kdm/kdm
-- @atlcompiler emftvm
module teste_2;
create OUT : KDM
refining IN: KDM, IN2 : KDM2;
rule copySteriotypes{
from
segment: KDM!Segment
to
segmentTo: KDM!Segment(
extension <- test
),
test: KDM!ExtensionFamily(
name <- 'API-VIOLATIONS STERIOTYPES',--thisModule.getNameExtension(),
stereotype <- thisModule.getAllStereotype()
)
}
helper def : getAllStereotype() : KDM!Stereotype =
KDM2!Stereotype.allInstances() -> iterate( stereotype ; elements : OrderedSet(KDM!Stereotype) =
OrderedSet{} |
elements.append(thisModule.copyStereotype(stereotype))
)
;
lazy rule copyStereotype {
from
stereotypeIn: KDM2!Stereotype
to
stereotype : KDM!Stereotype (
name <- stereotypeIn.name,
type <- stereotypeIn.type)
}
--helper def : copyStereotype(stereotype: KDM2!Stereotype) :
-- KDM!Stereotype =
-- KDM!Stereotype.newInstance().refSetValue('name', stereotype.refGetValue('name')).refSetValue('type', stereotype.refGetValue('type'))
--;
--helper def : getNameExtension() : String = KDM2!ExtensionFamily.allInstances().first().name;--refGetValue('name');
i tryed to search options but i can not found a solution.
I can not discover that the problem is with the programatically call or if is the ATL, with the commented part the Eclipse Launcher works fine but with the lazy rule the Eclipse Launcher do not works and programatically i get the exceptions.
Can anyone help me?
|
|
|
Goto Forum:
Current Time: Thu Apr 18 04:10:57 GMT 2024
Powered by FUDForum. Page generated in 0.03033 seconds
|