|
|
|
|
Re: allInstances, unrecognized variable [message #835700 is a reply to message #835055] |
Tue, 03 April 2012 15:09 |
fv fv Messages: 19 Registered: April 2012 |
Junior Member |
|
|
Hi,
I've tried "MyClass.allInstances.var < 10", but the same error comes.
Are there other possibilities besides using the pivot version?
Another question appeared when reading the OCL Tutorial.
I have tried to use the library example project. It created the three projects:
org.eclipse.emf.examples.library
org.eclipse.emf.examples.library.edit
org.eclipse.emf.examples.library.editor
Then I created the following java class to parse an OCL Query as it is described in the tutorial (I should mention I used UMLEnvironmentFactory instead of the EcoreEnvironmentFactory because eclipse always told me that EcoreEnvironmentFactory cannot be resolved to a variable!?):
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.examples.extlibrary.EXTLibraryPackage;
import org.eclipse.ocl.expressions.OCLExpression;
import org.eclipse.uml2.uml.CallOperationAction;
import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.Classifier;
import org.eclipse.uml2.uml.Constraint;
import org.eclipse.uml2.uml.EnumerationLiteral;
import org.eclipse.uml2.uml.Operation;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.Parameter;
import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.SendSignalAction;
import org.eclipse.uml2.uml.State;
import org.eclipse.ocl.OCL;
import org.eclipse.ocl.ParserException;
import org.eclipse.ocl.helper.OCLHelper;
import org.eclipse.ocl.uml.UMLEnvironmentFactory;
public class LibTest {
boolean valid;
OCLExpression<EClassifier> query = null;
public void parseOCLExpr() {
OCL<Package, Classifier, Operation, Property, EnumerationLiteral, Parameter, State, CallOperationAction, SendSignalAction, Constraint, Class, EObject> ocl;
UMLEnvironmentFactory umlEnv = new UMLEnvironmentFactory();
ocl = OCL.newInstance(umlEnv);
// create an OCL helper object
OCLHelper helper = ocl.createOCLHelper();
try {
// set the OCL context classifier
helper.setContext(EXTLibraryPackage.Literals.WRITER);
query = helper.createQuery("self.books->collect(b : Book | b.category)->asSet()");
// record success
valid = true;
} catch (ParserException e) {
// record failure to parse
valid = false;
System.err.println(e.getLocalizedMessage());
e.printStackTrace();
}
}
public static void main(String[] args) {
LibTest a = new LibTest();
a.parseOCLExpr();
}
}
But I just get the following exception:
Exception in thread "main" java.lang.NoClassDefFoundError: lpg/runtime/RuleAction
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
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)
at LibTest.parseOCLExpr(LibTest.java:35)
at LibTest.main(LibTest.java:61)
Caused by: java.lang.ClassNotFoundException: lpg.runtime.RuleAction
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)
... 14 more
The reason for this seems to be the line:
ocl = OCL.newInstance(umlEnv);
Does anybody know what I did wrong?
Thank's.
[Updated on: Tue, 03 April 2012 15:15] Report message to a moderator
|
|
|
Re: allInstances, unrecognized variable [message #835766 is a reply to message #835700] |
Tue, 03 April 2012 16:38 |
Ed Willink Messages: 7669 Registered: July 2009 |
Senior Member |
|
|
Hi
Comments below
On 03/04/2012 16:09, fv fv wrote:
> Hi,
>
> I've tried "MyClass.allInstances.var < 10", but the same error comes.
> Are there other possibilities besides using the pivot version?
>
Read the earlier comments and use allInstances().
The, I've no idea what .var < 10 is supposed to do since .var is an
implicit collect and so returns a collection that cannot be compared
with an integer.
>
> Another question appeared when reading the OCL Tutorial.
> I have tried to use the library example project. It created the three
> projects:
> org.eclipse.emf.examples.library
> org.eclipse.emf.examples.library.edit
> org.eclipse.emf.examples.library.editor
>
> Then I created the following java class to parse an OCL Query as it is
> described in the tutorial:
>
>
>
>
>
>
> import org.eclipse.emf.ecore.EClassifier;
> import org.eclipse.emf.ecore.EObject;
> import org.eclipse.emf.examples.extlibrary.EXTLibraryPackage;
> import org.eclipse.ocl.expressions.OCLExpression;
> import org.eclipse.uml2.uml.CallOperationAction;
> import org.eclipse.uml2.uml.Class;
> import org.eclipse.uml2.uml.Classifier;
> import org.eclipse.uml2.uml.Constraint;
> import org.eclipse.uml2.uml.EnumerationLiteral;
> import org.eclipse.uml2.uml.Operation;
> import org.eclipse.uml2.uml.Package;
> import org.eclipse.uml2.uml.Parameter;
> import org.eclipse.uml2.uml.Property;
> import org.eclipse.uml2.uml.SendSignalAction;
> import org.eclipse.uml2.uml.State;
> import org.eclipse.ocl.OCL;
> import org.eclipse.ocl.ParserException;
> import org.eclipse.ocl.helper.OCLHelper;
> import org.eclipse.ocl.uml.UMLEnvironmentFactory;
>
> public class LibTest {
>
>
> boolean valid;
> OCLExpression<EClassifier> query = null;
>
>
> public void parseOCLExpr() {
>
>
> OCL<Package, Classifier, Operation, Property,
> EnumerationLiteral, Parameter, State, CallOperationAction,
> SendSignalAction, Constraint, Class, EObject> ocl;
> UMLEnvironmentFactory umlEnv = new UMLEnvironmentFactory();
> ocl = OCL.newInstance(umlEnv);
> // create an OCL helper object
> OCLHelper helper = ocl.createOCLHelper();
> try {
> // set the OCL context classifier
> helper.setContext(EXTLibraryPackage.Literals.WRITER);
> query =
> helper.createQuery("self.books->collect(b : Book |
> b.category)->asSet()");
> // record success
> valid = true;
> } catch (ParserException e) {
> // record failure to parse
> valid = false;
> System.err.println(e.getLocalizedMessage());
> e.printStackTrace();
> }
>
> }
>
>
> public static void main(String[] args) {
> LibTest a = new LibTest();
> a.parseOCLExpr();
> }
> }
>
>
>
>
>
>
> But I just get the following exception:
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> lpg/runtime/RuleAction
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClassCond(Unknown Source)
> at java.lang.ClassLoader.defineClass(Unknown Source)
> at java.security.SecureClassLoader.defineClass(Unknown Source)
> at java.net.URLClassLoader.defineClass(Unknown Source)
> at java.net.URLClassLoader.access$000(Unknown Source)
> 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)
> at LibTest.parseOCLExpr(LibTest.java:35)
> at LibTest.main(LibTest.java:61)
> Caused by: java.lang.ClassNotFoundException: lpg.runtime.RuleAction
> 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)
> ... 14 more
>
>
> The reason for this seems to be the line:
> ocl = OCL.newInstance(umlEnv);
>
> Does anybody know what I did wrong?
It looks as if lpg.runtime is missing, which is because you are using a
Java application rather than an Eclipse plugin project, which I
recommend since it has a MANIFEST that sorts nearly all the classpath
problems out. If you use Jav projects you have to solve all these
problems yourself. Fix the classpath.
Regards
Ed Willink
|
|
|
|
|
Re: allInstances, unrecognized variable [message #840630 is a reply to message #840595] |
Tue, 10 April 2012 10:05 |
Ed Willink Messages: 7669 Registered: July 2009 |
Senior Member |
|
|
Hi
That article was written in 2007 and led to the MDT/OCL Tools project
proposal which failed to progress past the creation review. That article
should not be linked to from current Eclipse OCL Documentation.
The main MDT/OCL project now provides many of the tools envisaged by the
proposed project:
- editors
- code generator
The new Xtext-based editors have an Outline view.
The article predates Xtext and so is very misleading about what can be
done with the new pivot-based UML-aligned Eclipse OCL. It may however
provide an example of the use of visitors, but in a clumsy fashion since
EClass is not visitable whereas org.eclipse.ocl.examples.pivot.Class is.
In general, synchronization of meta-model evolution is not supported by
EMF, and while many tools successfully make it work, useful
functionality is currently a bonus. Within Eclipse OCL, I was surprised
to find that the OCLinEcore editor updates when the *.ecore file is
changed externally. I know that the Console View does not update
correctly. I'm not surprised that the view in the old tutorial fails to
update.
Regards
Ed Willink
On 10/04/2012 10:28, fv fv wrote:
> Hi,
>
> now, both the query and the library example works :)
>
> My next step is to create a Syntax Tree of an OCL Expression.
> I read the article:
> www.eclipse.org/articles/printable.php?file=Article-HowToProcessOCLAbstractSyntaxTrees/index.html
>
> In this article the OCLAstView is mentioned.
> I extracted OCLASTView_1.0.0.jar and copied OCLASTView.jar in the
> plugins folder. Now I have the OCL Ast View as it is depicted in the
> tutorial.
> I thought I just have to select an invariant in an ecore file and the
> OCL Ast View is updated (as it looks like in figure 1 in the
> tutorial). But nothing happens.
> How do I have to use the View?
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06372 seconds