Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » [OCL] ClassCastException for constraint on static profile
[OCL] ClassCastException for constraint on static profile [message #1713412] Tue, 03 November 2015 21:20 Go to next message
Johan Van Noten is currently offline Johan Van NotenFriend
Messages: 87
Registered: July 2009
Member
Environment: Mars.1 + Papyrus Today's nightly

The reproduction scenario below leads to a failing OCL constraint (ClassCastException).
I have been trying to correct it, but don't find a solution.
The issue is not specific to this OCL constraint, but rather to the concept: "configuring a static profile + OCL".
So the core question is: "What are the correct GenModel options to make sure that OCL constraints on my static profile are correctly evaluated?"

Tried:
* Same profile, but on dynamically applied --> works
* Read OCLinEcore documentation, but didn't provide a clue wrt this problem
* Internet search, seems not to be a frequent issue.
* Tried on Luna, same issue.

Scenario:
I list the steps I tried to come to my static profile, each step corresponds to a directory in the attached archive.
In order to reuse, please remove the .v0 etc extension from the dirs.

v0 - Just the profile, no genmodel yet
v1 - Add GenModel, default settings (only add base package and point model code to /src-gen), generate Model code, add static profile definition to the plugin.xml
Code: MyClassImpl seems to have "if (false)" code.
Runtime: No validation happens
v2 - Reload GenModel, set Validation Delegates = Process.
Code: no change
Runtime: no change
v3 - Reload GenModel, set Invocation Delegates = Process.
Code: MyClassImpl now contains "return MyProfileValidator.validate(...". Seems real validation code.
Runtime: Model validation error...
An exception occurred while delegating evaluation of the 'Constraint1' invariant on 'MyClass':
java.lang.ClassCastException: org.eclipse.ocl.ecore.delegate.OCLValidationDelegateFactory$Global
cannot be cast to org.eclipse.ocl.pivot.internal.delegate.ValidationDelegate$Factory

The attachment also contains a test-project com.ecme.sandbox which is to be imported in the runtime environment (as usual for static profiles).

Thanks,
Johan
Re: [OCL] ClassCastException for constraint on static profile [message #1713817 is a reply to message #1713412] Fri, 06 November 2015 17:02 Go to previous messageGo to next message
Johan Van Noten is currently offline Johan Van NotenFriend
Messages: 87
Registered: July 2009
Member
Update... There is a mistake in the post I will correct it asap. In the meantime, put it on hold.
Re: [OCL] ClassCastException for constraint on static profile [message #1713830 is a reply to message #1713817] Fri, 06 November 2015 18:44 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5843
Registered: July 2009
Senior Member
Hi

Thanks; one less job to try to get done this weekend.

Regards

Ed Willink


On 06/11/2015 17:02, Johan Van Noten wrote:
> Update... There is a mistake in the post I will correct it asap. In
> the meantime, put it on hold.
Re: [OCL] ClassCastException for constraint on static profile [message #1714295 is a reply to message #1713830] Wed, 11 November 2015 13:56 Go to previous messageGo to next message
Johan Van Noten is currently offline Johan Van NotenFriend
Messages: 87
Registered: July 2009
Member
Ok, post "revised"...

Forget about the original reproduction scenario.
Here a newer and clearer version.
Two attachments:
* com.ecme.myprofile.zip: a project containing the profile definition
* com.ecme.sandbox.zip: a project for the runtime

Scenario:
* Open the first project in Eclipse
It defines a static profile, including its generated code.
* Run "Run As - new Eclipse Application" with default settings
* Import the second project
* Open the included model.
* Validate the model

Result:
The Model Validation tab shows one validation error:
An exception occurred while delegating evaluation of the 'Constraint1' invariant on 'MyClass': java.lang.ClassCastException: org.eclipse.ocl.ecore.delegate.OCLValidationDelegateFactory$Global cannot be cast to org.eclipse.ocl.pivot.internal.delegate.ValidationDelegate$Factory

Current analysis:
This could be due to a mistake in my genmodel settings. I don't really now which settings would be necessary to get PivotOCL based validations for my static profile. I don't find good documentation about the effects of these options.

Alternatives using the Papyrus DSML Validation seem to work fine but are somewhat more cumbersome.

Thanks,
Johan
Re: [OCL] ClassCastException for constraint on static profile [message #1714595 is a reply to message #1714295] Fri, 13 November 2015 17:57 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5843
Registered: July 2009
Senior Member
Hi

Thanks for the repro.

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

Regards

Ed Willink

On 11/11/2015 13:56, Johan Van Noten wrote:
> Ok, post "revised"...
>
> Forget about the original reproduction scenario.
> Here a newer and clearer version.
> Two attachments:
> * com.ecme.myprofile.zip: a project containing the profile definition
> * com.ecme.sandbox.zip: a project for the runtime
>
> Scenario:
> * Open the first project in Eclipse
> It defines a static profile, including its generated code.
> * Run "Run As - new Eclipse Application" with default settings
> * Import the second project
> * Open the included model.
> * Validate the model
>
> Result:
> The Model Validation tab shows one validation error:
> An exception occurred while delegating evaluation of the 'Constraint1' invariant on 'MyClass': java.lang.ClassCastException: org.eclipse.ocl.ecore.delegate.OCLValidationDelegateFactory$Global cannot be cast to org.eclipse.ocl.pivot.internal.delegate.ValidationDelegate$Factory
>
> Current analysis:
> This could be due to a mistake in my genmodel settings. I don't really now which settings would be necessary to get PivotOCL based validations for my static profile. I don't find good documentation about the effects of these options.
>
> Alternatives using the Papyrus DSML Validation seem to work fine but are somewhat more cumbersome.
>
> Thanks,
> Johan
>
Re: [OCL] ClassCastException for constraint on static profile [message #1716957 is a reply to message #1714295] Wed, 09 December 2015 10:00 Go to previous message
Ansgar Radermacher is currently offline Ansgar RadermacherFriend
Messages: 126
Registered: March 2011
Location: Paris Saclay, France
Senior Member
Please note that there are two different ways to add validation constraints and both involve a plugin with generated code (therefore, it is quite easy to confuse these two - I will improve the Papyrus documentation with respect to this aspect).

(1) Use the standard tooling with validation delegate in ecore & generated code. This is currently not working with OCL and produces the class cast exception in bug 482143

(2) Ignore the validation delegate and use the Papyrus DSML generator to generate a plugin with the constraints embedded into the plugin.xml. This is what we currently use for Papyrus-RT. Eventually, Papyrus might drop the support for this mechanism once the first one is fully working, but there are no concrete decisions yet and it will certainly still be supported in the near future.
Previous Topic:How to use Pivot OCL thread-safely?
Next Topic:Executing "ClassName.allInstances()" query on instances created using InstanceSpecificatio
Goto Forum:
  


Current Time: Thu Apr 26 08:01:47 GMT 2018

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

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