Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL Validation outside of eclipse
OCL Validation outside of eclipse [message #1102170] Thu, 05 September 2013 13:12 Go to next message
Jean-Baptiste Guillois is currently offline Jean-Baptiste GuilloisFriend
Messages: 33
Registered: August 2011
Member
Hello,

I am trying to programmatically trigger OCL validation of my EMF model. Everything works well using the Eclipse environment (EMF model editor and instance viewer)

I use this code in my unit tests. After reading some posts in this forum, I added the following OCL initialization code in my setUp() method:

String oclDelegateURI = OCLDelegateDomain.OCL_DELEGATE_URI;

Operation.Internal.InvocationDelegate.Factory.Registry.INSTANCE.put(oclDelegateURI,
				new OCLInvocationDelegateFactory.Global());

EStructuralFeature.Internal.SettingDelegate.Factory.Registry.INSTANCE.put(oclDelegateURI,
				new OCLSettingDelegateFactory.Global());

EValidator.ValidationDelegate.Registry.INSTANCE.put(oclDelegateURI,
				new OCLValidationDelegateFactory.Global());


Then, in my test method i use the following:
// Validate this domain
Diagnostic diag = Diagnostician.INSTANCE.validate(myDomain);
assertNotNull(diag.getChildren());

for (Diagnostic subDiag : diag.getChildren()) {
	System.out.println(subDiag.getMessage());
}


I get the following validation diagnostics, which are both correct but the second one reveals that my OCL constraint has not been evaluated:
The feature 'environments' of 'com.xxx.root.impl.DomainImpl@35b57d0b{#//}' with 0 values must have at least 1 values
Unable to find delegate to evaluate the 'atLeastOneFlow' constraint on 'com.xxx.interaction.impl.InteractionTemplateImpl@27cb4b33{#///@interactionTemplates.0}': http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot


Any idea?

Many thanks for your help,

Best Regards,
-- Jean-Baptiste
PS: I am using org.eclipse.ocl-3.2.1, org.eclipse.ocl.ecore-3.2.0, org.eclipse.ocl.common-1.0.2

Re: OCL Validation outside of eclipse [message #1102205 is a reply to message #1102170] Thu, 05 September 2013 14:03 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4155
Registered: July 2009
Senior Member
Hi

You've only provided only half a problem; no repro.

So I can only provide a half a reply; no solution.

Regards

Ed Willink


On 05/09/2013 14:12, Missing name Mising name wrote:
> Hello,
>
> I am trying to programmatically trigger OCL validation of my EMF
> model. Everything works well using the Eclipse environment (EMF model
> editor and instance viewer)
>
> I use this code in my unit tests. After reading some posts in this
> forum, I added the following OCL initialization code in my setUp()
> method:
>
> String oclDelegateURI = OCLDelegateDomain.OCL_DELEGATE_URI;
>
> Operation.Internal.InvocationDelegate.Factory.Registry.INSTANCE.put(oclDelegateURI,
>
> new OCLInvocationDelegateFactory.Global());
>
> EStructuralFeature.Internal.SettingDelegate.Factory.Registry.INSTANCE.put(oclDelegateURI,
>
> new OCLSettingDelegateFactory.Global());
>
> EValidator.ValidationDelegate.Registry.INSTANCE.put(oclDelegateURI,
> new OCLValidationDelegateFactory.Global());
>
> Then, in my test method i use the following:
>
> // Validate this domain
> Diagnostic diag = Diagnostician.INSTANCE.validate(myDomain);
> assertNotNull(diag.getChildren());
>
> for (Diagnostic subDiag : diag.getChildren()) {
> System.out.println(subDiag.getMessage());
> }
>
>
> I get the following validation diagnostics, which are both correct but
> the second one reveals that my OCL constraint has not been evaluated:
> The feature 'environments' of
> 'com.xxx.root.impl.DomainImpl@35b57d0b{#//}' with 0 values must have
> at least 1 values
> Unable to find delegate to evaluate the 'atLeastOneFlow' constraint on
> 'com.xxx.interaction.impl.InteractionTemplateImpl@27cb4b33{#///@interactionTemplates.0}':
> http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot
>
>
> Any idea?
>
> Many thanks for your help,
>
> Best Regards,
> -- Jean-Baptiste
> PS: I am using org.eclipse.ocl-3.2.1, org.eclipse.ocl.ecore-3.2.0,
> org.eclipse.ocl.common-1.0.2
>
>
Re: OCL Validation outside of eclipse [message #1125211 is a reply to message #1102205] Fri, 04 October 2013 09:19 Go to previous messageGo to next message
Jean-Baptiste Guillois is currently offline Jean-Baptiste GuilloisFriend
Messages: 33
Registered: August 2011
Member
Hi Ed,

I am sorry for not getting back to you earlier.

Please find attached a zip file containing a minimal project with a main class that:
- create an instance of a Test class
- triggers the validation of this instance

After execution, you will have in the console something like:
Diagnostic ERROR source=root code=0 An exception occurred while delegating evaluation of the 'check1' constraint on 'root.impl.TestImpl@3890c1ee{#//}': org/eclipse/ocl/examples/domain/elements/DomainElement data=[root.impl.TestImpl@3890c1ee (att1: 1, att2: 123)]


This is what i am struggling at...

If you can provide any help/hint regarding this error, that would be great,

Thx,

Best regards,
Re: OCL Validation outside of eclipse [message #1125392 is a reply to message #1125211] Fri, 04 October 2013 13:07 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4155
Registered: July 2009
Senior Member
Hi

If you set a breakpoint on BasicDiagnostic, you can see that the "An
exception occurred while delegating evaluation of the" occurred because of a

java.lang.NoClassDefFoundError:
org/eclipse/ocl/examples/domain/utilities/DomainUtil

which is nearly the same as
org/eclipse/ocl/examples/domain/elements/DomainElement

Try fixing the classpath.

Regards

Ed Willink

On 04/10/2013 05:19, Jean-Baptiste Guillois wrote:
> Hi Ed,
>
> I am sorry for not getting back to you earlier.
>
> Please find attached a zip file containing a minimal project with a main class that:
> - create an instance of a Test class
> - triggers the validation of this instance
>
> After execution, you will have in the console something like:
> Diagnostic ERROR source=root code=0 An exception occurred while delegating evaluation of the 'check1' constraint on 'root.impl.TestImpl@3890c1ee{#//}': org/eclipse/ocl/examples/domain/elements/DomainElement data=[root.impl.TestImpl@3890c1ee (att1: 1, att2: 123)]
>
> This is what i am struggling at...
>
> If you can provide any help/hint regarding this error, that would be great,
>
> Thx,
>
> Best regards,
Re: OCL Validation outside of eclipse [message #1125408 is a reply to message #1125392] Fri, 04 October 2013 13:25 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4155
Registered: July 2009
Senior Member
Hi

https://bugs.eclipse.org/bugs/show_bug.cgi?id=418677 raised.

Regards

Ed Willink

On 04/10/2013 09:07, Ed Willink wrote:
> Hi
>
> If you set a breakpoint on BasicDiagnostic, you can see that the "An
> exception occurred while delegating evaluation of the" occurred
> because of a
>
> java.lang.NoClassDefFoundError:
> org/eclipse/ocl/examples/domain/utilities/DomainUtil
>
> which is nearly the same as
> org/eclipse/ocl/examples/domain/elements/DomainElement
>
> Try fixing the classpath.
>
> Regards
>
> Ed Willink
>
> On 04/10/2013 05:19, Jean-Baptiste Guillois wrote:
>> Hi Ed,
>>
>> I am sorry for not getting back to you earlier.
>>
>> Please find attached a zip file containing a minimal project with a
>> main class that:
>> - create an instance of a Test class
>> - triggers the validation of this instance
>>
>> After execution, you will have in the console something like:
>> Diagnostic ERROR source=root code=0 An exception occurred while
>> delegating evaluation of the 'check1' constraint on
>> 'root.impl.TestImpl@3890c1ee{#//}':
>> org/eclipse/ocl/examples/domain/elements/DomainElement
>> data=[root.impl.TestImpl@3890c1ee (att1: 1, att2: 123)]
>>
>> This is what i am struggling at...
>>
>> If you can provide any help/hint regarding this error, that would be
>> great,
>>
>> Thx,
>>
>> Best regards,
>
Re: OCL Validation outside of eclipse [message #1125431 is a reply to message #1125408] Fri, 04 October 2013 13:58 Go to previous messageGo to next message
Jean-Baptiste Guillois is currently offline Jean-Baptiste GuilloisFriend
Messages: 33
Registered: August 2011
Member
Hi Ed,

Thx for your quick reply.
Thanks to your answer, i discovered that many jars were missing. I attached my updated project zip.

I nevertheless now get an exception in EObjectValidator.class (line 237):
org.eclipse.debug.core.DebugException: com.sun.jdi.ClassNotLoadedException: Type has not been loaded occurred while retrieving component type of array
.

Any clue?

Thx again,

Best Regards,
Re: OCL Validation outside of eclipse [message #1125532 is a reply to message #1125431] Fri, 04 October 2013 16:11 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4155
Registered: July 2009
Senior Member
Hi

On 04/10/2013 09:58, Jean-Baptiste Guillois wrote:
> Hi Ed,
>
> Thx for your quick reply.
> Thanks to your answer, i discovered that many jars were missing. I attached my updated project zip.
>
> I nevertheless now get an exception in EObjectValidator.class (line 237):
> org.eclipse.debug.core.DebugException: com.sun.jdi.ClassNotLoadedException: Type has not been loaded occurred while retrieving component type of array.
Where did this come from?

Any clue?
> Any clue?
>
> Thx again,
>
> Best Regards,
Re: OCL Validation outside of eclipse [message #1125560 is a reply to message #1125532] Fri, 04 October 2013 16:47 Go to previous messageGo to next message
Jean-Baptiste Guillois is currently offline Jean-Baptiste GuilloisFriend
Messages: 33
Registered: August 2011
Member
Hi,

I get this exception while stepping with the debugger in the EObjectValidator class line 237.
At the end (from my main class), the end result is the same as before.

What other info can I provide you on this problem to help you helping me?

Best Regards,

PS: Thx for the bug, i read its description and I agree that having more info when a validation fails because of missing entires in classpath would bgreat.
Re: OCL Validation outside of eclipse [message #1125610 is a reply to message #1125560] Fri, 04 October 2013 17:52 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4155
Registered: July 2009
Senior Member
Hi

An exception is the first line of a diagnostic; where is the rest of it?

org.eclipse.debug.core.DebugException: com.sun.jdi.ClassNotLoadedException

is a very odd exception; it suggests that the debugger is malfunctioning
so the context may be very revealing.

See
http://stackoverflow.com/questions/1367730/how-do-i-deal-with-a-classnotloadedexception-while-debugging.

Regards

Ed Willink


On 04/10/2013 12:47, Jean-Baptiste Guillois wrote:
> Hi,
>
> I get this exception while stepping with the debugger in the
> EObjectValidator class line 237.
> At the end (from my main class), the end result is the same as before.
>
> What other info can I provide you on this problem to help you helping me?
>
> Best Regards,
>
> PS: Thx for the bug, i read its description and I agree that having
> more info when a validation fails because of missing entires in
> classpath would bgreat.
Re: OCL Validation outside of eclipse [message #1127493 is a reply to message #1125532] Sun, 06 October 2013 18:57 Go to previous messageGo to next message
Jean-Baptiste Guillois is currently offline Jean-Baptiste GuilloisFriend
Messages: 33
Registered: August 2011
Member
Hi Ed,

Please find attached two screenshots of my current eclipse state where you will see the stacktrace i talked about.

I don't know what information I can add to help you...

Thx for your help,

Best Regards,
Re: OCL Validation outside of eclipse [message #1129300 is a reply to message #1127493] Tue, 08 October 2013 13:48 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4155
Registered: July 2009
Senior Member
Hi

Please consult http://wiki.eclipse.org/OCL/ForumNetiquette

Regards

Ed Willink

On 06/10/2013 19:57, Jean-Baptiste Guillois wrote:
> Hi Ed,
>
> Please find attached two screenshots of my current eclipse state where you will see the stacktrace i talked about.
>
> I don't know what information I can add to help you...
>
> Thx for your help,
>
> Best Regards,
Re: OCL Validation outside of eclipse [message #1129603 is a reply to message #1129300] Tue, 08 October 2013 20:21 Go to previous messageGo to next message
Jean-Baptiste Guillois is currently offline Jean-Baptiste GuilloisFriend
Messages: 33
Registered: August 2011
Member
Hi Ed,

Thx for your email.
I have carefully read the ForumNetiquette as you suggested.

Nevertheless, I have provided you with a zipped project containing the required files for demonstrating my problem which, since the beginning, is about getting some help on how to initialize the OCL framework. I am still struggling at this and was hoping to find some help in doing such an initialization (which, in my opinion, does not seem to be that special) in this forum.
I have added the two previous screenshots for illustrating the exception I have encountered as no stacktrace is being printed anywhere (as far as I know). By the way, there wasn't any stacktrace printed neither for the missing classpath entries and I thank you for creating and commenting the bug your created.

Regarding my initial problem, and as I still would like to use OCL in my project, would it be better (not to waste your time or other contributors' time) to ask for help specifically on a code snippet regarding OCL usage outside of Eclipse ?

If you want me to ask this question in another thread/forum, please feel free.

Thx for your time and help,

With my best regards,
Re: OCL Validation outside of eclipse [message #1129631 is a reply to message #1129603] Tue, 08 October 2013 20:55 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4155
Registered: July 2009
Senior Member
Hi

Perthaps I should add "Don't ask follow on question".

When you write "Thanks to your answer, i discovered that many jars were
missing. I attached my updated project zip." I regard the thread as
complete and assu me that nsibnce you have resolved your problem you can
resolve your next one.

You cannot expect me to reread multiple levels of the thread.

Regards

Ed Willink



On 08/10/2013 21:21, Jean-Baptiste Guillois wrote:
> Hi Ed,
>
> Thx for your email.
> I have carefully read the ForumNetiquette as you suggested.
> Nevertheless, I have provided you with a zipped project containing the
> required files for demonstrating my problem which, since the
> beginning, is about getting some help on how to initialize the OCL
> framework. I am still struggling at this and was hoping to find some
> help in doing such an initialization (which, in my opinion, does not
> seem to be that special) in this forum.
> I have added the two previous screenshots for illustrating the
> exception I have encountered as no stacktrace is being printed
> anywhere (as far as I know). By the way, there wasn't any stacktrace
> printed neither for the missing classpath entries and I thank you for
> creating and commenting the bug your created.
>
> Regarding my initial problem, and as I still would like to use OCL in
> my project, would it be better (not to waste your time or other
> contributors' time) to ask for help specifically on a code snippet
> regarding OCL usage outside of Eclipse ?
>
> If you want me to ask this question in another thread/forum, please
> feel free.
>
> Thx for your time and help,
>
> With my best regards,
Re: OCL Validation outside of eclipse [message #1130721 is a reply to message #1129603] Wed, 09 October 2013 21:47 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4155
Registered: July 2009
Senior Member
On 08/10/2013 21:21, Jean-Baptiste Guillois wrote:
>
> If you want me to ask this question in another thread/forum, please
> feel free.
You would save yourself a lot of time if you read the documentation:

http://help.eclipse.org/kepler/topic/org.eclipse.ocl.doc/help/PivotStandalone.html?cp=38_6_2

requires standalone users to call Xtext setup.

If you test first in an envirionment where Eclipse helps, such as a Java
application with Manifest.mf controlled classpath you wouldn't have to
struggle with all those horrible paths and you would get

"Diagnostic ERROR source=root code=0 An exception occurred while
delegating evaluation of the 'check1' constraint on
'root.impl.TestImpl@e9f6ef{#//}': No registration for content type
'org.eclipse.ocl.examples.oclas.ecore' data=[root.impl.TestImpl@e9f6ef
(att1: 1, att2: 123)]
"

which is a clue that initialization/registration is rubbish.

If you add the missing

EssentialOCLStandaloneSetup.doSetup();

You get

"Diagnostic ERROR source=root code=0 The 'check1' constraint is violated
on 'root.impl.TestImpl@f0926b{#//}' data=[root.impl.TestImpl@f0926b
(att1: 1, att2: 123)]"

which is presumably what you want.

Regards

Ed Willink
Re: OCL Validation outside of eclipse [message #1131538 is a reply to message #1130721] Thu, 10 October 2013 16:18 Go to previous messageGo to next message
Jean-Baptiste Guillois is currently offline Jean-Baptiste GuilloisFriend
Messages: 33
Registered: August 2011
Member
Hi Ed,

Thanks a lot for your help, I indeed now get the correct diagnostic message.
I have attached to this reply the final zipped version of my project as it might be usefull to other users of this forum.

This topic is now resolved.

Thx again for your help and support.

Best Regards,
Re: OCL Validation outside of eclipse [message #1131580 is a reply to message #1131538] Thu, 10 October 2013 16:57 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4155
Registered: July 2009
Senior Member
Hi

Thanks for reporting back.

Ed

On 10/10/2013 17:18, Jean-Baptiste Guillois wrote:
> Hi Ed,
>
> Thanks a lot for your help, I indeed now get the correct diagnostic message.
> I have attached to this reply the final zipped version of my project as it might be usefull to other users of this forum.
>
> This topic is now resolved.
>
> Thx again for your help and support.
>
> Best Regards,
Previous Topic:Using OCL for creating (temporary) object
Next Topic:Debugging OCL constraints in UML profiles
Goto Forum:
  


Current Time: Fri Nov 28 23:20:03 GMT 2014

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

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