Home » Archived » M2M (model-to-model transformation) » [ATL] ...emfvm.VMException caused by ClassCastException, but why?
[ATL] ...emfvm.VMException caused by ClassCastException, but why? [message #491686] |
Thu, 15 October 2009 13:19 |
Tassilo Horn Messages: 93 Registered: July 2009 |
Member |
|
|
Hi all,
I have this rule:
--8<---------------cut here---------------start------------->8---
rule Member2Male {
from
s : Families!Member (not s.isFemale)
to
a : Persons!Address (
street <- s.family.street,
town <- s.family.town
),
t : Persons!Male (
address <- a,
fullName <- s.firstName + ' ' + s.family.lastName,
genealogy <- s.tree,
parents <- s.parents,
wife <- s.spouse,
ageGroup <- s.ageGroup
)
}
--8<---------------cut here---------------end--------------->8---
to create a Male for each source model Person that is not female.
Additionally, I want to create an Address. In the metamodel, there's a
composition in between: Person 0..1 <>----- 0..1 Address
The role names are person and address. Ok, when I try to run the
transformation, I get this exception.
--8<---------------cut here---------------start------------->8---
org.eclipse.m2m.atl.engine.emfvm.VMException
at __applyMember2Male(Families2Persons.atl[81:4-81:20])
local variables: self=thisModule, link=org.eclipse.m2m.atl.engine.emfvm.lib.TransientLink@4f444bef, s=IN!<unnamed>:Families!Member, a=OUT!<unnamed>:Persons!Address, t=OUT!<unnamed>:Persons!Male
at __exec__(Families2Persons.atl)
local variables: self=thisModule, e=org.eclipse.m2m.atl.engine.emfvm.lib.TransientLink@4f444bef
at main(Families2Persons.atl)
local variables: self=thisModule
Java Stack:
org.eclipse.m2m.atl.engine.emfvm.VMException
at org.eclipse.m2m.atl.engine.emfvm.adapter.EMFModelAdapter.set (EMFModelAdapter.java:637)
at org.eclipse.m2m.atl.engine.emfvm.ASMOperation.exec(ASMOperat ion.java:451)
at org.eclipse.m2m.atl.engine.emfvm.ASMOperation.exec(ASMOperat ion.java:387)
at org.eclipse.m2m.atl.engine.emfvm.ASMOperation.exec(ASMOperat ion.java:387)
at org.eclipse.m2m.atl.engine.emfvm.ASM.run(ASM.java:197)
at org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMLauncher.launch (EMFVMLauncher.java:162)
at org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMLauncher.launch (EMFVMLauncher.java:135)
at org.eclipse.m2m.atl.core.service.LauncherService.launch(Laun cherService.java:135)
at org.eclipse.m2m.atl.core.ui.launch.AtlLaunchConfigurationDel egate.launch(AtlLaunchConfigurationDelegate.java:222)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:853)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:703)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(D ebugUIPlugin.java:866)
at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlu gin.java:1069)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.lang.ClassCastException
--8<---------------cut here---------------end--------------->8---
The source position it links to is the line "wife <- s.spouse,", but I'm
pretty sure that line is ok. If I comment out the
a : Persons!Address (...),
part and the "address <- a" line, then the transformation works as
expected, of course without creation of addresses.
I tried to create t before a, or assigning "person <- t" instead of the
other way round, but the error persists.
Any pointers?
Bye,
Tassilo
|
|
| |
Re: [ATL] ...emfvm.VMException caused by ClassCastException, but why? [message #491780 is a reply to message #491722] |
Thu, 15 October 2009 19:04 |
Tassilo Horn Messages: 93 Registered: July 2009 |
Member |
|
|
William Piers <william.piers@obeo.fr> writes:
Hi William,
> references. Anyway, the error message isn't explicit. Is it possible
> for you to send a zip containing the project (ecore files, input model
> and transformation) ?
Sure, get the workspace at
http://www.uni-koblenz.de/~horn/atl-workspace.tar.gz
Bye,
Tassilo
>> --8<---------------cut here---------------start------------->8---
>> rule Member2Male {
>> from
>> s : Families!Member (not s.isFemale)
>> to
>> a : Persons!Address (
>> street <- s.family.street,
>> town <- s.family.town
>> ),
>> t : Persons!Male (
>> address <- a,
>> fullName <- s.firstName + ' ' + s.family.lastName,
>> genealogy <- s.tree,
>> parents <- s.parents,
>> wife <- s.spouse,
>> ageGroup <- s.ageGroup
>> )
>> }
>> --8<---------------cut here---------------end--------------->8---
>>
>> to create a Male for each source model Person that is not female.
>> Additionally, I want to create an Address. In the metamodel, there's a
>> composition in between: Person 0..1 <>----- 0..1 Address
>>
>> The role names are person and address. Ok, when I try to run the
>> transformation, I get this exception.
>>
>> --8<---------------cut here---------------start------------->8---
>> org.eclipse.m2m.atl.engine.emfvm.VMException
>> at __applyMember2Male(Families2Persons.atl[81:4-81:20])
>> local variables: self=thisModule, link=org.eclipse.m2m.atl.engine.emfvm.lib.TransientLink@4f444bef, s=IN!<unnamed>:Families!Member, a=OUT!<unnamed>:Persons!Address, t=OUT!<unnamed>:Persons!Male
>> at __exec__(Families2Persons.atl)
>> local variables: self=thisModule, e=org.eclipse.m2m.atl.engine.emfvm.lib.TransientLink@4f444bef
>> at main(Families2Persons.atl)
>> local variables: self=thisModule
>> Java Stack:
>> org.eclipse.m2m.atl.engine.emfvm.VMException
>> at org.eclipse.m2m.atl.engine.emfvm.adapter.EMFModelAdapter.set (EMFModelAdapter.java:637)
>> at org.eclipse.m2m.atl.engine.emfvm.ASMOperation.exec(ASMOperat ion.java:451)
>> at org.eclipse.m2m.atl.engine.emfvm.ASMOperation.exec(ASMOperat ion.java:387)
>> at org.eclipse.m2m.atl.engine.emfvm.ASMOperation.exec(ASMOperat ion.java:387)
>> at org.eclipse.m2m.atl.engine.emfvm.ASM.run(ASM.java:197)
>> at org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMLauncher.launch (EMFVMLauncher.java:162)
>> at org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMLauncher.launch (EMFVMLauncher.java:135)
>> at org.eclipse.m2m.atl.core.service.LauncherService.launch(Laun cherService.java:135)
>> at org.eclipse.m2m.atl.core.ui.launch.AtlLaunchConfigurationDel egate.launch(AtlLaunchConfigurationDelegate.java:222)
>> at org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:853)
>> at org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:703)
>> at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(D ebugUIPlugin.java:866)
>> at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlu gin.java:1069)
>> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
>> Caused by: java.lang.ClassCastException
>> --8<---------------cut here---------------end--------------->8---
>>
>> The source position it links to is the line "wife <- s.spouse,", but I'm
>> pretty sure that line is ok. If I comment out the
>>
>> a : Persons!Address (...),
>>
>> part and the "address <- a" line, then the transformation works as
>> expected, of course without creation of addresses.
>>
>> I tried to create t before a, or assigning "person <- t" instead of the
>> other way round, but the error persists.
>>
>> Any pointers?
>>
>> Bye,
>> Tassilo
|
|
|
Re: [ATL] ...emfvm.VMException caused by ClassCastException, but why? [message #491873 is a reply to message #491780] |
Fri, 16 October 2009 10:01 |
William Piers Messages: 303 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------020002050205010401000502
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Hello,
The error happens when you try to put an Address into the "husband" or
"wife" feature.
To rely input model elements with newly created elements, ATL uses an
implicit traceability mechanism:
if IN!A is transformed to OUT!B1, OUT!B2 (as B1 and B2 are ordered
inside of the rule, "to" section), when you refer to A it will in fact
refer to OUT!B1.
If you want to refer to B2 you need to use resolveTemp. You can read
more about resolveTemp here:
http://wiki.eclipse.org/ATL/User_Guide#The_ATL_Module_data_t ype
In your case, as you never want to refer the Address of a person, you
just have to reorder the transformation like that:
rule Member2Male {
from
s : Families!Member (not s.isFemale)
to
t : Persons!Male (... -- "main" ModelElement first
),
a : Persons!Address (...
)
}
rule Member2Female {
from
s : Families!Member (s.isFemale)
to
t : Persons!Female (... -- "main" ModelElement first
),
a : Persons!Address (...
)
}
Best Regards,
William
Tassilo Horn a
|
|
|
Re: [ATL] ...emfvm.VMException caused by ClassCastException, but why? [message #491886 is a reply to message #491873] |
Fri, 16 October 2009 11:57 |
Tassilo Horn Messages: 93 Registered: July 2009 |
Member |
|
|
William Piers <william.piers@obeo.fr> writes:
Hi William,
> The error happens when you try to put an Address into the "husband" or
> "wife" feature.
>
> To rely input model elements with newly created elements, ATL uses an implicit
> traceability mechanism:
> if IN!A is transformed to OUT!B1, OUT!B2 (as B1 and B2 are ordered inside of
> the rule, "to" section), when you refer to A it will in fact refer to OUT!B1.
> If you want to refer to B2 you need to use resolveTemp. You can read more about
> resolveTemp here:
> http://wiki.eclipse.org/ATL/User_Guide#The_ATL_Module_data_t ype
Good to know.
> In your case, as you never want to refer the Address of a person, you
> just have to reorder the transformation like that:
Yes, that does the trick.
In the meantime, I've also discovered rule inheritance, so that I don't
need to repeat myself in the Male and Females rule. Very nice.
Bye,
Tassilo
|
|
|
Goto Forum:
Current Time: Wed Jan 15 03:36:21 GMT 2025
Powered by FUDForum. Page generated in 0.04195 seconds
|