Home » Modeling » M2T (model-to-text transformation) » [acceleo 3] OclInvalid_Class while trying to read an attribute in the model
| |
Re: [acceleo 3] OclInvalid_Class while trying to read an attribute in the model [message #730935 is a reply to message #730915] |
Thu, 29 September 2011 14:56 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
In [file ('stdout', false)][table+'\n'/][/file]
you invoke the 'OCL' operation to compute the string concatenation of
Acceleo's default toString for table and a new lin.
It would be simpler to write
[file ('stdout', false)]table/]
[/file]
In [file ('stdout', false)][table.localCustomizations+'\n'/][/file]
you similarly perform an OCL evaluation of the concatenation of
Acceleo's toString for what is presumably a Collection. I have no idea
what this does, but if at any point something fails you will get
invalid, and probably will get invalid if the Collection is empty too.
The OclInvalid_Class mumbo jumbo is OCL's very klunky way of printing
'invalid'. The new Eclipse OCL pivot implementation has the natural
spelling.
I suggest you use a [for loop to iterate your localCustomizations.
It is very very unlikely that Acceleo has failed to load them, since
that would be a failure in massively widely used EMF code.
Regards
Ed Willink
On 29/09/2011 15:21, saadia dhouib wrote:
> Hi all,
>
> I'm writing my first acceleo generator.
> I want to read the values of an attribute which is a List:
>
>
> [module
> generate('http://www.eclipse.org/Papyrus/Table/0.8.0/papyrustableinstance','http://www.eclipse.org/EmfFacet/infra/browser/custom/0.8')]
>
> [template public getTableLocalCustomizations(aPapyrusTableInstance :
> PapyrusTableInstance)]
> [file ('stdout', false)][table+'\n'/][/file]
> [file ('stdout', false)][table.localCustomizations+'\n'/][/file]
> [/template]
>
> It seems that Acceleo does not load the localcustomizations attribute
> contents (localCustomizations : MetamodelView [1..*]).
> The result of the print in the console is as follows:
>
> mailto:org.eclipse.emf.facet.widgets.nattable.instance.tableinstance2.impl.TableInstance2Impl@14e6393
> (parameter: null, hideEmptyColumns: false, onlyShowCommonColumns:
> false, description: Table Description)
> mailto:org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1b4a6c2 (eClass:
> mailto:org.eclipse.emf.ecore.impl.EClassImpl@130129c (name:
> OclInvalid_Class) (instanceClassName: null) (abstract: false,
> interface: false))
>
>
>
|
|
| |
Re: [acceleo 3] OclInvalid_Class while trying to read an attribute in the model [message #731161 is a reply to message #730958] |
Fri, 30 September 2011 07:27 |
saadia dhouib Messages: 36 Registered: April 2010 |
Member |
|
|
Hi Edward,
I have changed my loop to print the contents of the localcustomizations list in the console:
line 143 [template public generatePlugin(aPapyrusTableInstance : PapyrusTableInstance)]
[comment @main/]
line 146 [file ('../plugin.xml', false, 'UTF-8')]
line 211 [file ('stdout', false)][table/][/file]
line 212 [for (it : MetamodelView | table.localCustomizations)]
line 213 [file ('stdout', false)][it/]
line 214 [/file]
[/for]
The table is printed in the console, but I have still errors in the loop:
org.eclipse.emf.facet.widgets.nattable.instance.tableinstance2.impl.TableInstance2Impl@12c70d2 (parameter: null, hideEmptyColumns: false, onlyShowCommonColumns: false, description: Table Description)
!ENTRY org.eclipse.ocl 4 10 2011-09-30 09:18:21.025
!MESSAGE Evaluation failed with an exception: (no message)
!STACK 0
java.lang.IllegalArgumentException
at org.eclipse.ocl.ecore.EcoreEvaluationEnvironment.navigateProperty(EcoreEvaluationEnvironment.java:258)
at org.eclipse.ocl.ecore.EcoreEvaluationEnvironment.navigateProperty(EcoreEvaluationEnvironment.java:1)
at org.eclipse.ocl.EvaluationVisitorImpl.visitPropertyCallExp(EvaluationVisitorImpl.java:2088)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationVisitor.visitPropertyCallExp(AcceleoEvaluationVisitor.java:1111)
at org.eclipse.ocl.ecore.impl.PropertyCallExpImpl.accept(PropertyCallExpImpl.java:238)
at org.eclipse.ocl.AbstractEvaluationVisitor.visitExpression(AbstractEvaluationVisitor.java:248)
at org.eclipse.ocl.EvaluationVisitorDecorator.visitExpression(EvaluationVisitorDecorator.java:156)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationVisitor.switchExpression(AcceleoEvaluationVisitor.java:1693)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationVisitor.visitExpression(AcceleoEvaluationVisitor.java:999)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationVisitor.visitAcceleoForBlock(AcceleoEvaluationVisitor.java:413)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationVisitor.switchExpression(AcceleoEvaluationVisitor.java:1656)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationVisitor.visitExpression(AcceleoEvaluationVisitor.java:999)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationVisitor.visitAcceleoFileBlock(AcceleoEvaluationVisitor.java:396)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationVisitor.switchExpression(AcceleoEvaluationVisitor.java:1663)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationVisitor.visitExpression(AcceleoEvaluationVisitor.java:999)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationVisitor.visitAcceleoTemplate(AcceleoEvaluationVisitor.java:867)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationVisitor.switchExpression(AcceleoEvaluationVisitor.java:1643)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationVisitor.visitExpression(AcceleoEvaluationVisitor.java:999)
at org.eclipse.ocl.internal.evaluation.QueryImpl.evaluate(QueryImpl.java:152)
at org.eclipse.ocl.ecore.QueryImpl.evaluate(QueryImpl.java:62)
at org.eclipse.acceleo.engine.generation.AcceleoEngine.doEvaluate(AcceleoEngine.java:265)
at org.eclipse.acceleo.engine.generation.AcceleoEngine.evaluate(AcceleoEngine.java:130)
at org.eclipse.acceleo.engine.service.AcceleoService.doGenerateTemplate(AcceleoService.java:860)
at org.eclipse.acceleo.engine.service.AcceleoService.doGenerate(AcceleoService.java:523)
at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator.generate(AbstractAcceleoGenerator.java:175)
at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator.doGenerate(AbstractAcceleoGenerator.java:154)
at org.eclipse.papyrus.table.generation.acceleo.main.Generate.doGenerate(Generate.java:220)
at org.eclipse.papyrus.table.generation.handlers.TableJavaCodeGenerator.runAcceleoTransformation(TableJavaCodeGenerator.java:87)
at org.eclipse.papyrus.table.generation.handlers.GenerateTableHandler$1.doExecuteWithResult(GenerateTableHandler.java:141)
at org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand.doExecute(AbstractTransactionalCommand.java:247)
at org.eclipse.emf.workspace.AbstractEMFOperation.execute(AbstractEMFOperation.java:150)
at org.eclipse.papyrus.core.utils.GMFtoEMFCommandWrapper.execute(GMFtoEMFCommandWrapper.java:87)
at org.eclipse.emf.common.command.CompoundCommand.execute(CompoundCommand.java:267)
at org.eclipse.emf.workspace.EMFCommandOperation.doExecute(EMFCommandOperation.java:119)
at org.eclipse.emf.workspace.AbstractEMFOperation.execute(AbstractEMFOperation.java:150)
at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:513)
at org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.doExecute(WorkspaceCommandStackImpl.java:208)
at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:165)
at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:219)
at org.eclipse.papyrus.modelexplorer.handler.AbstractCommandHandler.execute(AbstractCommandHandler.java:150)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:293)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
at org.eclipse.ui.menus.CommandContributionItem.handleWidgetSelection(CommandContributionItem.java:829)
at org.eclipse.ui.menus.CommandContributionItem.access$19(CommandContributionItem.java:815)
at org.eclipse.ui.menus.CommandContributionItem$5.handleEvent(CommandContributionItem.java:805)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
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.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
!ENTRY org.eclipse.acceleo.engine 2 2 2011-09-30 09:18:21.181
!MESSAGE Invalid loop iteration at line 212 in Module generate for block for (self.table.localCustomizations). Last recorded value of self was org.eclipse.papyrus.table.instance.papyrustableinstance.impl.PapyrusTableInstanceImpl@a934ec (name: DefaultTable, type: PapyrusDefaultTable, isSynchronized: false).
!STACK 0
org.eclipse.acceleo.engine.AcceleoEvaluationException: Invalid loop iteration at line 212 in Module generate for block for (self.table.localCustomizations). Last recorded value of self was org.eclipse.papyrus.table.instance.papyrustableinstance.impl.PapyrusTableInstanceImpl@a934ec (name: DefaultTable, type: PapyrusDefaultTable, isSynchronized: false).
at generate.generatePlugin(PapyrusTableInstance)(generate.mtl:212)
at generate.generatePlugin(PapyrusTableInstance)(generate.mtl:146)
at generate.generatePlugin(PapyrusTableInstance)(generate.mtl:143)
|
|
|
Re: [acceleo 3] OclInvalid_Class while trying to read an attribute in the model [message #731163 is a reply to message #730958] |
Fri, 30 September 2011 07:30 |
|
Hi,
Quote:
In [file ('stdout', false)][table+'\n'/][/file]
you invoke the 'OCL' operation to compute the string concatenation of
Acceleo's default toString for table and a new lin.
and that is supported, though indeed not the most readable way of doing it.
[Sequence{'a', 'b'} + 'c'/]
does output "abc". Moreover,
properly outputs "c"...
However, that is with the latest versions of Acceleo. I suspect that you are using one of the versions where we did not (or _could_ not) override OCL's "plus" operation. Which version of Acceleo are you using, under which version of Eclipse?
Laurent Goubet
Obeo
|
|
|
Re: [acceleo 3] OclInvalid_Class while trying to read an attribute in the model [message #731188 is a reply to message #731163] |
Fri, 30 September 2011 08:17 |
|
Okay, so what fails here is that "localCustomizations" cannot be found. Acceleo (and, transitively, OCL) managed to compile your module properly; which means that at compile time, that eStructuralFeature was found. Yet at runtime, OCL does not manage to find it. This issue is most likely due to OCL not interacting well with EMF Facet.
Ed, the code of EcoreEvaluationEnvironment fails because of the line (or at least I think that this line is the culprit) :
if (etarget.eClass().getEAllStructuralFeatures().contains(property)) {
Why would the compilation work and not the evaluation?
Laurent Goubet
Obeo
|
|
| |
Re: [acceleo 3] OclInvalid_Class while trying to read an attribute in the model [message #731218 is a reply to message #731188] |
Fri, 30 September 2011 09:55 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
It could either be that
line 244: if (target instanceof EObject) fails, i.e target is not an
EObject. Maybe the model does not extend EObject. Maybe a bad navigation
has traversed a Collection or a Tuple or unresolved proxy.
line 247: if
(etarget.eClass().getEAllStructuralFeatures().contains(property)) fails,
i.e. eTarget does not have the required feature; - out of date generated
Java compared to the *.ecore used by the editor/compiler. Or property is
a 'different' property because of our old friend meta-model schizophrenia.
Since navigation to table has succeeded, out of data Java is most
likely, but unwise cross-resource containment with unresolved proxies
might cause any amount of confusing chaos.
Difficult to conclude more than that table.localCustomizations is bad
without single stepping to examine the navigation as it fails.
However regenerating the Java has to be worth a try.
Regards
Ed Willink
On 30/09/2011 09:17, Laurent Goubet wrote:
> Okay, so what fails here is that "localCustomizations" cannot be
> found. Acceleo (and, transitively, OCL) managed to compile your module
> properly; which means that at compile time, that eStructuralFeature
> was found. Yet at runtime, OCL does not manage to find it. This issue
> is most likely due to OCL not interacting well with EMF Facet.
>
> Ed, the code of EcoreEvaluationEnvironment fails because of the line
> (or at least I think that this line is the culprit) :
> if (etarget.eClass().getEAllStructuralFeatures().contains(property)) {
>
> Why would the compilation work and not the evaluation?
>
> Laurent Goubet
> Obeo
|
|
| | | | |
Re: [acceleo 3] OclInvalid_Class while trying to read an attribute in the model [message #733999 is a reply to message #733967] |
Thu, 06 October 2011 09:28 |
|
And yet ... I apologize Ed, there is a good possibility that you are right and that this _is_ a case of metamodel schizophrenia... Looking at how papyrus metamodels and customizations through facets are defined, I fear that the URIs are not right.
Saadia, could you provide us with the models you are using for this generation? I did not manage to create a useable sample of my own through papyrus.
Laurent Goubet
Obeo
|
|
|
Goto Forum:
Current Time: Thu Mar 28 11:49:22 GMT 2024
Powered by FUDForum. Page generated in 0.03353 seconds
|