Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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 07:55 Go to next message
Alexis Muller is currently offline Alexis MullerFriend
Messages: 13
Registered: July 2009
Junior Member
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 09:57 Go to previous messageGo to next message
Radomil Dvorak is currently offline Radomil DvorakFriend
Messages: 249
Registered: July 2009
Senior Member
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 09:36 Go to previous messageGo to next message
Alexis Muller is currently offline Alexis MullerFriend
Messages: 13
Registered: July 2009
Junior Member
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
Re: [QVTO] QvtRuntimeException when running by program [message #106498 is a reply to message #106484] Thu, 11 June 2009 09:48 Go to previous messageGo to next message
Radomil Dvorak is currently offline Radomil DvorakFriend
Messages: 249
Registered: July 2009
Senior Member
Hi Alexis,

> Many thanks, I have solved my issue :)
Great!

> And, more important, TransformationExecutor is taking Resources as input/
> output, I am using EObject.

The executor uses ModelExtent interface which should be a sufficient
abstraction
and can hold a list of EObjects representing its contents.
There is a BasicModelExtent implementation where you can add whatever
EObjects,
for instance those retrieved from a resource or simply what you just
create on the fly.

Regards,
/Radek
Re: [QVTO] QvtRuntimeException when running by program [message #550256 is a reply to message #106442] Thu, 29 July 2010 16:01 Go to previous message
mm  is currently offline mm Friend
Messages: 3
Registered: July 2010
Junior Member
Hi Alexis

Could you please provide the beginning of your program, because I would like to test your example but I have an error when creating inObjects.

thanks

Previous Topic:[QVTO] How to generate a trace file
Next Topic:[QVT-R] Problem with subvertex
Goto Forum:
  


Current Time: Thu Apr 18 13:36:22 GMT 2024

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

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

Back to the top