Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL Evaluation(Basics)
OCL Evaluation [message #1741406] Wed, 24 August 2016 19:47 Go to next message
Edouard R. Batot is currently offline Edouard R. BatotFriend
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 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
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 #1741409 is a reply to message #1741407] Wed, 24 August 2016 20:21 Go to previous messageGo to next message
Edouard R. Batot is currently offline Edouard R. BatotFriend
Messages: 100
Registered: March 2015
Senior Member
Hi Ed,
long time no see, hope you're doing good.

Quote:
Caused by: java.lang.ClassNotFoundException: lpg.runtime.RuleAction

means that lpg.runtime.RuleAction is not on your classpath.


That's correct. Thanks for your answer.
But using OCL, I don't get why am I asked to provide a path to that unknown class "lpg.runtime.RuleAction".


I would provide the content of my classpath explicitely, but unfortunately I have some trouble to print it - I love institutional machines.

But - the classpath I use contains the classics Java (included when creating a new project on Eclipse), plus
org.eclipse.emf.ecore
org.eclipse.emf.common
org.eclipse.emf.xmi

org.eclipse.ocl
org.eclipse.ocl.common
org.eclipse.ocl.ecore
org.eclipse.ocl.ecore.edit
org.eclipse.ocl.edit
org.eclipse.ocl.master


Does that help ?
Re: OCL Evaluation [message #1741434 is a reply to message #1741409] Thu, 25 August 2016 06:30 Go to previous messageGo to next message
Rolf Theunissen is currently offline Rolf TheunissenFriend
Messages: 260
Registered: April 2012
Senior Member
Seems the same as this issue:

https://www.eclipse.org/forums/index.php/t/198227/

Which version of OCL are you using?

[Updated on: Thu, 25 August 2016 06:32]

Report message to a moderator

Re: OCL Evaluation [message #1741480 is a reply to message #1741409] Thu, 25 August 2016 13:38 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

On 24/08/2016 21:21, Edoaurd Batot wrote:
> Hi Ed,
> long time no see, hope you're doing good.

Yes. Busy getting QVTr up to speed.

> I would provide the content of my classpath explicitely, but
> unfortunately I have some trouble to print it - I love institutional
> machines.

I'm really not interested in a printed classpath. At this point I
usually redirect to https://wiki.eclipse.org/OCL/ForumNetiquette.

On 25/08/2016 07:30, Rolf Theunissen wrote:
> Seems the same as this issue:
>
> https://www.eclipse.org/forums/index.php/t/198227/

Perhaps the problem is as simple as the referenced thread. But if you
installed OCL consistently you should have installed LPG too.

If you had supplied your MANIFEST.MF we wouldn't still be guessing.

Regards

Ed Willink

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
Re: OCL Evaluation [message #1741520 is a reply to message #1741480] Thu, 25 August 2016 14:58 Go to previous messageGo to next message
Edouard R. Batot is currently offline Edouard R. BatotFriend
Messages: 100
Registered: March 2015
Senior Member
Quote:
Seems the same as this issue:

https://www.eclipse.org/forums/index.php/t/198227/

I've read this one -> dead link.
I found some lpg update on sourceforge, installed it, same result.

Quote:
Perhaps the problem is as simple as the referenced thread. But if you installed OCL consistently you should have installed LPG too.

I've installed OCL from the marketplace, nothing fancy, and no trace of any LPG. What does this stand for "LPG" ?
What does "you installed OCL consistently" mean ?

Quote:
If you had supplied your MANIFEST.MF we wouldn't still be guessing.

Here it is (generated by Eclipse on demand).
  • Attachment: MANIFEST.MF
    (Size: 336.88KB, Downloaded 273 times)

[Updated on: Thu, 25 August 2016 15:09]

Report message to a moderator

Re: OCL Evaluation [message #1741527 is a reply to message #1741520] Thu, 25 August 2016 15:58 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

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.

When I wrote that I needed to see your MANIFEST.MF I meant the manually maintained source of your project. If you autogenerate the MANIFEST.MF then I need to see everything that affects the auto-generation. As clearly described in https://wiki.eclipse.org/OCL/ForumNetiquette, expect to waste both our times playing ping pong until you provide a zipped project.

Regards

Ed Willink
Re: OCL Evaluation [message #1741546 is a reply to message #1741527] Thu, 25 August 2016 18:01 Go to previous messageGo to next message
Edouard R. Batot is currently offline Edouard R. BatotFriend
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 #1741578 is a reply to message #1741546] Fri, 26 August 2016 05:08 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Where does the OCL documentation recommend installing from the Eclipse Marketplace?

Unfortunately punctuation got appended to https://wiki.eclipse.org/OCL/ForumNetiquette

Googling "OCL Forum Netiquette" also works.

Regards

Ed Willink
Re: OCL Evaluation [message #1741585 is a reply to message #1741578] Fri, 26 August 2016 06:48 Go to previous messageGo to next message
Rolf Theunissen is currently offline Rolf TheunissenFriend
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 Go to previous messageGo to next message
Edouard R. Batot is currently offline Edouard R. BatotFriend
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.
Re: OCL Evaluation [message #1741665 is a reply to message #1741648] Fri, 26 August 2016 19:07 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

What link is dead? just one that accidentally acquired trailing punctuation.

I certainly do not want to see your whole project. Since it fails at the very first step a very simple repro should demonstrate how clever/stupid you are being. Without a repro we can only guess at all the weird things you might have done. Bad classpath is just Java 101.

Eclipse OCL does not require a project, it is just that use of one enables you to gain all the benefits of Eclipse rather than just the inconveniences. 95% of Eclipse OCL JUnit tests work both standalone and as plugin tests. During day to day development, I only run the standalone tests since they avoid the overhead of an Eclipse invocation.

Not using a manifest is quite crazy. It forces you to get a non-trivial classpath just right by hand. If you don't know what you're doing, this takes a few rounds of newsgroup ping pong, and more if you don't actually communicate your problem. If you do know what you are doing, getting the classpath right can still take quite a few frustrating minutes. And you have to do it all over again when you update to a new version. In contrast a manifest just does it all automatically.

Even if your final production platform prohibits the use of a manifest, you should still use one for development since getting the help of Eclipse for the 99% of your time when your code doesn't work will save you tons of time in the long run.

Regards

Ed Willink



Previous Topic:Need your help on a student assignment .
Next Topic:news.eclipse.org is shutting down.
Goto Forum:
  


Current Time: Tue Mar 19 07:27:34 GMT 2024

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

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

Back to the top