Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Error at execution: java.lang.NoClassDefFoundError
Error at execution: java.lang.NoClassDefFoundError [message #948800] Thu, 18 October 2012 11:42 Go to next message
Yugi Muto is currently offline Yugi MutoFriend
Messages: 33
Registered: February 2012
Member
Hello,

I am writing a simple program in Java using the ATL API.
I want to use this API to compile my .atl file to a .asm file.
This is the code:
import org.eclipse.m2m.atl.engine.compiler.AtlCompiler;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.File;
import java.io.IOException;
public class MyClass
{
	public static void main(String[] args)
	{
		File inputFile = new File("myfile.atl");
		File outputFile = new File("myfile.asm");
		FileInputStream fileInputStream = null;
		try
		{
			fileInputStream = new FileInputStream(inputFile);
		}
		catch(FileNotFoundException e)
		{
			e.printStackTrace();
		}
		FileOutputStream fileOutputStream = null;
		try
		{
			fileOutputStream = new FileOutputStream(outputFile);
		}
		catch(FileNotFoundException e)
		{
			e.printStackTrace();
		}
		try
		{
			AtlCompiler.compile(fileInputStream, fileOutputStream);
		}
		catch(IOException e)
		{
			e.printStackTrace();
		}
	}
}


In command line:
In order to compile it, I need these JAR files in the classpath:

    org.eclipse.m2m.atl.engine_3.3.0.v201205241358.jar
    org.eclipse.core.resources_3.8.0.v20120522-2034.jar
    org.eclipse.emf.ecore_2.8.0.v20120606-0717.jar

In order to execute, I need these JAR files in the classpath:

    org.eclipse.emf.ecore_2.8.0.v20120606-0717.jar
    org.eclipse.emf.common_2.8.0.v20120606-0717.jar
    org.eclipse.emf.ecore.xmi_2.8.0.v20120606-0717.jar
    org.eclipse.equinox.common_3.6.100.v20120522-1841.jar
    org.eclipse.m2m.atl.common_3.3.0.v201205241358.jar
    org.eclipse.m2m.atl.core_3.3.0.v201205241358.jar
    org.eclipse.m2m.atl.core.emf_3.3.0.v201205241358.jar
    org.eclipse.m2m.atl.engine_3.3.0.v201205241358.jar
    org.eclipse.m2m.atl.engine.emfvm_3.3.0.v201205241358.jar
    org.eclipse.m2m.atl.dsls_3.3.0.v201205241358.jar

But I got this error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/m2m/atl/engine/compiler/AtlCompiler
	at main.Main.main(Main.java:35)
Caused by: java.lang.ClassNotFoundException: org.eclipse.m2m.atl.engine.compiler.AtlCompiler
	at java.net.URLClassLoader$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	... 1 more
make: *** [run] Error 1


On Eclipse:
In order to compile/execute, I need to add these JAR files in Java Build Path > Libraries:

    org.eclipse.core.resources_3.8.0.v20120522-2034.jar
    org.eclipse.emf.ecore_2.8.0.v20120606-0717.jar
    org.eclipse.emf.common_2.8.0.v20120606-0717.jar
    org.eclipse.emf.ecore.xmi_2.8.0.v20120606-0717.jar
    org.eclipse.equinox.common_3.6.100.v20120522-1841.jar
    org.eclipse.m2m.atl.common_3.3.0.v201205241358.jar
    org.eclipse.m2m.atl.core_3.3.0.v201205241358.jar
    org.eclipse.m2m.atl.core.emf_3.3.0.v201205241358.jar
    org.eclipse.m2m.atl.engine_3.3.0.v201205241358.jar
    org.eclipse.m2m.atl.engine.emfvm_3.3.0.v201205241358.jar
    org.eclipse.m2m.atl.dsls_3.3.0.v201205241358.jar
    org.antlr.runtime_3.0.0.v200803061811.jar
    org.eclipse.core.runtime_3.8.0.v20120521-2346.jar

But I got this error:
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.core.runtime.Platform
	at org.eclipse.m2m.atl.engine.compiler.AtlDefaultCompiler.internalCompile(AtlDefaultCompiler.java:204)
	at org.eclipse.m2m.atl.engine.compiler.AtlDefaultCompiler.compileWithProblemModel(AtlDefaultCompiler.java:94)
	at org.eclipse.m2m.atl.engine.compiler.AtlCompiler.compile(AtlCompiler.java:182)
	at MyClass.main(MyClass.java:35)


So, in both cases (command line and Eclipse), I can't run my program.

I am using Eclipse 4.2.0, ATL 3.3.0 and Java 1.6.0_25.

Do you see where is the problem?

Thank you.
Regards.
Re: Error at execution: java.lang.NoClassDefFoundError [message #958976 is a reply to message #948800] Fri, 26 October 2012 11:02 Go to previous messageGo to next message
Yugi Muto is currently offline Yugi MutoFriend
Messages: 33
Registered: February 2012
Member
I found a way to make it work :)

The code is good, there is nothing to change.

But in Eclipse, instead of create a Java project, create a Plug-in project.

Then add the following dependencies:
Require-Bundle: org.eclipse.m2m.atl.engine;bundle-version="3.3.0",
org.eclipse.core.resources;bundle-version="3.8.0",
org.eclipse.m2m.atl.common;bundle-version="3.3.0",
org.eclipse.m2m.atl.engine.emfvm;bundle-version="3.3.0",
org.eclipse.m2m.atl.dsls;bundle-version="3.3.0"

And it just works :)

I don't know why I need to create a Plug-in project instead of a Java project...

Do you know why?

Thank you.
Regards.

[Updated on: Fri, 26 October 2012 20:11]

Report message to a moderator

Re: Error at execution: java.lang.NoClassDefFoundError [message #959420 is a reply to message #958976] Fri, 26 October 2012 17:58 Go to previous messageGo to next message
Tomás Ruiz-López is currently offline Tomás Ruiz-LópezFriend
Messages: 12
Registered: October 2012
Location: Dallas
Junior Member
I have a little experience developing Eclipse plug-ins and I guess this is due to the fact that a Java project only uses the JDK libraries, whereas a Plug-in project includes the Eclipse development libraries, which is what you need in this case to call the ATL compiler.
Re: Error at execution: java.lang.NoClassDefFoundError [message #959543 is a reply to message #959420] Fri, 26 October 2012 20:10 Go to previous messageGo to next message
Yugi Muto is currently offline Yugi MutoFriend
Messages: 33
Registered: February 2012
Member
OK. So I should be able to make my code working in a Java project if I know what are the .jar archives corresponding to the Eclipse development libraries.

Do you have an idea of what are the .jar files corresponding to the Eclipse development libraries?
Re: Error at execution: java.lang.NoClassDefFoundError [message #959591 is a reply to message #959543] Fri, 26 October 2012 21:01 Go to previous message
Tomás Ruiz-López is currently offline Tomás Ruiz-LópezFriend
Messages: 12
Registered: October 2012
Location: Dallas
Junior Member
I have no clue on that, but maybe you have to check Eclipse SDK to know which are the corresponding jar files... I'll let you know if I figure out how to do it
Previous Topic:Problems starting with "Create a simple ATL transformation"
Next Topic:matched rule execution order
Goto Forum:
  


Current Time: Fri Dec 19 10:11:24 GMT 2014

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

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