Skip to main content



      Home
Home » Modeling » OCL » [OCL-Java] java.lang.NoClassDefFoundError: lpg/runtime/RuleAction
[OCL-Java] java.lang.NoClassDefFoundError: lpg/runtime/RuleAction [message #632093] Mon, 11 October 2010 10:27 Go to next message
Eclipse UserFriend
Hi all,

I'm working on a Java project that must execute some OCL Queries on an Ecore model.
I've written the foolowing class for trying a simple OCL Query execution:

import java.io.IOException;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.impl.ResourceImpl;
import org.eclipse.emf.query.conditions.Condition;
import org.eclipse.emf.query.conditions.eobjects.EObjectCondition;
import org.eclipse.emf.query.ocl.conditions.BooleanOCLCondition;
import org.eclipse.emf.query.statements.FROM;
import org.eclipse.emf.query.statements.IQueryResult;
import org.eclipse.emf.query.statements.SELECT;
import org.eclipse.emf.query.statements.WHERE;
import org.eclipse.ocl.ParserException;
import org.eclipse.ocl.ecore.EcoreEnvironmentFactory;
import org.eclipse.ocl.ecore.OCL;

public class QueryExecutor {

	/**
	* The method thats execute ocl queries
	* @param query the ocl query that must be executed
	*/
	public static IQueryResult execute(Resource ecoreResource, String query) {
		OCL ocl = OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);
		Condition condition;
		IQueryResult results = null;
		try {
			condition = new BooleanOCLCondition<EClassifier, EClass, EObject>(ocl.getEnvironment(),query,null);
	
			SELECT statement = new SELECT(SELECT.UNBOUNDED, false,
						new FROM(ecoreResource.getContents()), new WHERE((EObjectCondition) condition) );
			results = statement.execute();
		} catch (ParserException e) {
			e.printStackTrace();
		}
		return results;
	}
	
	
	public static void main(String[] args) {
		Resource ecoreResource = new ResourceImpl();
		ecoreResource.setURI(org.eclipse.emf.common.util.URI.createFileURI("systemModel2.ecore")); //systemModel.ecore is the ecore model on which an col query is executed
		System.out.println(ecoreResource.toString());
		IQueryResult res = execute(ecoreResource, "self->debug('self')");
		System.out.println(res.toString());
	}

}


but it returns the error:

Exception in thread "main" java.lang.NoClassDefFoundError: lpg/runtime/RuleAction
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoade r.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301 )
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at failuresdetector.QueryExecutor.execute(QueryExecutor.java:35 )
at failuresdetector.QueryExecutor.main(QueryExecutor.java:51)
Caused by: java.lang.ClassNotFoundException: lpg.runtime.RuleAction
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301 )
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 14 more

Investigating on the web, I relized that this happens when the lpg Java Runtime library library is missing, but I've added this library to my project. In fact, its Java Build Path includes the file net.sourceforge.lpg.lpgjavaruntime_1.1.0.v201004271650.jar .
So, I don't know what's the problem. Anyone could help me, please?

Many thanks in advance,

Dave.
Re: [OCL-Java] java.lang.NoClassDefFoundError: lpg/runtime/RuleAction [message #632095 is a reply to message #632093] Mon, 11 October 2010 10:31 Go to previous messageGo to next message
Eclipse UserFriend
I precise that the exception is thrown when executing the instruction
OCL ocl = OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);


and nothing changes if I replace it with

OCL ocl = OCL.newInstance();
Re: [OCL-Java] java.lang.NoClassDefFoundError: lpg/runtime/RuleAction [message #632119 is a reply to message #632093] Mon, 11 October 2010 11:56 Go to previous message
Eclipse UserFriend
I solved this issue.
I've downloaded the latest version of lpg, directly from the update site:

http://download.eclipse.org/technology/imp/updates/

and now it works! Smile

Dave.
Previous Topic:Exceptions swallowed during evaluation
Next Topic:[OCLInEcore] Change default error messages
Goto Forum:
  


Current Time: Wed Jul 23 18:58:17 EDT 2025

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

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

Back to the top