Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » executing mwe2 programmatically within Eclipse plugin(executing mwe2 programmatically within Eclipse plugin)
executing mwe2 programmatically within Eclipse plugin [message #1799476] Fri, 07 December 2018 13:15 Go to next message
Zakir Meer is currently offline Zakir MeerFriend
Messages: 50
Registered: February 2016
Member
Hello,

I want to invoke MWE2 workflow file from a eclipse plugin and expect that the runtime of the eclipse is being used during execution.

I have used below code with Mwe2Runner and Mwe2Launcher, but it does not seem to work and in both the cases I get exceptions.

Case 1: With Mwe2Runner

 
Injector injector = new Mwe2StandaloneSetup()
					.createInjectorAndDoEMFRegistration();
			
			Mwe2Runner runner = injector.getInstance(Mwe2Runner.class);
			
			URI uri = URI.createFileURI(getWorkFlowFilePath());

			runner.run(uri,
					new HashMap<>());


I get below exeption:
Quote:
java.lang.IllegalStateException: [XtextLinkingDiagnostic: null:31 Couldn't resolve reference to JvmType 'com.pc.TestReader

In this case, it is clearly visible that eclipse runtime is not considered.

Case 2: With Mwe2Launcher

Mwe2Launcher.main(new String[] {URI.createFileURI(getWorkFlowFilePath()).toFileString()});


Quote:
java.lang.IllegalStateException: Couldn't find module D:\01_Main\Test.mwe2


In this case I see that launcher is considering filePath as module name and failing :-(

Note: In both the case, I am fetching the path of workflow file with the below code and I see that it is completely valid

public static String getWorkFlowFilePath() {

		Bundle bundle = Platform.getBundle("com.project1");
		
		URL entry = bundle.getEntry("workflow/Test.mwe2");
		if (entry != null) {
			URL fileURL;
			try {
				fileURL = FileLocator.toFileURL(entry);
				if (fileURL != null) {
					 return fileURL.getFile();
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			
		}
		return null;
	}



It will be helpful if anyone of you can let me know how to solve this issue..

Thanks !!
Re: executing mwe2 programmatically within Eclipse plugin [message #1799477 is a reply to message #1799476] Fri, 07 December 2018 13:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
did you have a look what the normal launch config does: are you sure the classpath is correct? are you sure the path is correct?
something like

{code}
public class Main {

public static void main(String[] args) {
Mwe2Launcher.main(new String[] {
"/data/2018-12/ws2222222/org.xtext.example.mydsl/src/org/xtext/example/mydsl/GenerateMyDsl.mwe2",
"-p",
"rootPath=/data/2018-12/ws2222222/"}
);
}
}
{code}

works fine for me


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: executing mwe2 programmatically within Eclipse plugin [message #1799561 is a reply to message #1799477] Mon, 10 December 2018 10:28 Go to previous messageGo to next message
Zakir Meer is currently offline Zakir MeerFriend
Messages: 50
Registered: February 2016
Member
Hi Christian,

Thanks for your quick reply. I have used this code and still I have problems in execution of MWE2 from the eclipse plugin

I see that MWE2Launcher behaves differently when executed from a standalone java application (with main) and with eclipse application (launched as a eclipse application e.g: from a eclipse action or from a standalone RCP)

Major concern here is: in case of execution from eclipse application, dependencies are not resolved and MWE2Launcher throws an exception : illegalStateExection: [xtextlinkingdiagnostic]: couldn't resolve reference to JavaType '<defined in other plugin>'

To have a clear demonstration of this behaviour, I created two eclipse plugin and used the MWE2Launcher execution code from :

-simple java class containing main
- Eclipse headless RCP application

source code is available at : https://github.com/zam1kor/mwe2_execution/blob/c3676d4/src_code.zip?raw=true

Documentation : I have created step by step explanation of the plugins I have created + how I have used MWE2Launcher (in both the modes) : https://github.com/zam1kor/mwe2_execution/blob/c3676d4/Issue_description.docx?raw=true

info: both sources and docu are available in gitbu repo : https://github.com/zam1kor/mwe2_execution.git
Re: executing mwe2 programmatically within Eclipse plugin [message #1799567 is a reply to message #1799561] Mon, 10 December 2018 11:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
you dont provide any classpath ?!?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: executing mwe2 programmatically within Eclipse plugin [message #1799568 is a reply to message #1799567] Mon, 10 December 2018 12:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
=> you should debug?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: executing mwe2 programmatically within Eclipse plugin [message #1799569 is a reply to message #1799568] Mon, 10 December 2018 12:07 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
it might be that org.eclipse.xtext.common.types.access.binary.BinaryClass.forName(String, ClassLoader) does not support this usecase

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: executing mwe2 programmatically within Eclipse plugin [message #1799570 is a reply to message #1799569] Mon, 10 December 2018 12:10 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
https://bugs.eclipse.org/bugs/show_bug.cgi?id=318721

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Unordered Groups - any Alternatives?
Next Topic:cross-reference with modified name
Goto Forum:
  


Current Time: Thu Sep 26 00:45:00 GMT 2024

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

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

Back to the top