Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTo] Failed to resolve metamodel - in running Java application
[QVTo] Failed to resolve metamodel - in running Java application [message #645052] Wed, 15 December 2010 11:47 Go to next message
Kirsten M. Z. is currently offline Kirsten M. Z.
Messages: 131
Registered: July 2010
Senior Member
Hi @all,

currently I am using the following code to execute a QVTo transformation from Java code. However, I get the following error:

Compilation errors found in unit [......./mytrans.qvto]
Failed to resolve metamodel 'http://www.example.org/concrete'


Thereby, the mentioned metamodel is the second metamodel used by my QVTo transformation.

I can imagine that I have to "register" this metamodel in my code/application somewhere, but I have not found an example how to do that in my Java code/application.

The QVTo transformation works in my Eclipse environment, also without compilation error, of course. The metamodel project has been added as "plugin" to my Eclipse environment (I guess that's the reason why compilation and running of the QVTo transformation works there). I have also added the metamodel project to the transformation project. Otherwise, no special settings.

URI transformationURI = URI.createURI(Transformation.class
                .getResource("/mytrans.qvto").toURI().toString());
TransformationExecutor executor = new TransformationExecutor(transformationURI);

// load resource 1 (XMI)
Resource res1 = new XMIResourceFactoryImpl().createResource(null);
res1.load(isAML, null);

// load resource 2 (concrete format)
Resource res2 = new de.example.org.concrete.util.ConcreteResourceFactoryImpl()
                .createResource(null);
res2.load(isDDS, null);

// create the input extents with its initial contents
ModelExtent in1 = new BasicModelExtent(res1.getContents());
ModelExtent in2 = new BasicModelExtent(res2.getContents());

// setup the execution environment details
ExecutionContextImpl context = new ExecutionContextImpl();
context.setConfigProperty("keepModeling", true);

// run the transformation
ExecutionDiagnostic diagnostics = executor.execute(context, in1, in2);


Thanks in advance!
Re: [QVTo] Failed to resolve metamodel - in running Java application [message #645233 is a reply to message #645052] Thu, 16 December 2010 07:06 Go to previous messageGo to next message
Dennis Hendriks is currently offline Dennis Hendriks
Messages: 63
Registered: January 2010
Location: Eindhoven, The Netherland...
Member
Hi vultur,

> I can imagine that I have to "register" this metamodel in my
> code/application somewhere, but I have not found an example how to do
> that in my Java code/application.

Then I guess you didn't look hard enough :)

Anyway, here it is:
http://www.eclipse.org/forums/index.php?t=msg&goto=63020 0

Best regards,
Dennis



vultur wrote:
> Hi @all,
>
> currently I am using the following code to execute a QVTo transformation
> from Java code. However, I get the following error:
>
> Compilation errors found in unit [......./mytrans.qvto]
> Failed to resolve metamodel 'http://www.example.org/concrete'
>
>
> Thereby, the mentioned metamodel is the second metamodel used by my QVTo
> transformation.
>
> I can imagine that I have to "register" this metamodel in my
> code/application somewhere, but I have not found an example how to do
> that in my Java code/application.
>
> The QVTo transformation works in my Eclipse environment, also without
> compilation error, of course. The metamodel project has been added as
> "plugin" to my Eclipse environment (I guess that's the reason why
> compilation and running of the QVTo transformation works there). I have
> also added the metamodel project to the transformation project.
> Otherwise, no special settings.
>
>
> URI transformationURI = URI.createURI(Transformation.class
> .getResource("/mytrans.qvto").toURI().toString());
> TransformationExecutor executor = new
> TransformationExecutor(transformationURI);
>
> // load resource 1 (XMI)
> Resource res1 = new XMIResourceFactoryImpl().createResource(null);
> res1.load(isAML, null);
>
> // load resource 2 (concrete format)
> Resource res2 = new
> de.example.org.concrete.util.ConcreteResourceFactoryImpl()
> .createResource(null);
> res2.load(isDDS, null);
>
> // create the input extents with its initial contents
> ModelExtent in1 = new BasicModelExtent(res1.getContents());
> ModelExtent in2 = new BasicModelExtent(res2.getContents());
>
> // setup the execution environment details
> ExecutionContextImpl context = new ExecutionContextImpl();
> context.setConfigProperty("keepModeling", true);
>
> // run the transformation
> ExecutionDiagnostic diagnostics = executor.execute(context, in1, in2);
>
>
> Thanks in advance!
Re: [QVTo] Failed to resolve metamodel - in running Java application [message #645337 is a reply to message #645052] Thu, 16 December 2010 16:45 Go to previous message
Kirsten M. Z. is currently offline Kirsten M. Z.
Messages: 131
Registered: July 2010
Senior Member
Thanks for your help! It works now.

I knew the the thread, but it did not help when I skimmed through. Unfortunately, it was much more complex than the simple answer:

EPackage.Registry.INSTANCE.put("http://www.example.org/concrete", ns.ConcretePackage.eINSTANCE);


The thread baffled me, because it also covers unnecessary topics and code.

Thanks again!
Previous Topic:Debugging Expressions
Next Topic:[ATL] Adding entries to a Map attribute from imperative code
Goto Forum:
  


Current Time: Thu Oct 02 10:40:15 GMT 2014

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

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