Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » UI Dependency Problem of emf.Diagnostics (instance models with OCL Pivot constraints)
UI Dependency Problem of emf.Diagnostics (instance models with OCL Pivot constraints) [message #994527] Thu, 27 December 2012 10:36 Go to next message
Tobias Lutz is currently offline Tobias Lutz
Messages: 16
Registered: April 2012
Junior Member
Hello,

im not quite sure if this is an xtext or ocl problem.
I already found a similar problem at http://www.eclipse.org/forums/index.php/t/245264/
but it's from last year.

I also want to run some stuff in an headless junit-plugin-test and check my model if it's valid withing the following method:
//org.eclipse.emf.common.util.Diagnostic
	private static boolean modelIsValid(EObject model){
		 Diagnostic modelValidity = Diagnostician.INSTANCE.validate(model);
		 if(modelValidity.getSeverity() == Diagnostic.OK){
			 return true;
		 }else {
			 jlog.log(Level.SEVERE, "Loaded Model "+ model +"is invalid!");
			 return false;
		 }}


The problem is that there are some errors thrown when calling this at line 1 "Diagnostician.INSTANCE.validate(model);" saying that Guice couldn't create some ui stuff.
Im loading the model like the following way:
registerNecessaryMetaModelPackages(); // all required Packages are registered here
resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
resource = resourceSet.createResource(URI.createPlatformPluginURI("/projectName/folderpath/model.extension", true));
resource.load(null);
EcoreUtil.resolveAll(resource);
EObject model = resource.getContents().get(0);
if(modelIsValid(model)){


I figured out that this error only appears if i load a instance model of a metamodel with ocl constrains (pivot).
Loading a constraint free instancemodel or a metamodel works.

[Updated on: Thu, 27 December 2012 10:38]

Report message to a moderator

Re: UI Dependency Problem of emf.Diagnostics [message #994581 is a reply to message #994527] Thu, 27 December 2012 13:38 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4032
Registered: July 2009
Senior Member
Hi

You neglect to provide details that make it possible to provide a
sensible answer.

"saying that Guice couldn't create some ui stuff"

So what was the stack trace?

"registerNecessaryMetaModelPackages(); // all required Packages are registered here"

clearly something is not correctly registered so it is not adequate to assume you know what to do.

"headless junit-plugin-test"

this is potentially a contradiction. Is OSGI running or not?

"i load a instance model of a metamodel with ocl constrains (pivot)"

How? what OCL? how is the pivot relevant?

Generally you will save everyone a lot of time by creating a simple zipped repro project with a launch configuration.

Regards

Ed Willink



On 27/12/2012 15:36, Tobias Lutz wrote:
> Hello,
>
> im not quite sure if this is an xtext or ocl problem.
> I already found a similar problem at http://www.eclipse.org/forums/index.php/t/245264/
> but it's from last year.
>
> I also want to run some stuff in an headless junit-plugin-test and check my model if it's valid withing the following method:
>
> //org.eclipse.emf.common.util.Diagnostic
> private static boolean modelIsValid(EObject model){
> Diagnostic modelValidity = Diagnostician.INSTANCE.validate(model);
> if(modelValidity.getSeverity() == Diagnostic.OK){
> return true;
> }else {
> jlog.log(Level.SEVERE, "Loaded Model "+ model +"is invalid!");
> return false;
> }}
>
> The problem is that there are some errors thrown when calling this at line 1 "Diagnostician.INSTANCE.validate(model);" saying that Guice couldn't create some ui stuff.
> Im loading the model like the following way:
>
> registerNecessaryMetaModelPackages(); // all required Packages are registered here
> resourceSet = new ResourceSetImpl();
> resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
> resource = resourceSet.createResource(URI.createPlatformPluginURI("/projectName/folderpath/model.extension", true));
> resource.load(null);
> EcoreUtil.resolveAll(resource);
> EObject model = resource.getContents().get(0);
> if(modelIsValid(model)){
>
> I figured out that this error only appears if i load a instance model of a metamodel with ocl constrains (pivot).
> Loading a constraint free instancemodel or a metamodel works.
Re: UI Dependency Problem of emf.Diagnostics [message #994942 is a reply to message #994581] Fri, 28 December 2012 12:29 Go to previous messageGo to next message
Tobias Lutz is currently offline Tobias Lutz
Messages: 16
Registered: April 2012
Junior Member
Ok here we go, it took me some time to create a simple running example but much longer whats causing the error.
The projects are attacked below.

There are 4 but only the com.test and com.test.model is relevant where the model project contains the ecore and instance model with some more or less usefull ocl constraints.

the test model includes the launch config for plugin tests which should be just executed to see the error that happens when the instance model gets validated during the loading method.

What I currentlcy use as software is:
eclipse juno sr1
ocl keppler m3 ( OCL All-In-One SDK 4.1.0.v20121114-1028
OCL End User SDK 4.1.0.v20121114-1028
OCL Examples and Editors 3.3.0.v20121114-1028 )

Honestly I think I know what I need to register. These are only the required model packages:
EcorePackage.eINSTANCE.eClass();
ExamplePackage.eINSTANCE.eClass();

And why is running junit-plugin-tests headless a contradiction? You can set the mode to headless there is no problem.

The stack trace is attached in my first post of this topic.

regards.
  • Attachment: example.zip
    (Size: 143.15KB, Downloaded 94 times)
Re: UI Dependency Problem of emf.Diagnostics [message #995159 is a reply to message #994942] Sat, 29 December 2012 03:09 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4032
Registered: July 2009
Senior Member
Hi

Firstly apologies, I missed the stacktrace in your first post, which
certainly shows a strange UI dependency.

However I needed the repro to investigate.

Both your tests show UI problems, one on Display and the other on Workbench.

The problem is probably caused by reflective code that tests for the
presence of particular plugins to determine whether Eclipse platform
facilities are available. It would appear that such reflective use fails
to perform the correct OSGI plugin activation.

The attached launch configuration makes only the necessary plugins
available so that the UI facilities are genuinely not available. Your
tests then run without troubling the console output.

You could raise the 'Display' activation as an e4 issue or the
'Workbench' activation as an Xtext issue, but I suspect that both teams
may take the view that: if you don't want UI code, don't put it on the
classpath.

Regards

Ed Willink


On 28/12/2012 17:29, Tobias Lutz wrote:
> Ok here we go, it took me some time to create a simple running example but much longer whats causing the error.
> The projects are attacked below.
>
> There are 4 but only the com.test and com.test.model is relevant where the model project contains the ecore and instance model with some more or less usefull ocl constraints.
>
> the test model includes the launch config for plugin tests which should be just executed to see the error that happens when the instance model gets validated during the loading method.
>
> What I currentlcy use as software is:
> eclipse juno sr1
> ocl keppler m3 ( OCL All-In-One SDK 4.1.0.v20121114-1028
> OCL End User SDK 4.1.0.v20121114-1028
> OCL Examples and Editors 3.3.0.v20121114-1028 )
>
> Honestly I think I know what I need to register. These are only the required model packages:
> EcorePackage.eINSTANCE.eClass();
> ExamplePackage.eINSTANCE.eClass();
>
> And why is running junit-plugin-tests headless a contradiction? You can set the mode to headless there is no problem.
>
> The stack trace is attached in my first post of this topic.
>
> regards.
>
Re: UI Dependency Problem of emf.Diagnostics [message #995240 is a reply to message #995159] Sat, 29 December 2012 08:57 Go to previous messageGo to next message
Tobias Lutz is currently offline Tobias Lutz
Messages: 16
Registered: April 2012
Junior Member
Hey Ed,

thank you for your help.
I totally forgot to deactivate the plugins like *.edit and *.editor and the unnecessarytarget platform plugins. That thrown errors realy let me assume that it's an dependency error of the validate method.
I just though even if there are no ui dependencies and run a default plugin-tests in headless mode that no unnecessary target plugins load.

Ofcourse if all ui dependencies are removed the tests work without problems.
So there is no reason to raise an issue.

Regards
Re: UI Dependency Problem of emf.Diagnostics (instance models with OCL Pivot constraints) [message #995279 is a reply to message #994527] Sat, 29 December 2012 11:20 Go to previous messageGo to next message
Tobias Lutz is currently offline Tobias Lutz
Messages: 16
Registered: April 2012
Junior Member
Hi again,

I figured out that the validate method sets the Diagnostic severity value always to "Error (4)" even if the model is valid which can be validated via the sample reflective editor.

Is there any other plugin required that the validate method works correctly or did I use it wrong?

Regards
Re: UI Dependency Problem of emf.Diagnostics (instance models with OCL Pivot constraints) [message #995289 is a reply to message #995279] Sat, 29 December 2012 11:56 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4032
Registered: July 2009
Senior Member
Hi

That doesn't seem right, but the Sample Reflective Ecore editor may not
have the Complete OCL loaded or ... Again I don't know waht you are
doing accurately enough.

The OCL Documentation has a variety of clues on this search for "warning".

Regards

Ed Willink


On 29/12/2012 16:20, Tobias Lutz wrote:
> Hi again,
>
> I figured out that the validate method sets the Diagnostic severity
> value always to "Error (4)" even if the model is valid which can be
> validated via the sample reflective editor.
>
> Is there any other plugin required that the validate method works
> correctly or did I use it wrong?
>
> Regards
Re: UI Dependency Problem of emf.Diagnostics (instance models with OCL Pivot constraints) [message #995333 is a reply to message #995289] Sat, 29 December 2012 14:44 Go to previous messageGo to next message
Tobias Lutz is currently offline Tobias Lutz
Messages: 16
Registered: April 2012
Junior Member
Well,

what I want to do should be quite simple:
Run some Junit-Plugin-Tests in headless mode where some models (meta models or instance models) with ocl-constraints are loaded and shall be validated.

The validation for .ecore models works as assumed correct and also for instance models without any ocl constraints. But not for instance models with ocl constraints as the "ClassA.xmi" model in the example.

For those models the severity value is always set to "error" even if the validation withing an eclipse runtime or via the sample reflective editor works also.

So I think it should be a problem that there is a plugin missing for the evaluation of models or any other problem in the launch configuration but no error is thrown.

I figured out that the severity lvl gets changed from 0 = "OK" to 4 = "Error" at generated Validator "ExampleValidator" exactly at the place where the defined OCL-Invariant gets checked.

Re: UI Dependency Problem of emf.Diagnostics (instance models with OCL Pivot constraints) [message #995340 is a reply to message #995333] Sat, 29 December 2012 15:14 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4032
Registered: July 2009
Senior Member
Hi

Perhaps, but since you don't provide a list of plugins it's difficult to
tell which one is missing, and even if you did my insight is not unlimited.

Providing a repro enables me to see what you are actually doing, rather
than guessing according to hints that you provide.

Did you learn nothing from earlier in this thread? It was only the repro
that revealed the true problem.

Regrads

Ed Willink


On 29/12/2012 19:44, Tobias Lutz wrote:
> Well,
>
> what I want to do should be quite simple:
> Run some Junit-Plugin-Tests in headless mode where some models (meta
> models or instance models) with ocl-constraints are loaded and shall
> be validated.
>
> The validation for .ecore models works as assumed correct and also for
> instance models without any ocl constraints. But not for instance
> models with ocl constraints as the "ClassA.xmi" model in the example.
>
> For those models the severity value is always set to "error" even if
> the validation withing an eclipse runtime or via the sample reflective
> editor works also.
>
> So I think it should be a problem that there is a plugin missing for
> the evaluation of models or any other problem in the launch
> configuration but no error is thrown.
>
> I figured out that the severity lvl gets changed from 0 = "OK" to 4 =
> "Error" at generated Validator "ExampleValidator" exactly at the place
> where the defined OCL-Invariant gets checked.
>
>
Re: UI Dependency Problem of emf.Diagnostics (instance models with OCL Pivot constraints) [message #995351 is a reply to message #995340] Sat, 29 December 2012 16:00 Go to previous messageGo to next message
Tobias Lutz is currently offline Tobias Lutz
Messages: 16
Registered: April 2012
Junior Member
Hi,

acutally it's nothing else than I already provided and your launch config where i removed the unnecessary ui-plugins of mine and from the target platform.
So it's absolutely the same example. What else could I provide?

Regards
Re: UI Dependency Problem of emf.Diagnostics (instance models with OCL Pivot constraints) [message #995536 is a reply to message #995351] Sun, 30 December 2012 06:39 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4032
Registered: July 2009
Senior Member
Hi

OK, it's the same example, but you didn't tell me that before.

I don't know what to look at, so you could provide a JUnit test that
fails at the unexpected result.

Regards

Ed Willink

On 29/12/2012 21:00, Tobias Lutz wrote:
> Hi,
>
> acutally it's nothing else than I already provided and your launch config where i removed the unnecessary ui-plugins of mine and from the target platform.
> So it's absolutely the same example. What else could I provide?
>
> Regards
Re: UI Dependency Problem of emf.Diagnostics (instance models with OCL Pivot constraints) [message #995573 is a reply to message #995536] Sun, 30 December 2012 09:17 Go to previous messageGo to next message
Tobias Lutz is currently offline Tobias Lutz
Messages: 16
Registered: April 2012
Junior Member
Hi,

I modified the files that its more precise.
The Test-Case fails now when you run the launch configuration com.test.launch in the com.test project.

Some further explanation:
There are two ocl constraints withing the metamodel example.ecore in the com.test.model project:

invariant diffNames: not refB.name->includes(name);
invariant uniqueName: self.refB->isUnique(name);


So after generating the model files with the example.genmodel generator model a Class ExampleValidator.java is generated to the com.test.model project that is called to evaluate the model's validity. (Implicit via the Diagnostician's validate methode so not by my tests)

Both models (example.ecore and classA.xmi) are valid.
But the Diagnostician.INSTANCE.validate(model) method evaluates the instance model with the ocl constraints to have some error during the tests so that the model is invalid.
That should not happen.
The Problem is the com.test project com.test.util package inthe ModelLoader class at line 47.

I hope this is specific enough.

Regards

  • Attachment: example.zip
    (Size: 42.03KB, Downloaded 79 times)
Re: UI Dependency Problem of emf.Diagnostics (instance models with OCL Pivot constraints) [message #995875 is a reply to message #995573] Mon, 31 December 2012 06:12 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4032
Registered: July 2009
Senior Member
Hi

You will find it more helpful if you look at all your diagnostics. EMF
Validate returns a parent with multiple children thus:

public static boolean modelIsValid(EObject model){
Diagnostic modelValidity =
Diagnostician.INSTANCE.validate(model); //Sets serverity value to 4 but
it should be 0, when validating ocl constriants
if(modelValidity.getSeverity() == Diagnostic.OK){
return true;
}else {
StringBuilder s = new StringBuilder();
s.append(modelValidity.getChildren().size() + " validation
errors");
for (Diagnostic child : modelValidity.getChildren()){
s.append("\n ");
s.append(child.getMessage());
}
TestCase.fail(s.toString());
return false;
}
}

This will reveal a CCE where the internal *.essentialocl containing the
expression is created as an XMIResource rather than an Xtext
EssentiaOCLCSResource.
(This is clearly a point of common user trouble so I'll change the
default CCE to something explicit.)

The wrong resource class is because the EssentialOCL plugin has not been
started and so *.essentialocl has not been registered as an Xtext resource.

If you add "EssentialOCLStandaloneSetup.doSetup();" to your test, the
problem goes away.

You are using a JUnit configuration that I've never used. "[No
application] - Headless Mode"

I either run standalone JUnit tests (no platform)
or JUnit Plugin tests (with platform "org.eclipse.sdk.ide")

Your configuration seems to be confusingly between the two.
Platform.isRunning() returns true, but the platform is not starting the
plugins properly. If you want to use your hybrid test you'll need to
find out how to not have a platform or how to ensure that the platform
starts.

Currently the problem only goes away if assertions are disabled. If you
enable them (-ea to the VM) EssentialOCLStandaloneSetup.doSetup() bombs
because it ensures that the Xtext API that doSteup is not called on
running platforms is honoured.

Regards

Ed Willink

On 30/12/2012 14:17, Tobias Lutz wrote:
> Hi,
>
> I modified the files that its more precise.
> The Test-Case fails now when you run the launch configuration com.test.launch in the com.test project.
>
> Some further explanation:
> There are two ocl constraints withing the metamodel example.ecore in the com.test.model project:
>
>
> invariant diffNames: not refB.name->includes(name);
> invariant uniqueName: self.refB->isUnique(name);
>
>
> So after generating the model files with the example.genmodel generator model a Class ExampleValidator.java is generated to the com.test.model project that is called to evaluate the model's validity. (Implicit via the Diagnostician's validate methode so not by my tests)
>
> Both models (example.ecore and classA.xmi) are valid.
> But the Diagnostician.INSTANCE.validate(model) method evaluates the instance model with the ocl constraints to have some error during the tests so that the model is invalid.
> That should not happen.
> The Problem is the com.test project com.test.util package inthe ModelLoader class at line 47.
>
> I hope this is specific enough.
>
> Regards
>
>
Re: UI Dependency Problem of emf.Diagnostics (instance models with OCL Pivot constraints) [message #996522 is a reply to message #995875] Wed, 02 January 2013 04:25 Go to previous messageGo to next message
Tobias Lutz is currently offline Tobias Lutz
Messages: 16
Registered: April 2012
Junior Member
Hi,

I agree. But should in this case not at least be given a warning/error message instead of just evaluating the model to be invalid?
My expectation was just that if there are only dependencies to ui undependent plugins there is no ui stuff required that come implicit along with the EssentialOCLSetup and the "org.eclipse.sdk.ide".

But for now I choose the way with the "org.eclipse.sdk.ide".

Thanks and regards
Re: UI Dependency Problem of emf.Diagnostics (instance models with OCL Pivot constraints) [message #996535 is a reply to message #996522] Wed, 02 January 2013 05:05 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4032
Registered: July 2009
Senior Member
Hi

The new Pivot-based OCL has a rich 'invalid' that wraps a Java exception
stack trace so that the recipient of 'invalid' can be more informative.

Regards

Ed Willink


On 02/01/2013 09:25, Tobias Lutz wrote:
> Hi,
>
> I agree. But should in this case not at least be given a warning/error
> message instead of just evaluating the model to be invalid?
> My expectation was just that if there are only dependencies to ui
> undependent plugins there is no ui stuff required that come implicit
> along with the EssentialOCLSetup and the "org.eclipse.sdk.ide".
>
> But for now I choose the way with the "org.eclipse.sdk.ide".
>
> Thanks and regards
Previous Topic:UMLPrimitiveType int x OCL UnlimitedNatural
Next Topic:OCLinEcore - UI Dependency?
Goto Forum:
  


Current Time: Wed Aug 27 11:10:20 EDT 2014

Powered by FUDForum. Page generated in 0.03342 seconds