Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » setContext doesn't find RuleAction
setContext doesn't find RuleAction [message #41873] Tue, 30 October 2007 12:49 Go to next message
Jens von Pilgrim is currently offline Jens von PilgrimFriend
Messages: 313
Registered: July 2009
Senior Member
Hi,

I'm pretty new to OCL, so I tried to set up a quick test. I created a
new EMF based model, generated model, edit, editor, and test plugins
and now I'm trying to add some OCL expressions.

This is my test code:
-------------------------------------------------
01 // using package org.eclipse.ocl.ecore
02 EcoreEnvironmentFactory envfac = new
EcoreEnvironmentFactory(resourceSet.getPackageRegistry());
03 OCL ocl = OCL.newInstance(envfac);
04 OCL.Helper helper = ocl.createOCLHelper();
05 EObject instanceContext = resource.getContents().get(0);
06 helper.setInstanceContext(instanceContext);
07 try {
08 OCLExpression query = helper.createQuery("self.vertices->size()");
09 Object result = ocl.createQuery(query).evaluate();
10 System.out.println(result);
11 } catch (ParserException ex) {
12 ex.printStackTrace();
13 }
-------------------------------------------------

In line 6, the following exception is thrown:

-------------------------------------------------
Exception in thread "main" java.lang.NoClassDefFoundError:
lpg/lpgjavaruntime/RuleAction
....
at
org.eclipse.ocl.AbstractEnvironment.lookupLocal(AbstractEnvi ronment.java:482)
at

org.eclipse.ocl.AbstractEnvironment.addElement(AbstractEnvir onment.java:249)
at
org.eclipse.ocl.AbstractEnvironmentFactory.createClassifierC ontext(AbstractEnvironmentFactory.java:132)
at

org.eclipse.ocl.AbstractEnvironmentFactory.createInstanceCon text(AbstractEnvironmentFactory.java:144)
at

org.eclipse.ocl.internal.helper.OCLHelperImpl.setInstanceCon text(OCLHelperImpl.java:131)
at

org.eclipse.ocl.ecore.OCLHelperImpl.setInstanceContext(OCLHe lperImpl.java:130)
= line 6
at
de.feu.SimpleModel.tests.SimpleModelExample.main(SimpleModel Example.java:114)
-------------------------------------------------

I

also modified the ocl.examples.interpreter to plugin into my model
editor instead of the library example, and this is working pretty well.
With the (modified) interpreter example, I can query the model.

What is wrong with my code? Do I have to add a dependency? Where do I
find lpg.lpgjavaruntime.RuleAction?

Jens
Re: setContext doesn't find RuleAction [message #41914 is a reply to message #41873] Tue, 30 October 2007 15:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Jens,

How did you install the OCL SDK? The SDK download and update-manager site
both include the plug-in that defines the RuleAction class:

- net.sourceforge.lpg.lpgjavaruntime (version 1.1.0)

If you're consuming the OCL source from CVS, then you can get the LPG Java
Runtime from the Orbit CVS repository. The easiest way to do that is to
load the ocl.psf file in the org.eclipse.ocl.releng project, or download it
from the Orbit downloads page:
http://download.eclipse.org/tools/orbit/downloads/

HTH,

Christian


Jens v.P. wrote:

> Hi,
>
> I'm pretty new to OCL, so I tried to set up a quick test. I created a
> new EMF based model, generated model, edit, editor, and test plugins
> and now I'm trying to add some OCL expressions.
>
> This is my test code:
> -------------------------------------------------
> 01 // using package org.eclipse.ocl.ecore
> 02 EcoreEnvironmentFactory envfac = new
> EcoreEnvironmentFactory(resourceSet.getPackageRegistry());
> 03 OCL ocl = OCL.newInstance(envfac);
> 04 OCL.Helper helper = ocl.createOCLHelper();
> 05 EObject instanceContext = resource.getContents().get(0);
> 06 helper.setInstanceContext(instanceContext);
> 07 try {
> 08 OCLExpression query = helper.createQuery("self.vertices->size()");
> 09 Object result = ocl.createQuery(query).evaluate();
> 10 System.out.println(result);
> 11 } catch (ParserException ex) {
> 12 ex.printStackTrace();
> 13 }
> -------------------------------------------------
>
> In line 6, the following exception is thrown:
>
> -------------------------------------------------
> Exception in thread "main" java.lang.NoClassDefFoundError:
> lpg/lpgjavaruntime/RuleAction
> ...
> at
>
org.eclipse.ocl.AbstractEnvironment.lookupLocal(AbstractEnvi ronment.java:482)
> at
>
>
org.eclipse.ocl.AbstractEnvironment.addElement(AbstractEnvir onment.java:249)
> at
>
org.eclipse.ocl.AbstractEnvironmentFactory.createClassifierC ontext(AbstractEnvironmentFactory.java:132)
> at
>
>
org.eclipse.ocl.AbstractEnvironmentFactory.createInstanceCon text(AbstractEnvironmentFactory.java:144)
> at
>
>
org.eclipse.ocl.internal.helper.OCLHelperImpl.setInstanceCon text(OCLHelperImpl.java:131)
> at
>
>
org.eclipse.ocl.ecore.OCLHelperImpl.setInstanceContext(OCLHe lperImpl.java:130)
> = line 6
> at
>
de.feu.SimpleModel.tests.SimpleModelExample.main(SimpleModel Example.java:114)
> -------------------------------------------------
>
> I
>
> also modified the ocl.examples.interpreter to plugin into my model
> editor instead of the library example, and this is working pretty well.
> With the (modified) interpreter example, I can query the model.
>
> What is wrong with my code? Do I have to add a dependency? Where do I
> find lpg.lpgjavaruntime.RuleAction?
>
> Jens
Re: setContext doesn't find RuleAction [message #41976 is a reply to message #41914] Tue, 30 October 2007 18:13 Go to previous message
Jens von Pilgrim is currently offline Jens von PilgrimFriend
Messages: 313
Registered: July 2009
Senior Member
On 2007-10-30 16:42:14 +0100, "Christian W. Damus" <cdamus@ca.ibm.com> said:
>
> - net.sourceforge.lpg.lpgjavaruntime (version 1.1.0)

I have used the update site, and the plugin was installed. I simply
didn't added it to the dependencies. Thank you very much!

Jens
Previous Topic:Re: Generating code for OCL annotations in OCL 1.0.1/EMF 2.2
Next Topic:Adding variable-value bindings to queries
Goto Forum:
  


Current Time: Thu Apr 25 04:41:50 GMT 2024

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

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

Back to the top