Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Java/ANT/Epsilon Problem: failed to create task or type epsilon.loadModel
Java/ANT/Epsilon Problem: failed to create task or type epsilon.loadModel [message #713351] Mon, 08 August 2011 11:33 Go to next message
adrian  is currently offline adrian
Messages: 1
Registered: August 2011
Junior Member
Hi,

I have a problem. I'm trying to do a transformation with ANT epsilon by running a Java class. The problem is that I get the error:

Problem: failed to create task or type epsilon.loadModel

ANT code:
<project default="main">

<target name="loadModels">


<epsilon.loadModel name="EER" type="EMF">
<parameter name="modelFile" file="./default.xmi"/>
<parameter name="metamodelFile" value="../../es.unican.moses.sle.db.eer2sql/model/EERmodel.ecore"/>
<parameter name="isMetamodelFileBased" value="true"/>
<parameter name="readOnLoad" value="true"/>
<parameter name="storeOnDisposal" value="false"/>
</epsilon.loadModel>

<epsilon.loadModel name="Relational" type="EMF">
<parameter name="modelFile" file="pruebaSalida.model"/>
<parameter name="metamodelFile" value="../../es.unican.moses.sle.db.relacional/model/Relational.ecore"/>
<parameter name="isMetamodelFileBased" value="true"/>
<parameter name="readOnLoad" value="false"/>
<parameter name="storeOnDisposal" value="true"/>
</epsilon.loadModel>
</target>

<target name="main" depends="loadModels">
<epsilon.etl src="${basedir}/eer2relational.etl">
<model ref="EER"/>
<model ref="Relational"/>
</epsilon.etl>
</target>
</project>
-------------------------------------------------- -------

The Java class is as follows:

import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.BuildListener;
import org.apache.tools.ant.DefaultLogger;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.ProjectHelper;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import org.osgi.framework.Bundle;



public class doCodeGeneration implements IObjectActionDelegate {

private Shell shell;

/**
* Constructor for Action1.
*/
public doCodeGeneration() {
super();
}

/**
* @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
*/
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
shell = targetPart.getSite().getShell();
}

/**
* @see IActionDelegate#run(IAction)
*/
public void run(IAction action) {
MessageDialog.openInformation(
shell,
"Moses Research Group",
"EER Code Generation was executed.");

action();

}

/**
* @see IActionDelegate#selectionChanged(IAction, ISelection)
*/
public void selectionChanged(IAction action, ISelection selection) {
}


/**
* Implements the actions to be carried out when the Generate Code action is invoked
*/
public void action(){

// We look for the ANT file to be executed.
File buildFile = findEer2RelationalLauncher();

Project p = new Project();
p.setUserProperty("ant.file",buildFile.getAbsolutePath());
DefaultLogger consoleLogger = new DefaultLogger();
consoleLogger.setErrorPrintStream(System.err);
consoleLogger.setOutputPrintStream(System.out);
consoleLogger.setMessageOutputLevel(Project.MSG_INFO);
p.addBuildListener(consoleLogger);

try {
p.fireBuildStarted();
p.init();
ProjectHelper helper = ProjectHelper.getProjectHelper();
p.addReference("ant.projectHelper", helper);
helper.parse(p, buildFile);
p.executeTarget(p.getDefaultTarget());
p.fireBuildFinished(null);
} catch (BuildException e) {
p.fireBuildFinished(e);
}


}

/**
* Looks for the ANT file to be invoked for transforming a EER model into a relational
* one
* @return The file containing such an ANT file
*/
private File findEer2RelationalLauncher() {

// We search for the XML file containing the ANT task to be launched
Bundle bundle = Platform.getBundle("es.unican.moses.transformations.db.eer2relational");
Path path = new Path("Transformations/launchEer2Relational.xml");
URL launcherURL = FileLocator.find(bundle, path, null);

// We convert the URL to a URL using the file protocol
URL launcherFileURL = null;
try {
launcherFileURL = FileLocator.toFileURL(launcherURL);
} catch (IOException e2) {
// TODO Auto-generated catch block
// Completa esta excepcion
e2.printStackTrace();
} //

System.out.println("Path = " + launcherFileURL.toString());

File buildFile = null;
try {
buildFile = new File(launcherFileURL.toURI());
} catch (URISyntaxException e1) {
// Cambia esto por una ventana que informe del error
System.out.println("The file for launching the transformation can not be found." +
"This is probably due to an installation error");
e1.printStackTrace();
}
return buildFile;
}
}


Any ideas? I think I should change the configuration of Eclipse from Java code but I do not know how to put the option "Run in the Same JRE as the workspace".

Thank you

Re: Java/ANT/Epsilon Problem: failed to create task or type epsilon.loadModel [message #714323 is a reply to message #713351] Wed, 10 August 2011 10:22 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-Dominguez
Messages: 309
Registered: January 2010
Senior Member
Hi Adrian,

If you want to use the same Ant tasks that are available to the Eclipse Ant launch configurations, you shouldn't use Project directly. Instead, you should use the AntRunner class in the org.eclipse.ant.core plug-in.

Cheers,
Antonio
Re: Java/ANT/Epsilon Problem: failed to create task or type epsilon.loadModel [message #726259 is a reply to message #713351] Fri, 16 September 2011 23:47 Go to previous messageGo to next message
Pablo   is currently offline Pablo
Messages: 2
Registered: September 2011
Junior Member
Hi,

Executing the ETL transformation using ANTRunner, I got the following error.

org.eclipse.core.runtime.CoreException: H:\WorkspaceJava\Adrian\es.unican.moses.transformations.db.eer2relational\Transformations\launchEer2Relational.xml:51: Internal error: java.lang.NullPointerException
at java.lang.String.concat[Unknown Source]
at sun.reflect.NativeMethodAccessorImpl.invoke0[Native Method]
at sun.reflect.NativeMethodAccessorImpl.invoke[Unknown Source]
at sun.reflect.DelegatingMethodAccessorImpl.invoke[Unknown Source]
at java.lang.reflect.Method.invoke[Unknown Source]
at org.eclipse.epsilon.eol.util.ReflectionUtil.executeMethod[ReflectionUtil.java:183]
at org.eclipse.epsilon.eol.util.ReflectionUtil.executeMethod[ReflectionUtil.java:164]
at org.eclipse.epsilon.eol.execute.PointExecutor.executeOperation[PointExecutor.java:161]
at org.eclipse.epsilon.eol.execute.PointExecutor.execute[PointExecutor.java:74]
at org.eclipse.epsilon.eol.execute.PointExecutor.execute[PointExecutor.java:42]
at org.eclipse.epsilon.eol.execute.PointExecutor.execute[PointExecutor.java:130]
at org.eclipse.epsilon.eol.execute.ExecutorFactory.executeAST[ExecutorFactory.java:179]
at org.eclipse.epsilon.eol.execute.PointExecutor.execute[PointExecutor.java:41]
at org.eclipse.epsilon.eol.execute.PointExecutor.execute[PointExecutor.java:130]
at org.eclipse.epsilon.eol.execute.ExecutorFactory.executeAST[ExecutorFactory.java:179]
at org.eclipse.epsilon.eol.execute.StatementBlockExecutor.execute[StatementBlockExecutor.java:33]
at org.eclipse.epsilon.eol.execute.ExecutorFactory.executeAST[ExecutorFactory.java:179]
at org.eclipse.epsilon.etl.TransformRule.executeSuperRulesAndBody[TransformRule.java:254]
at org.eclipse.epsilon.etl.TransformRule.transform[TransformRule.java:225]
at org.eclipse.epsilon.etl.TransformRule.transformAll[TransformRule.java:190]
at org.eclipse.epsilon.etl.strategy.DefaultTransformationStrategy.transformModels[DefaultTransformationStrategy.java:138]
at org.eclipse.epsilon.etl.EtlModule.execute[EtlModule.java:186]
at org.eclipse.epsilon.workflow.tasks.ExecutableModuleTask.executeImpl[ExecutableModuleTask.java:115]
at org.eclipse.epsilon.workflow.tasks.EpsilonTask.execute[EpsilonTask.java:41]
at org.apache.tools.ant.UnknownElement.execute[UnknownElement.java:288]
at sun.reflect.NativeMethodAccessorImpl.invoke0[Native Method]
at sun.reflect.NativeMethodAccessorImpl.invoke[Unknown Source]
at sun.reflect.DelegatingMethodAccessorImpl.invoke[Unknown Source]
at java.lang.reflect.Method.invoke[Unknown Source]
at org.apache.tools.ant.dispatch.DispatchUtils.execute[DispatchUtils.java:106]
at org.apache.tools.ant.Task.perform[Task.java:348]
at org.apache.tools.ant.Target.execute[Target.java:357]
at org.apache.tools.ant.Target.performTasks[Target.java:385]
at org.apache.tools.ant.Project.executeSortedTargets[Project.java:1337]
at org.apache.tools.ant.Project.executeTarget[Project.java:1306]
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets[DefaultExecutor.java:41]
at org.eclipse.ant.internal.core.ant.EclipseDefaultExecutor.executeTargets[EclipseDefaultExecutor.java:32]
at org.apache.tools.ant.Project.executeTargets[Project.java:1189]
at org.eclipse.ant.internal.core.ant.InternalAntRunner.run[InternalAntRunner.java:662]
at org.eclipse.ant.internal.core.ant.InternalAntRunner.run[InternalAntRunner.java:495]
at sun.reflect.NativeMethodAccessorImpl.invoke0[Native Method]
at sun.reflect.NativeMethodAccessorImpl.invoke[Unknown Source]
at sun.reflect.DelegatingMethodAccessorImpl.invoke[Unknown Source]
at java.lang.reflect.Method.invoke[Unknown Source]
at org.eclipse.ant.core.AntRunner.run[AntRunner.java:378]
at es.unican.moses.sle.db.eer2sql.diagram.custom.popup.actions.doCodeGeneration.action[doCodeGeneration.java:150]
at es.unican.moses.sle.db.eer2sql.diagram.custom.popup.actions.doCodeGeneration.run[doCodeGeneration.java:108]
at org.eclipse.ui.internal.PluginAction.runWithEvent[PluginAction.java:251]
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection[ActionContributionItem.java:584]
at org.eclipse.jface.action.ActionContributionItem.access$2[ActionContributionItem.java:501]
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent[ActionContributionItem.java:411]
at org.eclipse.swt.widgets.EventTable.sendEvent[EventTable.java:84]
at org.eclipse.swt.widgets.Widget.sendEvent[Widget.java:1053]
at org.eclipse.swt.widgets.Display.runDeferredEvents[Display.java:4066]
at org.eclipse.swt.widgets.Display.readAndDispatch[Display.java:3657]
at org.eclipse.ui.internal.Workbench.runEventLoop[Workbench.java:2640]
at org.eclipse.ui.internal.Workbench.runUI[Workbench.java:2604]
at org.eclipse.ui.internal.Workbench.access$4[Workbench.java:2438]
at org.eclipse.ui.internal.Workbench$7.run[Workbench.java:671]
at org.eclipse.core.databinding.observable.Realm.runWithDefault[Realm.java:332]
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench[Workbench.java:664]
at org.eclipse.ui.PlatformUI.createAndRunWorkbench[PlatformUI.java:149]
at org.eclipse.ui.internal.ide.application.IDEApplication.start[IDEApplication.java:115]
at org.eclipse.equinox.internal.app.EclipseAppHandle.run[EclipseAppHandle.java:196]
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication[EclipseAppLauncher.java:110]
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start[EclipseAppLauncher.java:79]
at org.eclipse.core.runtime.adaptor.EclipseStarter.run[EclipseStarter.java:369]
at org.eclipse.core.runtime.adaptor.EclipseStarter.run[EclipseStarter.java:179]
at sun.reflect.NativeMethodAccessorImpl.invoke0[Native Method]
at sun.reflect.NativeMethodAccessorImpl.invoke[Unknown Source]
at sun.reflect.DelegatingMethodAccessorImpl.invoke[Unknown Source]
at java.lang.reflect.Method.invoke[Unknown Source]
at org.eclipse.equinox.launcher.Main.invokeFramework[Main.java:620]
at org.eclipse.equinox.launcher.Main.basicRun[Main.java:575]
at org.eclipse.equinox.launcher.Main.run[Main.java:1408]
at org.eclipse.equinox.launcher.Main.main[Main.java:1384]

There seems to be a problem with the "concat" function provided by ETL. I have tried some alternative methods, such as invoking the ETL transformation programatically, but the same problem appears.

Any idea about how to solve this?

Thanks very much in advance, Pablo.

Re: Java/ANT/Epsilon Problem: failed to create task or type epsilon.loadModel [message #726381 is a reply to message #726259] Sat, 17 September 2011 18:42 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris Kolovos
Messages: 886
Registered: July 2009
Senior Member
Hi Pablo,

Could you please put together a minimal example we can use to reproduce this behaviour using the following guidelines?

http://eclipse.org/gmt/epsilon/doc/articles/minimal-examples/

Cheers,
Dimitris
Re: Java/ANT/Epsilon Problem: failed to create task or type epsilon.loadModel [message #726893 is a reply to message #726381] Mon, 19 September 2011 20:06 Go to previous message
Pablo   is currently offline Pablo
Messages: 2
Registered: September 2011
Junior Member
Hi Dimitrios,

Here my mininmal example.

Epsilon version: Epsilon Core (Incubation) 0.9.0.201011251259
To reproduce the problem: run the plugins I am sending attached to this post as an Eclipse application. Then, create an empty project and an create an EER diagram. This can be done by doing double click on the name of the project New->Other->
Examples->EERmodel diagram.

Then, add a couple of entities to the diagram (just in case you want to do it). Then, select the .eer file, press the right button of the mouse and select "EER Code generation". You will get a dialog box saying all have been done correctly, but if you look at the console of the first Eclipse, you will find the error.

If the code is too complex, let me know and I try to simplify it.

Thanks in advance, Pablo.

[Updated on: Mon, 19 September 2011 20:07]

Report message to a moderator

Previous Topic:[Epsilon] Standalone: Deprecated EmfModel constants
Next Topic:[eugenia][newbie] Where is the rcp application ?
Goto Forum:
  


Current Time: Thu Oct 30 14:41:41 GMT 2014

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

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