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 09:12 Go to next message
Jean-Baptiste Guillois is currently offline Jean-Baptiste Guillois
Messages: 28
Registered: August 2011
Junior 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 10:03 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 3446
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 05:19 Go to previous messageGo to next message
Jean-Baptiste Guillois is currently offline Jean-Baptiste Guillois
Messages: 28
Registered: August 2011
Junior 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 09:07 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 3446
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 09:25 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 3446
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 09:58 Go to previous messageGo to next message
Jean-Baptiste Guillois is currently offline Jean-Baptiste Guillois
Messages: 28
Registered: August 2011
Junior 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 12:11 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 3446
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 12:47 Go to previous messageGo to next message
Jean-Baptiste Guillois is currently offline Jean-Baptiste Guillois
Messages: 28
Registered: August 2011
Junior 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 13:52 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 3446
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 14:57 Go to previous message
Jean-Baptiste Guillois is currently offline Jean-Baptiste Guillois
Messages: 28
Registered: August 2011
Junior 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,
Previous Topic:Forum Netiquette
Goto Forum:
  


Current Time: Mon Oct 07 10:09:18 EDT 2013

Powered by FUDForum. Page generated in 0.01851 seconds