Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Xpand] Multiple meta models and ClassCastException
[Xpand] Multiple meta models and ClassCastException [message #551691] Mon, 09 August 2010 07:41 Go to next message
Eclipse UserFriend
Originally posted by: till.tillamma.de

Hello,

I'm trying to combine multiple meta models into one MWE+Xpand step. So
far I managed to get no compile errors. But when running the code I get
a ClassCastException where the "FactoryImpl" of meta model A is being
casted into the "Factory" interface of meta model B.

I call the workflow using the WorkflowRunner from within an RCP.

The Exception is invoked during the prepare-step of the WorkflowRunner.

Should I post some log output and/or code? If so, which parts of it? I
think it's a tiny thing I'm overseeing.

Thanks,

Till
Re: [Xpand] Multiple meta models and ClassCastException [message #551701 is a reply to message #551691] Mon, 09 August 2010 08:56 Go to previous messageGo to next message
Darius Jockel is currently offline Darius JockelFriend
Messages: 63
Registered: July 2009
Member
Hello,

Quote:
Should I post some log output and/or code? If so, which parts of it?


of cause we need more information.
What kind of mtamodels do you use?
Is there any reference between Factory and FactoryImpl in your metamodel?
Can you past please the paste the errormessage?

Regards
Darius
Re: [Xpand] Multiple meta models and ClassCastException [message #551722 is a reply to message #551701] Mon, 09 August 2010 10:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: till.tillamma.de

On 08/09/2010 10:56 AM, Darius Jockel wrote:
> Hello,
>
> Quote:
>> Should I post some log output and/or code? If so, which parts of it?
> of cause we need more information.
Thought so, but didn't want to make the post unnecessarily bulky.

> What kind of mtamodels do you use?
'.ecore's

> Is there any reference between Factory and FactoryImpl in your metamodel?
Nope, no reference between them.

> Can you past please the paste the errormessage?
Yes. (Log, template and component of the workflow pasted below)

Here is the log including the error message:

Aug 9, 2010 9:33:11 AM org.eclipse.emf.mwe.core.WorkflowRunner prepare
INFO:
------------------------------------------------------------ --------------------------
Aug 9, 2010 9:33:11 AM org.eclipse.emf.mwe.core.WorkflowRunner prepare
INFO: EMF Modeling Workflow Engine 1.0.0, Build v201006150535
Aug 9, 2010 9:33:11 AM org.eclipse.emf.mwe.core.WorkflowRunner prepare
INFO: (c) 2005-2009 openarchitectureware.org and contributors
Aug 9, 2010 9:33:11 AM org.eclipse.emf.mwe.core.WorkflowRunner prepare
INFO:
------------------------------------------------------------ --------------------------
Aug 9, 2010 9:33:11 AM org.eclipse.emf.mwe.core.WorkflowRunner prepare
INFO: running workflow: utilityGenerationWorkflow.oaw
Aug 9, 2010 9:33:11 AM org.eclipse.emf.mwe.core.WorkflowRunner prepare
INFO:
!SESSION 2010-08-09 09:32:51.551
-----------------------------------------------
eclipse.buildId=unknown
java.version=1.6.0_20
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US
Framework arguments: -product
de.uni_kassel.cn.planDesigner.ui.planDesignerProduct
Command-line arguments: -product
de.uni_kassel.cn.planDesigner.ui.planDesignerProduct -data
/home/till/Code/workspace/../runtime-cnplandesigner.product -dev
file:/home/till/Code/workspace/.metadata/.plugins/org.eclips e.pde.core/cnplandesigner.product/dev.properties
-os linux -ws gtk -arch x86 -consoleLog -clean

!ENTRY org.eclipse.emf.ecore 2 0 2010-08-09 09:33:11.670
!MESSAGE de.uni_kassel.cn.alica.impl.AlicaFactoryImpl cannot be cast to
de.uni_kassel.cn.planDesigner.translator.translator.Translat orFactory
!STACK 0
java.lang.ClassCastException:
de.uni_kassel.cn.alica.impl.AlicaFactoryImpl cannot be cast to
de.uni_kassel.cn.planDesigner.translator.translator.Translat orFactory
at
de.uni_kassel.cn.planDesigner.translator.translator.impl.Tra nslatorFactoryImpl.init(TranslatorFactoryImpl.java:42)
at
de.uni_kassel.cn.planDesigner.translator.translator.Translat orFactory. <clinit>(TranslatorFactory.java:27)
at
de.uni_kassel.cn.planDesigner.translator.translator.impl.Tra nslatorPackageImpl. <init>(TranslatorPackageImpl.java:71)
at
de.uni_kassel.cn.planDesigner.translator.translator.impl.Tra nslatorPackageImpl.init(TranslatorPackageImpl.java:98)
at
de.uni_kassel.cn.planDesigner.translator.translator.Translat orPackage. <clinit>(TranslatorPackage.java:62)
at sun.misc.Unsafe.ensureClassInitialized(Native Method)
at
sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(Unsa feFieldAccessorFactory.java:25)
at
sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFac tory.java:122)
at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
at java.lang.reflect.Field.get(Field.java:358)
at
org.eclipse.xtend.typesystem.emf.EcoreUtil2.getEPackageByCla ssName(EcoreUtil2.java:177)
at
org.eclipse.xtend.typesystem.emf.EmfMetaModel.setMetaModelPa ckage(EmfMetaModel.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.eclipse.emf.mwe.internal.core.ast.util.InjectorSimple.se tValue(InjectorSimple.java:33)
at
org.eclipse.emf.mwe.internal.core.ast.util.VisitorCreator.vi sitSimpleParamAST(VisitorCreator.java:203)
at
org.eclipse.emf.mwe.internal.core.ast.util.VisitorBase.visit (VisitorBase.java:49)
at
org.eclipse.emf.mwe.internal.core.ast.AbstractASTBase.accept (AbstractASTBase.java:44)
at
org.eclipse.emf.mwe.internal.core.ast.util.VisitorCreator.cr eateBean(VisitorCreator.java:157)
at
org.eclipse.emf.mwe.internal.core.ast.util.VisitorCreator.vi sitComponentAST(VisitorCreator.java:118)
at
org.eclipse.emf.mwe.internal.core.ast.util.VisitorBase.visit (VisitorBase.java:37)
at
org.eclipse.emf.mwe.internal.core.ast.AbstractASTBase.accept (AbstractASTBase.java:44)
at
org.eclipse.emf.mwe.internal.core.ast.util.VisitorCreator.cr eateBean(VisitorCreator.java:157)
at
org.eclipse.emf.mwe.internal.core.ast.util.VisitorCreator.vi sitComponentAST(VisitorCreator.java:118)
at
org.eclipse.emf.mwe.internal.core.ast.util.VisitorBase.visit (VisitorBase.java:37)
at
org.eclipse.emf.mwe.internal.core.ast.AbstractASTBase.accept (AbstractASTBase.java:44)
at
org.eclipse.emf.mwe.internal.core.ast.util.VisitorCreator.cr eateBean(VisitorCreator.java:157)
at
org.eclipse.emf.mwe.internal.core.ast.util.VisitorCreator.vi sitComponentAST(VisitorCreator.java:118)
at
org.eclipse.emf.mwe.internal.core.ast.util.VisitorBase.visit (VisitorBase.java:37)
at
org.eclipse.emf.mwe.internal.core.ast.AbstractASTBase.accept (AbstractASTBase.java:44)
at
org.eclipse.emf.mwe.internal.core.ast.util.WorkflowFactory.p arseInitAndCreate(WorkflowFactory.java:74)
at
org.eclipse.emf.mwe.internal.core.ast.util.WorkflowFactory.p arseInitAndCreate(WorkflowFactory.java:52)
at org.eclipse.emf.mwe.core.WorkflowRunner.prepare(WorkflowRunn er.java:332)
at org.eclipse.emf.mwe.core.WorkflowRunner.run(WorkflowRunner.j ava:290)
at
de.uni_kassel.cn.planDesigner.codegeneration.commands.Genera teCSharpUtilitiesCommand$GenerateCodeJob.runInWorkspace(Gene rateCSharpUtilitiesCommand.java:130)
at
org.eclipse.core.internal.resources.InternalWorkspaceJob.run (InternalWorkspaceJob.java:38)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Aug 9, 2010 9:33:11 AM
org.eclipse.emf.mwe.core.container.CompositeComponent internalInvoke
INFO: Generator(generator): generating
'de::uni_kassel::cn::planDesigner::codegeneration::templates ::UtilitySummand::Root
FOR plan' => /home/till/Code/runtime-cnplandesigner.product/test/generate d/
Aug 9, 2010 9:33:12 AM org.eclipse.emf.mwe.core.WorkflowRunner
executeWorkflow
INFO: workflow completed in 298ms!





And the template:


«IMPORT alica»

«EXTENSION
de::uni_kassel::cn::planDesigner::codegeneration::extensions ::Java»

«DEFINE Root FOR alica::UtilityRepository»
«ENDDEFINE»


And the component from the workflow ("metaModelPackage" properties are
filled in a java class and given as an argument to the WorkflowRunner
constructor):

<component id="generator" class="org.eclipse.xpand2.Generator"
skipOnErrors="true">
<fileEncoding value="ISO-8859-1"/>

<!-- ALICA meta model -->
<metaModel id="mm" class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
<metaModelPackage value="${metaModelPackage}"/>
<!--
<metaModelFile value="${metaModelFile}" />
-->
</metaModel>

<!-- Translator meta model -->
<metaModel id="mm2" class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
<metaModelPackage value="${metaModelPackage2}"/>
<!--
<metaModelFile value="${metaModelFile2}" />
-->
</metaModel>

<outlet path="${srcGenPath}">
<!--<postprocessor
class="org.openarchitectureware.xpand2.output.JavaBeautifier "/>-->
</outlet>

<!--protected regions configuration -->
<prSrcPaths value="${srcGenPath}"/>
<prDefaultExcludes value="false"/>

<expand
value=" de::uni_kassel::cn::planDesigner::codegeneration::templates: :UtilitySummand::Root
FOR plan">

</expand>
</component>
Re: [Xpand] Multiple meta models and ClassCastException [message #551931 is a reply to message #551722] Tue, 10 August 2010 08:40 Go to previous messageGo to next message
Darius Jockel is currently offline Darius JockelFriend
Messages: 63
Registered: July 2009
Member
Hello,

this classes:
de.uni_kassel.cn.planDesigner.translator.translator.impl.Tra nslatorFactoryImpl.init(TranslatorFactoryImpl.java:42)
are part of your meta model and not manually implemented logic, right?

Maybe your metamodel is not correctly configured.
Please take a look at your workflow configuration:
<!-- Translator meta model -->
<metaModel id="mm2" class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
<metaModelPackage value="${metaModelPackage2}"/>
<!--
<metaModelFile value="${metaModelFile2}" />
-->
</metaModel>

You have to refer the ecore file with metaModelFile OR
you have to refer the generated Javabeans (generated from the ecore).
Please remove one of the configurations.

Regards
Darius
Re: [Xpand] Multiple meta models and ClassCastException [message #552049 is a reply to message #551931] Tue, 10 August 2010 16:00 Go to previous message
Eclipse UserFriend
Originally posted by: till.tillamma.de

Hi,

first of all: I got it working (at least there are no Exceptions
anymore) - thanks for the help.

Now to answer your questions and ask some:

> this classes:
> de.uni_kassel.cn.planDesigner.translator.translator.impl.Tra
> nslatorFactoryImpl.init(TranslatorFactoryImpl.java:42)
> are part of your meta model and not manually implemented logic, right?

Yes, both factories were generated from the ecores.

>
> Maybe your metamodel is not correctly configured.
> Please take a look at your workflow configuration:
> <!-- Translator meta model -->
> <metaModel id="mm2" class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
> <metaModelPackage value="${metaModelPackage2}"/>
> <!--
> <metaModelFile value="${metaModelFile2}" />
> -->
> </metaModel>
>
> You have to refer the ecore file with metaModelFile OR
> you have to refer the generated Javabeans (generated from the ecore).

I referred to the meta model file (which was commented out before)
instead of the package... and voila no complaints any more.

> Please remove one of the configurations.

Not sure what you wanted. But it worked well with only one metaModel
definition.

-----

Now a question came to my mind:

Why does it work when both metaModels are configured via "metaModelFile"
but not via "metaModelPackage"?

-----

Thanks,

Till
Previous Topic:[XPAND] Problems with getting started
Next Topic:[Xpand] Access to root element from within DEFINE block [SOLVED]
Goto Forum:
  


Current Time: Sat Dec 20 11:39:46 GMT 2014

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

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