Home » Modeling » OCL » OCL Evaluation(Basics)
OCL Evaluation [message #1741406] |
Wed, 24 August 2016 19:47 |
Edouard R. Batot Messages: 100 Registered: March 2015 |
Senior Member |
|
|
Hi there,
I've been looking on the forum for a while now and I cannot find any way to tackle with my problem :
I want to execute OCL constraints on an XMI model (meta is written in Ecore).
After initializing the resource for the metamodel, I execute :
boolean valid;
Constraint invariant = null;
try {
// create an OCL instance for Ecore
OCL<?, EClassifier, ?, ?, ?, ?, ?, ?, ?, Constraint, EClass, EObject> ocl;
ocl = OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);
// create an OCL helper object
OCLHelper<EClassifier, ?, ?, Constraint> helper = ocl.createOCLHelper();
// set the OCL context classifier
helper.setContext(m.classifiers.get("P"));
invariant = helper.createInvariant(
"age>10"
);
// record success
valid = true;
} catch (ParserException e) {
// record failure to parse
valid = false;
System.err.println(e.getLocalizedMessage());
}
(Copy paste from tutorials)
Note that I've tried many different OCL expression, same result :
Exception in thread "main" java.lang.NoClassDefFoundError: lpg/runtime/RuleAction
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
...
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at MainOCL.main(MainOCL.java:39)
Caused by: java.lang.ClassNotFoundException: lpg.runtime.RuleAction
at java.net.URLClassLoader$1.run(Unknown Source)
... 16 more
The metamodel and models used are ok since I use them in other context.
I guess it is about a configuration mistake, but I've got no clue about where to start searching.
Any help would be much appreciated.
THanks,
Edouard
|
|
|
Re: OCL Evaluation [message #1741407 is a reply to message #1741406] |
Wed, 24 August 2016 19:55 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
It is very difficult to diagnose problems when you only provide a
fraction of a repro. In particular your classpath is critical since:
Caused by: java.lang.ClassNotFoundException: lpg.runtime.RuleAction
means that lpg.runtime.RuleAction is not on your classpath.
Regards
Ed Willink
On 24/08/2016 20:47, Edoaurd Batot wrote:
> Hi there,
>
> I've been looking on the forum for a while now and I cannot find any way
> to tackle with my problem : I want to execute OCL constraints on an XMI
> model (meta is written in Ecore).
>
>
> After initializing the resource for the metamodel, I execute :
>
> boolean valid;
> Constraint invariant = null;
> try {
> // create an OCL instance for Ecore
> OCL<?, EClassifier, ?, ?, ?, ?, ?, ?, ?, Constraint, EClass,
> EObject> ocl;
> ocl = OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);
> // create an OCL helper object
> OCLHelper<EClassifier, ?, ?, Constraint> helper =
> ocl.createOCLHelper();
> // set the OCL context classifier
> helper.setContext(m.classifiers.get("P"));
> invariant = helper.createInvariant(
> "age>10"
> );
> // record success
> valid = true;
> } catch (ParserException e) {
> // record failure to parse
> valid = false;
> System.err.println(e.getLocalizedMessage());
> }
>
> (Copy paste from tutorials)
>
> Note that I've tried many different OCL expression, same result :
> Exception in thread "main" java.lang.NoClassDefFoundError:
> lpg/runtime/RuleAction
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClass(Unknown Source)
> ..
> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at MainOCL.main(MainOCL.java:39)
> Caused by: java.lang.ClassNotFoundException: lpg.runtime.RuleAction
> at java.net.URLClassLoader$1.run(Unknown Source)
> ... 16 more
>
>
> The metamodel and models used are ok since I use them in other context.
> I guess it is about a configuration mistake, but I've got no clue about
> where to start searching.
> Any help would be much appreciated.
> THanks,
> Edouard
>
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
|
|
| | | | | |
Re: OCL Evaluation [message #1741546 is a reply to message #1741527] |
Thu, 25 August 2016 18:01 |
Edouard R. Batot Messages: 100 Registered: March 2015 |
Senior Member |
|
|
Quote:Installing from the marketplace is fancy, since OCL is a core Eclipse contribution available directly from the Neon or whatever repo that also has all the correct dependencies.
Once this problem is solved, perhaps the mechanism by which the marketplace let you down can be investigated.
If this is ping-pong, I'd ask you to give some flesh too.
What is the marketplace purpose if not to get the correct dependencies while installing a plugin ? I went through the documentation, installed the required "OCL Example and SDK" thing. If I am suppose to know before hand external dependencies a plugin require, I don't need any marketplace, do I ?
That is not the topic I guess.
As for the "forum netiquette", the link is another "dead" one as pictured in the attached image.
Sorry, but I usually don't use manifest. If there's any information I can provide, I will.
I have a couple dozens of Java lines (with related EMF dependencies) to extract a valid EClassifier from an Ecore metamodel which I want to use to apply OCL terms.
I copy-pasted the OCL tutorial's code. The first lines compile but do not execute.
The OCL I use is OCL Eclipse 6.0.1 from the marketplace (I did it again on a Mars version of Eclipse, with no notice of LPG requirements).
This is the whole story, any additional information I'm not aware of, but I can look for it on demand, of course.
OCL<?, EClassifier, ?, ?, ?, ?, ?, ?, ?, Constraint, EClass, EObject> ocl;
ocl = OCL.newInstance(EcoreEnvironmentFactory.INSTANCE); //this throws ClassDefNotException w.r.t. lpg.runtime.RuleAction
|
|
| |
Re: OCL Evaluation [message #1741585 is a reply to message #1741578] |
Fri, 26 August 2016 06:48 |
Rolf Theunissen Messages: 260 Registered: April 2012 |
Senior Member |
|
|
Hi Edoaurd,
I expect that there is a problem in the set-up of the project. The dependencies listed for OCL are the 'root'-dependencies. These dependencies are OSGi bundles, not plain jars. The OSGi bundles have dependencies on other bundles too, these dependencies will be resolved by the OSGi platform. If you are using the OSGi bundles as plain jars, the dependencies are not automatically resolved. You have to manually take care that all these dependencies are available on the classpath too.
Switching from an plain java project to an eclipse plugin project might solve the issues. However, this can result in other problems in your particular set-up or deployment.
As pointed out by Ed, please provide us with more information, especially regarding your project set-up, classpath settings, and how you execute your command. For now, all the above is just a guess.
|
|
|
Re: OCL Evaluation [message #1741648 is a reply to message #1741585] |
Fri, 26 August 2016 15:05 |
Edouard R. Batot Messages: 100 Registered: March 2015 |
Senior Member |
|
|
Thanks Rolf for your attention,
I'm gonna investigate what does OSGi is - might be usefull since it is not the first time I encounter it.
I like to keep my projects plain Java to avoid dependencies to the platform I use (Eclipse, with chosen plugins and features is a plateform).
Nonethless, the use of OCL seems to require an Eclipse project.
It is the second time I have to deal with OCL from scratch, and I don't understand why is it so complicated to get started with..
On the other hand, Ed, I did not expect you to run the project I'm working on. The exception being thrown at the very first step of the execution, I was looking for help from the ones who have had the same issue before. And it happened, as pointed out in a previous post - but links are dead. That might be added to your netiquette guidelines : if we want to reuse and improve the knowledge we put into the forum, it would be better to keep the links working. Otherwise, we are gonna depend on a few gurus - which good-will might be affected by a few goofy words.
Thanks for your help, I'll get some distance and be back in a few days (once I'll have gathered zips and OSGi dependencies).
Have a good day.
|
|
| |
Goto Forum:
Current Time: Tue Mar 19 07:27:34 GMT 2024
Powered by FUDForum. Page generated in 0.03743 seconds
|