Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Epsilon Workflow Casting Issue
Epsilon Workflow Casting Issue [message #1823612] Mon, 30 March 2020 09:18 Go to next message
Charlie Parsons is currently offline Charlie ParsonsFriend
Messages: 6
Registered: February 2020
Location: Bath, UK
Junior Member
Hi,
I am trying to call an Ant build containing a EOL file programmatically.
My build.xml contains the following:
<project default="gen" name="Generate Data Configuration">
        <!-- Get Classpath -->
	<path id="project.class">
		<pathelement location="lib/epsilon-1.5.1-kitchensink.jar"/>
	</path>

	<!-- Define Tasks -->
	<taskdef name="epsilon.eol" classname="org.eclipse.epsilon.workflow.tasks.EolTask">
		<classpath refid="project.class"/>
	</taskdef>

	<taskdef name="epsilon.emf.loadModel" classname="org.eclipse.epsilon.workflow.tasks.emf.LoadEmfModelTask">
		<classpath refid="project.class"/>
	</taskdef>

<!-- Define Targets -->
	<target name="gen" description="Generate Data Configuration from abstract model">
		<!-- Trace Rule Data Configuration -->
		<epsilon.emf.loadModel name="abConfig"
			read="true"
			store="false"
			metamodeluri="org.eclipse.capra.GenericDataConfigurationMetaModel"
			modelfile="../Settings/abstract_data_config.ecore"
		/>
		<epsilon.emf.loadModel name="fullDataConfig"
			read="false"
			store="true"
			metamodeluri="org.eclipse.capra.GenericDataConfigurationMetaModel"
			modelfile="../06_Traceability/data_configuration.ecore"
		/>

		<!-- Generate Trace Data Configuration -->
		<epsilon.eol src="src/generate_data_config.eol">
			<model ref="abConfig"/>
			<model ref="fullDataConfig"/>
		</epsilon.eol>
	</target>
...
</project>

If i try to run a ant build that runs a EOL file with no EMF models then i get no issues and the build completes successfully. However, if i try to run a EOL file with EMF Models referenced then the following ClassCastException is thrown.

java.lang.ClassCastException: class org.eclipse.epsilon.eol.models.ModelRepository cannot be cast to class org.eclipse.epsilon.eol.models.ModelRepository (org.eclipse.epsilon.eol.models.ModelRepository is in unnamed module of loader org.apache.tools.ant.AntClassLoader @332f6402; org.eclipse.epsilon.eol.models.ModelRepository is in unnamed module of loader org.apache.tools.ant.AntClassLoader @43ec687e)
at org.eclipse.epsilon.workflow.tasks.ExecutableModuleTask.executeImpl(ExecutableModuleTask.java:233)
	at org.eclipse.epsilon.workflow.tasks.EpsilonTask.execute(EpsilonTask.java:39)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
	at jdk.internal.reflect.GeneratedMethodAccessor56.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
	at org.apache.tools.ant.Task.perform(Task.java:350)
	at org.apache.tools.ant.Target.execute(Target.java:449)
	at org.apache.tools.ant.Target.performTasks(Target.java:470)
	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1391)
	at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
	at org.eclipse.mbt.views.AntView.buildScript(AntView.java:763)
	at org.eclipse.mbt.views.AntView$8.widgetSelected(AntView.java:722)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:252)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4175)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3988)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3587)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1160)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1049)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:660)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:559)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:154)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:150)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:657)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:594)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1438)

I am running the following code to call the Ant build from Java:
File file = new File(buildFilePath);
Project project = new Project();
project.setBaseDir(new File(buildFilePath.substring(0, buildFilePath.lastIndexOf("/"))));
project.init();
				
DefaultLogger logger = new DefaultLogger();
logger.setErrorPrintStream(System.err);
logger.setOutputPrintStream(System.out);
logger.setMessageOutputLevel(Project.MSG_INFO);
				
project.setProperty("ant.file", file.getAbsolutePath());
project.addBuildListener(logger);
project.fireBuildStarted();
				
ProjectHelper helper = ProjectHelper.getProjectHelper();
project.addReference("ant.projectHelper", helper);
helper.parse(project, file);
if (targetToRun == null) {
	project.executeTarget(project.getDefaultTarget());
} else {
	project.executeTarget(targetToRun);
}


As you can see i am using the latest stable version of the Epsilon kitchensink. I have tried to use the latest interim version of the kitchen sink (Version 1.6.0) however, a NoClassDefFoundError is raised
java.lang.NoClassDefFoundError: org/antlr/runtime/TokenSource


Sorry for the long message.

Hope someone can help,

Thanks,
Charlie Parsons

[Updated on: Mon, 30 March 2020 09:18]

Report message to a moderator

Re: Epsilon Workflow Casting Issue [message #1823625 is a reply to message #1823612] Mon, 30 March 2020 13:00 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

Hi Charlie,

Could you share a minimal example [1] I can use to reproduce this?

Thanks,
Dimitris

[1] https://www.eclipse.org/epsilon/doc/articles/minimal-examples/
Re: Epsilon Workflow Casting Issue [message #1823627 is a reply to message #1823625] Mon, 30 March 2020 13:19 Go to previous messageGo to next message
Charlie Parsons is currently offline Charlie ParsonsFriend
Messages: 6
Registered: February 2020
Location: Bath, UK
Junior Member
Hi Dimitris,
I seem to be finding it difficult to create a minimal example. When creating the minimal example the issue i am having doesn't occur and everything runs as expected, but within my main program i am still having this issue occur.
I'm not really sure how i can reproduce this issue.

Thanks,
Charlie
Re: Epsilon Workflow Casting Issue [message #1823628 is a reply to message #1823612] Mon, 30 March 2020 13:20 Go to previous messageGo to next message
Sina MadaniFriend
Messages: 160
Registered: November 2015
Location: York, UK
Senior Member
Hi Charlie,

I think the reason you are having problems with the Interim version is you are missing ANTLR 3.2 (which can be found here. If you have Java 8 installed, it might also be worth trying with that to rule out compatibility issues.

EDIT: Bug raised for missing dependency in interim version.

Thanks,
Sina

[Updated on: Mon, 30 March 2020 13:27]

Report message to a moderator

Re: Epsilon Workflow Casting Issue [message #1823641 is a reply to message #1823628] Mon, 30 March 2020 15:07 Go to previous messageGo to next message
Charlie Parsons is currently offline Charlie ParsonsFriend
Messages: 6
Registered: February 2020
Location: Bath, UK
Junior Member
Hi Sina,
After adding ANTLR to my build path my program then comes out with the same error that i am having with the stable version of Epsilon. I have also tried to run my program using an older version of Java (8) as specified and still encounter the same issue as stable Epsilon.

Thanks,
Charlie
Re: Epsilon Workflow Casting Issue [message #1823723 is a reply to message #1823641] Tue, 31 March 2020 18:15 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

Hi Charlie,

> When creating the minimal example the issue i am having doesn't occur and everything runs as expected, but within my main program i am still having this issue occur.

If we can't reproduce the error locally, it's unlikely that we'll be able to offer much assistance. I'd suggest starting with a copy of your full program, and removing one feature at a time, until the unwanted behaviour stops occurring.

Thanks,
Dimitris
Re: Epsilon Workflow Casting Issue [message #1842089 is a reply to message #1823723] Tue, 08 June 2021 22:56 Go to previous message
Jörn Guy Süß is currently offline Jörn Guy SüßFriend
Messages: 320
Registered: July 2009
Location: Anstead, Brisbane, Queens...
Senior Member

I would guess that you are having the issue because the task loads onto a different classloader from your master program. Tasks are dynamically loaded in ant and objects cannot be shared outside the tasks classloader. Hence you cannot access objects created on the 'inside'.

There is a description of the ant classpath hell in this article I have written:
https://dzone.com/articles/what-is-ant-really


Previous Topic:Extracting metamodel from ETL
Next Topic:Maximum amount of sheets allowable by epsilon
Goto Forum:
  


Current Time: Sat Apr 27 10:22:57 GMT 2024

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

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

Back to the top