Home » Archived » M2M (model-to-model transformation) » [QVTO] QvtRuntimeException when running by program
[QVTO] QvtRuntimeException when running by program [message #106442] |
Wed, 10 June 2009 03:55  |
Eclipse User |
|
|
|
Hello,
I need to call qvto transformations by program in my own plugin.
I am using this code :
....
QvtInterpretedTransformation transformation =
new QvtInterpretedTransformation(TransformationUtil.getQvtModule (uri));
List<EObject> inObjects = new ArrayList<EObject>();
for ((Map.Entry<InPort, EObject> entry : inputs.entrySet())
inObjects.add(entry.getValue());
TransformationRunner.In input =
new TransformationRunner.In(inObjects.toArray(new EObject[inObjects.size
()]), new Context());
TransformationRunner.Out output = transformation.run(input);
....
This code works for almost all of my qvto transformations, only one has
trouble.
When I am launching it via Eclipse 'run as' it works, when I am launching
it via my above code I am getting :
org.eclipse.m2m.internal.qvt.oml.evaluator.QvtRuntimeExcepti on:
org.eclipse.emf.ecore.impl.DynamicEObjectImpl cannot be cast to
java.lang.Integer
The incriminate qvt line code is like that :
vectorElem := Sequence{1 .. partshape.shapes->size()}->collect (0);
where 'partshape.shapes' is a references collection.
Any idea why this is working with the 'normal' qvto launcher but not with
code ?
Many thanks in advance,
regards
|
|
|
Re: [QVTO] QvtRuntimeException when running by program [message #106456 is a reply to message #106442] |
Wed, 10 June 2009 05:57   |
Eclipse User |
|
|
|
Hi Alexis,
The actual cause is in how MDT OCL handles invalid values in the last
expression
of a collection range.
In your case, "partshape.shapes->size()" results in invalid
value (of OclInvalid type) because 'partshape' is for some reason null or
invalid.
As I can see the MDT OCL impl, it always casts the range last value to
Integer,
in this case causing "java.lang.ClassCastException:
org.eclipse.emf.ecore.impl.DynamicEObjectImpl"
and should definitely be more tolerant.
You can reproduce the same in a plain OCL like this: Sequence {
1..(1/0).round() }.
Sure you need your transf to continue so you can handle this in your code
explicitly.
As for the difference in launch using Eclipse configuration or Java, I
can't reproduce
this and assume there must be a difference. Perhaps another input model,
configuration properties that might affect the execution flow?
If not, we have something to correct ;)
I can see you use some internals, I would recommend looking at
'org.eclipse.m2m.qvt.oml.TransformationExecutor', in case you do not need
anything special that is not exposed.
Check:
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.m2m/org .eclipse.m2m.qvt.oml/examples/org.eclipse.m2m.qvt.oml.econ20 09.tutorial/projects/qvto.ecore2uml.invoke/src/qvto/ecore2um l/invoke/ConvertEcore2UML.java?root=Modeling_Project&vie w=markup
Regards,
/Radek
On Wed, 10 Jun 2009 09:55:21 +0200, Alexis Muller <Alexis.Muller@inria.fr>
wrote:
> Hello,
>
> I need to call qvto transformations by program in my own plugin.
> I am using this code :
>
> ...
> QvtInterpretedTransformation transformation =
> new QvtInterpretedTransformation(TransformationUtil.getQvtModule (uri));
> List<EObject> inObjects = new ArrayList<EObject>();
> for ((Map.Entry<InPort, EObject> entry : inputs.entrySet())
> inObjects.add(entry.getValue());
> TransformationRunner.In input =
> new TransformationRunner.In(inObjects.toArray(new
> EObject[inObjects.size
> ()]), new Context());
>
> TransformationRunner.Out output = transformation.run(input);
> ...
>
> This code works for almost all of my qvto transformations, only one has
> trouble.
> When I am launching it via Eclipse 'run as' it works, when I am launching
> it via my above code I am getting :
>
> org.eclipse.m2m.internal.qvt.oml.evaluator.QvtRuntimeExcepti on:
> org.eclipse.emf.ecore.impl.DynamicEObjectImpl cannot be cast to
> java.lang.Integer
> The incriminate qvt line code is like that :
>
> vectorElem := Sequence{1 .. partshape.shapes->size()}->collect (0);
>
> where 'partshape.shapes' is a references collection.
>
> Any idea why this is working with the 'normal' qvto launcher but not with
> code ?
>
> Many thanks in advance,
> regards
|
|
|
Re: [QVTO] QvtRuntimeException when running by program [message #106484 is a reply to message #106456] |
Thu, 11 June 2009 05:36   |
Eclipse User |
|
|
|
Hi Radek,
Many thanks, I have solved my issue :)
On Wed, 10 Jun 2009 11:57:50 +0200, Radek Dvorak wrote:
> In your case, "partshape.shapes->size()" results in invalid value (of
> OclInvalid type) because 'partshape' is for some reason null or invalid.
[...]
> As for the difference in launch using Eclipse configuration or Java, I
> can't reproduce
> this and assume there must be a difference. Perhaps another input model,
> configuration properties that might affect the execution flow?
[...]
Indeed, the input model was not *exactly* the same in both case.
> I can see you use some internals, I would recommend looking at
> 'org.eclipse.m2m.qvt.oml.TransformationExecutor', in case you do not
> need anything special that is not exposed.
[...]
This Class is available with the new qvto plugin (2.0.0), but not with my
production version (1.0.1).
And, more important, TransformationExecutor is taking Resources as input/
output, I am using EObject.
Again, thanks for your help.
Regards,
Alexis
|
|
| | |
Goto Forum:
Current Time: Thu May 08 08:30:14 EDT 2025
Powered by FUDForum. Page generated in 0.05189 seconds
|