Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Running MWE2 Generator from external code(I'm trying to run the MWE2 Luncher from external code)
Running MWE2 Generator from external code [message #640041] Thu, 18 November 2010 19:06 Go to next message
Jake is currently offline JakeFriend
Messages: 21
Registered: November 2010
Junior Member
I'm trying to run the MWE2 Luncher in an external project code (using Xtext to build the parser for a general purpose language ), without Eclipse (corresponding to the right click->run as MWE workflow). I found this for the old one, but trying this code I've a nullPointerException and not the expected IllegalArgumentException (source)

...

import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine;
import org.eclipse.emf.mwe2.launch.runtime.*;


public class RunWF {

public static void main (String[] args ) {


Map<String, String> params = null;

new Mwe2Runner().run(URI.createURI("wf.mwe"), params);

}

}

Thank you in advance,

Jake
Re: Running MWE2 Generator from external code [message #640046 is a reply to message #640041] Thu, 18 November 2010 19:49 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6499
Registered: July 2009
Senior Member
Hello Jake,

for running mwe workflows you have to use WorkflowRunner. Mwe2Runner is for mwe2 workflows. so have you a mwe or a mwe2 workflow?

~Christian

[Updated on: Thu, 18 November 2010 20:01]

Report message to a moderator

Re: Running MWE2 Generator from external code [message #640053 is a reply to message #640046] Thu, 18 November 2010 20:17 Go to previous messageGo to next message
Jake is currently offline JakeFriend
Messages: 21
Registered: November 2010
Junior Member
I have a MWE2 workflow.
Re: Running MWE2 Generator from external code [message #640057 is a reply to message #640053] Thu, 18 November 2010 20:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6499
Registered: July 2009
Senior Member
Hi,

you have to use Guice to create the Runner

Injector injector = new Mwe2StandaloneSetup().createInjectorAndDoEMFRegistration();
		Mwe2Runner mweRunner = injector.getInstance(Mwe2Runner.class);
		mweRunner.run(URI.createURI("src/com/example/workflow/Workflow.mwe2"), new HashMap<String,String>());


or you use the launcher

new Mwe2Launcher().run(new String[]{"src/com/example/workflow/Workflow.mwe2"});


~Christian
Re: Running MWE2 Generator from external code [message #640124 is a reply to message #640057] Fri, 19 November 2010 08:53 Go to previous messageGo to next message
Jake is currently offline JakeFriend
Messages: 21
Registered: November 2010
Junior Member
Thank you very much!
Re: Running MWE2 Generator from external code [message #999232 is a reply to message #640124] Fri, 11 January 2013 15:56 Go to previous messageGo to next message
Michael Veit is currently offline Michael VeitFriend
Messages: 12
Registered: January 2012
Junior Member
I have a similar problem, running MWE2 standalone.
The unit test within Eclipse works fine, but when running in the WebLogic context, the MWE2 module is not found.

I call the workflow like:
Injector injector = new MyFactoryStandaloneSetup().createInjectorAndDoEMFRegistration();
slots.put("injector", injector);
Mwe2Runner mweRunner = injector.getInstance(Mwe2Runner.class);
mweRunner.run(URI.createURI("com/mycompany/path/filename.mwe2"), prepareWorkflowProperties(), slots);


I get
java.io.FileNotFoundException: C:\Apps\appsrv\domains\MyDomain_6002\com\mycompany\path\filename.mwe2 (The system cannot find the path specified)

Under MyDomain_6002, there is a completely different hierarchy.

According to your proposal, I also tried this syntax:
mweRunner.run("com.mycompany.path.modulename", prepareWorkflowProperties(), slots);

using the module name which is specified in the MWE2 file (and matching the package/file naming), but I got the error
java.lang.IllegalStateException: Couldn't find module com.mycompany.path.modulename


I verified that the MWE2 file is within the jar.
Using Mwe2Launcher() isn't an option for me, because I need to support these additional parameters for workflow properties and slots.

How do I need to address the MWE2 workflow?

One more detail:

Due to very strong restrictions and a heavy Java framework in our company, some folder names are hard-coded in the framework. So I cannot use xtend-gen or src-gen folders. I had to set the Xtend build target to the src folder itself. In another post, I found that the MWE2 module would be searched in the src-gen folder only: http://jevopisdeveloperblog.blogspot.ch/2011/06/when-your-mwe2-workflow-is-not-working.html

[Updated on: Fri, 11 January 2013 16:13]

Report message to a moderator

Re: Running MWE2 Generator from external code [message #1001699 is a reply to message #999232] Thu, 17 January 2013 08:33 Go to previous message
Michael Veit is currently offline Michael VeitFriend
Messages: 12
Registered: January 2012
Junior Member
Finally I got the solution by myself. The problem was to find any documentation about the syntax expected for the URI. I found the syntax in the forums only...
mweRunner.run(URI.createURI("classpath:/com/mycompany/path/filename.mwe2"), prepareWorkflowProperties(), slots);
Previous Topic:juno upgrade - uml2.types
Next Topic:Dynamically create resources on file load
Goto Forum:
  


Current Time: Fri Nov 28 06:04:08 GMT 2014

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

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