Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 452162

Summary: [OCLInEcore] Editor unusable in Luna SR1
Product: [Modeling] OCL Reporter: Adolfo Sanchez-Barbudo Herrera <adolfosbh>
Component: CoreAssignee: OCL Inbox <mdt-ocl-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ed
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Screenshot with NPE
none
Luna SR0 Installation Details
none
Luna SR1 details
none
Luna SR1 + workaround installation details
none
Bad configuration log
none
OK configuration log
none
Installation details of the working setup none

Description Adolfo Sanchez-Barbudo Herrera CLA 2014-11-18 13:20:49 EST
Louis pointed me out a problem which I've been able to reproduce.

Installation: Luna Modelling SR1 + OCL Examples.

Steps:
- Crate a new "OCLinEcore Ecore File".
- Play around with the editor and you will soon get an NPE from the "XtextReconcilerJob". (screenshot coming soon)
- This makes the editor unusable.

If I install the complete Xtext SDK afterwards, I can't reproduce the NPE.

The error log indicates that the issue is related to Xtext code. Without further investigation I presume that, we are missing some Xtext plugin/s - present when installing the SDK- which, without it/them, is causing us some bad behaviour. That's quite weird though, because any plugin we need should appear as a dependency in the generated code of our editors. Perhaps that's new bit, and our editors haven't been regenerated ?

Anyway it's just speculation, it needs investigation... 

I'll also try to reproduce in Luna SR0.
Comment 1 Adolfo Sanchez-Barbudo Herrera CLA 2014-11-18 13:22:56 EST
Created attachment 248736 [details]
Screenshot with NPE
Comment 2 Adolfo Sanchez-Barbudo Herrera CLA 2014-11-18 13:28:51 EST
Created attachment 248737 [details]
Luna SR0 Installation Details

I can't reproduce this in Luna SR0
Comment 3 Adolfo Sanchez-Barbudo Herrera CLA 2014-11-18 13:32:07 EST
Created attachment 248738 [details]
Luna SR1 details

If I uninstall Xtext SDK feature, I obtain the exceptions again
Comment 4 Adolfo Sanchez-Barbudo Herrera CLA 2014-11-18 13:45:04 EST
Workaround rechecked: Install "Xtext Complete SDK".

I suggest an announce in the forum and a note in the new & noteworthy wiki page.
Comment 5 Ed Willink CLA 2014-11-18 15:32:55 EST
Not critical. I've never seen it and there is an SDK workaround.

It is not clear what version is actually a problem. Your only details are for OCL 5.0.0 which was superseded by 5.0.1 pre-release.

You'll see plenty of reconciler errors with Xtext so it is imperative to pin the versions down.

It is very undesirable to announce every eccentric annoyance on the forum.
Comment 6 Adolfo Sanchez-Barbudo Herrera CLA 2014-11-18 16:16:25 EST
Hi,

I strongly disagree.

You and myself didn´t notice it because we need Xtext SDK to develop.

I was told by a user who wanted to use the editor and he didn´t because it was unusable. I didn´t know any workaround: I had to investigate because at a first point it worked for me, and when I reproduced it, I had to figure out which one of the configurations of my Luna setup was what made the editor work again. End users are not so benevolent, they are either plenty-of-times users who try to notify the bug and/or figure out a straightforward workaround, or they revert back to the previous version waiting for a fix for SR2... which who knows if it will arrive giving your light reaction.

I´ll investigate the problem in my own. Given we are talking about one of the key features of the project, we can´t afford to have the problem again in Luna SR2.

(In reply to Ed Willink from comment #5)
> 
> It is not clear what version is actually a problem. Your only details are
> for OCL 5.0.0 which was superseded by 5.0.1 pre-release.
> 

Not sure what confussed you. There are some clues in the description:

(In reply to Adolfo Sanchez-Barbudo Herrera from comment #0)
> 
> Installation: Luna Modelling SR1 + OCL Examples.

Luna Modelling SR0 + OCL examples: the editor works.
Luna Modelling SR1 + OCL examples: the editor does NOT work.
Comment 7 Ed Willink CLA 2014-11-19 04:04:55 EST
(In reply to Adolfo Sanchez-Barbudo Herrera from comment #6)
> > Installation: Luna Modelling SR1 + OCL Examples.
> 
> Luna Modelling SR0 + OCL examples: the editor works.
> Luna Modelling SR1 + OCL examples: the editor does NOT work.

A problem like this needs precise versions. Luna SR1 is suggestive but does not make clear exactly which OCL, Xtext, Xtend-Lib, EMF, Platform versions are involved. Luna SR0 is vague since we had OCL 5.0.1 immediately. Xtext versions also move out of synchronism with the simrel, so is Luna SR1, Xtext 2.7.2 or 2.8.0? Does your workspace permit 'contact all sites?' to contact inappropriate contributions?

The original report suggested Xtext SDK was a workaround. I'm not clear quite what that means in terms of versions and plugins.

Also ensure that the repro does not have extraneous projects. See the OCL newsgroup "Re: Differences evaluating an OCL expression using Interactive OCL Console and xText Interactive Console. Is ther a bug?" message where it appears that probably Sirius 1.0.0, possibly Epsilon, possibly ??? is able to corrupt the operation of the Xtext OCL console.
Comment 8 Adolfo Sanchez-Barbudo Herrera CLA 2014-11-19 06:17:33 EST
Hi,

[I had already sent screenshoots with the installation details >.<]

My apologies. I thought it was straightforward. 

When I mention "Luna Modelling SR1 + OCL examples" I mean:
- A fresh Luna SR1 installation (I must add, I'm using windows 64, although original user had a Mac, so it shouldn't be a weird OS specific issue)
- "OCL Examples and Editors SDK" installed from the luna repository (Help -> Install New Software -> Work with: "http://download.eclipse.org/releases/luna/") 

If you needed some numbers, you might have a look to the screenshots I attached yesterday.

When I mentioned install "Xtext Complete SDK" I meant:
- "Xtext Complete SDK" installed from the luna repository (Help -> Install New Software -> Work with: "http://download.eclipse.org/releases/luna/" )

I'll attach a new screenshot for the setup with the workaround, which hopefully will help...
Comment 9 Adolfo Sanchez-Barbudo Herrera CLA 2014-11-19 06:21:55 EST
Created attachment 248747 [details]
Luna SR1 + workaround installation details
Comment 10 Ed Willink CLA 2014-11-19 07:13:02 EST
Created attachment 248752 [details]
Bad configuration log

The repro

Unzip eclipse-modeling-luna-SR1-win32-x86_64.zip
Install New Software from the default luna repo for OCL Examples and Editors
Restart
New Project, Examples, OCLinEcotre tuturial
edit a couple of characters, NPE stack trace below

Configuration Log attached

An internal error occurred during: "XtextReconcilerJob".

java.lang.NullPointerException
	at org.eclipse.xtext.ui.editor.DirtyStateEditorSupport.getResourceDescriptionManager(DirtyStateEditorSupport.java:496)
	at org.eclipse.xtext.ui.editor.DirtyStateEditorSupport.announceDirtyState(DirtyStateEditorSupport.java:466)
	at org.eclipse.xtext.ui.editor.reconciler.XtextDocumentReconcileStrategy.postParse(XtextDocumentReconcileStrategy.java:160)
	at org.eclipse.xtext.ui.editor.reconciler.XtextDocumentReconcileStrategy.doReconcile(XtextDocumentReconcileStrategy.java:146)
	at org.eclipse.xtext.ui.editor.reconciler.XtextDocumentReconcileStrategy.reconcile(XtextDocumentReconcileStrategy.java:65)
	at org.eclipse.xtext.ui.editor.reconciler.XtextReconciler.doRun(XtextReconciler.java:401)
	at org.eclipse.xtext.ui.editor.reconciler.XtextReconciler.access$3(XtextReconciler.java:386)
	at org.eclipse.xtext.ui.editor.reconciler.XtextReconciler$1.process(XtextReconciler.java:327)
	at org.eclipse.xtext.ui.editor.reconciler.XtextReconciler$1.process(XtextReconciler.java:1)
	at org.eclipse.xtext.util.concurrent.IUnitOfWork$Void.exec(IUnitOfWork.java:36)
	at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.modify(XtextDocument.java:418)
	at org.eclipse.xtext.ui.editor.model.XtextDocument.internalModify(XtextDocument.java:131)
	at org.eclipse.xtext.ui.editor.reconciler.XtextReconciler.run(XtextReconciler.java:324)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Comment 11 Ed Willink CLA 2014-11-19 07:18:48 EST
Created attachment 248754 [details]
OK configuration log

Indeed. Installing "Xtext Complete SDK" causes the problem to go away.

Corresponding confuguration log attached.
Comment 12 Ed Willink CLA 2014-11-19 07:28:08 EST
The workaround adds

Features:
org.eclipse.xtend.sdk (2.7.2.v201409160908) "Xtend IDE"
org.eclipse.xtext.docs (2.7.2.v201409160908) "Xtext Documentation "
org.eclipse.xtext.sdk (2.7.2.v201409160908) "Xtext "
org.eclipse.xtext.ui (2.7.2.v201409160908) "Xtext UI Core "
org.eclipse.xtext.xbase (2.7.2.v201409160908) "Xbase Model "
org.eclipse.xtext.xbase.lib (2.7.2.v201409160908) "Xbase Runtime Library"
org.eclipse.xtext.xtext.ui (2.7.2.v201409160908) "Xtext Xtext UI "

Plugins:
org.eclipse.emf.mwe2.language (2.7.0.v201409021051) "Modeling Workflow Engine 2 Language" [Starting]
org.eclipse.emf.mwe2.language.ui (2.7.0.v201409021051) "Modeling Workflow Engine 2 Language UI" [Starting]
org.eclipse.emf.mwe2.launch (2.7.0.v201409021051) "Modeling Workflow Engine 2 Launch" [Resolved]
org.eclipse.xpand (2.0.0.v201406030414) "Xpand Core" [Resolved]
org.eclipse.xtend.core (2.7.2.v201409160908) "Xtend Core" [Starting]
org.eclipse.xtend.doc (2.7.2.v201409160908) "Xtend Documentation" [Starting]
org.eclipse.xtend.examples (2.7.2.v201409160908) "Xtend Examples" [Starting]
org.eclipse.xtend.ide (2.7.2.v201409160908) "Xtend IDE" [Starting]
org.eclipse.xtend.m2e (2.7.2.v201409160908) "Xtend m2e Integration" [Resolved]
org.eclipse.xtend.standalone (2.7.2.v201409160908) "Xtend Standalone Bundle" [Resolved]
org.eclipse.xtend2.lib (2.7.2.v201409160908) "Old Xtend 2 lib (Deprecated, use org.eclipse.xtend.lib instead)" [Resolved]
org.eclipse.xtext.activities (2.7.2.v201409160908) "Xtext UI Activities" [Resolved]
org.eclipse.xtext.builder.standalone (2.7.2.v201409160908) "Xtext Standalone Builder" [Starting]
org.eclipse.xtext.common.types.shared (2.7.2.v201409160908) "Common Types Shared State" [Active]
org.eclipse.xtext.common.types.shared.jdt38 (2.7.2.v201409160908) "Common Types Shared State (JDT 3.8)" [Resolved]
org.eclipse.xtext.doc (2.7.2.v201409160908) "Xtext Documentation" [Starting]
org.eclipse.xtext.ecore (2.7.2.v201409160908) "Xtext Ecore Support" [Active]
org.eclipse.xtext.generator (2.7.2.v201409160908) "Xtext Generator" [Starting]
org.eclipse.xtext.junit (2.7.2.v201409160908) "Xtext Junit Support (Deprecated, use org.eclipse.xtext.junit4 instead)" [Resolved]
org.eclipse.xtext.junit4 (2.7.2.v201409160908) "Xtext Junit4 Support" [Resolved]
org.eclipse.xtext.logging (1.2.15.v201409160908) "Xtext log4j fragment" [Resolved]
org.eclipse.xtext.m2e (2.7.2.v201409160908) "Xtext m2e Integration" [Resolved]
org.eclipse.xtext.purexbase (2.7.2.v201409160908) "org.eclipse.xtext.purexbase" [Starting]
org.eclipse.xtext.purexbase.ui (2.7.2.v201409160908) "org.eclipse.xtext.purexbase.ui" [Starting]
org.eclipse.xtext.ui.codetemplates (2.7.2.v201409160908) "Xtext Ecore Ui Support" [Starting]
org.eclipse.xtext.ui.codetemplates.ui (2.7.2.v201409160908) "Xtext Ecore Ui Support" [Starting]
org.eclipse.xtext.ui.ecore (2.7.2.v201409160908) "Xtext Ecore Ui Support" [Active]
org.eclipse.xtext.ui.junit (2.7.2.v201409160908) "Xtext Junit UI Support" [Starting]
org.eclipse.xtext.ui.shared (2.7.2.v201409160908) "Xtext UI Shared" [Active]
org.eclipse.xtext.xbase (2.7.2.v201409160908) "Xbase Model" [Starting]
org.eclipse.xtext.xbase.junit (2.7.2.v201409160908) "Xbase Junit support" [Resolved]
org.eclipse.xtext.xbase.ui (2.7.2.v201409160908) "Xbase UI" [Active]
org.eclipse.xtext.xtext.ui (2.7.2.v201409160908) "Xtext Xtext UI" [Starting]
org.eclipse.xtext.xtext.ui.examples (2.7.2.v201409160908) "Xtext Examples" [Starting]
org.eclipse.xtext.xtext.ui.graph (2.7.2.v201409160908) "Xtext Railroad Diagram Plugin" [Starting]

*shared or *lib are most likely to have hidden dependencies.
Comment 13 Adolfo Sanchez-Barbudo Herrera CLA 2014-11-19 07:30:23 EST
The method which causes the exception is deprecated in Mars:

/**
  * @since 2.7
  */
@Deprecated
// use getResourceDescriptionManagerIfOwnLanguage(XtextResource)
protected IResourceDescription.Manager getResourceDescriptionManager(URI resourceURI) {
   return resourceServiceProviderRegistry.getResourceServiceProvider(resourceURI).get(DirtyStateResourceDescription.Manager.class);
}

The replacement now does a check, so NPE are not sent anymore (at least at that point):

/**
  * @since 2.8
  */
protected IResourceDescription.Manager getResourceDescriptionManagerIfOwnLanguage(XtextResource resource) {
  IResourceServiceProvider rsp = resourceServiceProviderRegistry.getResourceServiceProvider(resource.getURI());
  if (rsp == null)
    return null;
  ...
}

I've not checked if there is similar fix backported to Luna. More importantly, what changed to suddenly make the problem appear in Luna SR1 ?...

Time to download Xtext Git repo.... I guess that now you are looking at this, let me know if you want me to go further or just you want to go on the investigations.
Comment 14 Ed Willink CLA 2014-11-19 07:56:06 EST
(In reply to Adolfo Sanchez-Barbudo Herrera from comment #13)
> The method which causes the exception is deprecated in Mars:

>    return
> resourceServiceProviderRegistry.getResourceServiceProvider(resourceURI).
> get(DirtyStateResourceDescription.Manager.class);


> I've not checked if there is similar fix backported to Luna. More
> importantly, what changed to suddenly make the problem appear in Luna SR1
> ?...

The workaround clearly arranges for resourceServiceProviderRegistry.getResourceServiceProvider(resourceURI) to not return null.

Once we understand how to encourage that we can make the problem go away.

One option is to have dependencies on whichever Xtext plugins solve the problem.

Another option is a custom resourceServiceProviderRegistry that doesn't return null.

Possibly the problem is a confusion between *.ecore and *.ecore.oclas and *.oclinecore URIs.
Comment 15 Ed Willink CLA 2014-11-19 08:02:00 EST
Bug 298601 looks very smelly.

"Manager manager = resourceServiceProvider.getResourceDescriptionManager();

we have a NullPointerException.

In my opinion the builder should not care about non Xtext resources."

Maybe installing more of Xtext converted a 'non-Xtext' resource to an Xtext one.

Adolfo: If you're already set up to see the NPE, can you tell what the resourceURI was?
Comment 16 Adolfo Sanchez-Barbudo Herrera CLA 2014-11-19 08:24:48 EST
(In reply to comment #15)
> 
> Adolfo: If you're already set up to see the NPE, can you tell what the
> resourceURI was?
.ecore . The one corresponding to the file which is edited.
Comment 17 Adolfo Sanchez-Barbudo Herrera CLA 2014-11-19 08:36:51 EST
(In reply to comment #16)
> (In reply to comment #15)
> >
> > Adolfo: If you're already set up to see the NPE, can you tell what the
> > resourceURI was?
> .ecore . The one corresponding to the file which is edited.

might xbase the SDK component which makes .ecore resource be an "Xtext resource".

Things pending to discover:
a) What changed in Xtext in SR1 to make the issue arise.
b) Check if the issue is already fixed for SR2.

I could quickly check b) by adding the maintenance repo URI and update my SR1 + OCL Examples installation. For a) I'd need to download Xtext GIT repo and further investigation. I'll start with the former
Comment 18 Ed Willink CLA 2014-11-19 08:45:51 EST
(In reply to Adolfo Sanchez-Barbudo Herrera from comment #17)
> (In reply to comment #16)
> > (In reply to comment #15)
> > >
> > > Adolfo: If you're already set up to see the NPE, can you tell what the
> > > resourceURI was?
> > .ecore . The one corresponding to the file which is edited.
> 
> might xbase the SDK component which makes .ecore resource be an "Xtext
> resource".

Sort of. The two scenarios differ with respect to the availability of a *.ecore registration for the org.eclipse.xtext.resource.impl.ResourceServiceProviderRegistryImpl$InternalData.
Comment 19 Ed Willink CLA 2014-11-19 09:13:14 EST
org.eclipse.xtext.ui.ecore is where the plugin extension point is that would declare *.ecore.

Simplest fix is probably to define an org.eclipse.ocl.examples.xtext.oclinecore.ui dependency on org.eclipse.xtext.ui.ecore and let P2 sort out the rest.
Comment 20 Adolfo Sanchez-Barbudo Herrera CLA 2014-11-19 09:29:30 EST
I presume that Xtext 2.7.3 (at least) will be the contribution for Luna SR2.

What I did:
- Install the Xtext "Redistributable" from the luna repo (with this feature in the installation, the issue still arises)
- Download the last nightly 2.7.3 update site from their downloads [1]
- Update the Redistributable feature from 2.7.2 to 2.7.3.
- The exception doesn't happen any more and the editor is usable again.

I presume we don't have to do anything to have this fixed for Luna SR2. Perhaps:
- Confirm with Xtext guys that they will contribute 2.7.3 to Luna SR2.
- Ideally try to create a test case in our infrastructure so we can notice this kind critical bugs in time. I'm not experienced with those UI based tests.
- I feel the need to suggest again: an announce for Luna SR1 users about the workaround.

[1] https://www.eclipse.org/modeling/tmf/downloads/

[Coincidentally, Xtext 2.7.3 was released today]
Comment 21 Adolfo Sanchez-Barbudo Herrera CLA 2014-11-19 09:32:57 EST
Created attachment 248757 [details]
Installation details of the working setup
Comment 22 Ed Willink CLA 2014-11-24 10:41:52 EST
Fixed in 5.0.3 which provides an explicit import for the org.eclipse.xtext.ui.ecore plugin whose registration avoids the NPE.

No fix needed for Mars since the bug is also fixed in Xtext 2.7.3/2.8.0 so no rational Mars installation should be affected.