Bug 521294 - NPE when use Operation "Open Dialog" in Tree Representation
Summary: NPE when use Operation "Open Dialog" in Tree Representation
Status: CLOSED FIXED
Alias: None
Product: Sirius
Classification: Modeling
Component: Tree (show other bugs)
Version: 5.0.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 5.1.0   Edit
Assignee: Florian Barbin CLA
QA Contact: Julien Dupont CLA
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2017-08-23 04:39 EDT by M V CLA
Modified: 2017-11-08 03:37 EST (History)
4 users (show)

See Also:


Attachments
vsp and testOpenDialogOp modeling project (11.36 KB, application/x-zip-compressed)
2017-08-28 10:23 EDT, Laurent Fasani CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description M V CLA 2017-08-23 04:39:55 EDT
In a tree Representation use "Create" Tool in this a "Create Instance" for this a "Open Dialog" Operation. The Open Dialog ends up with NPE. In Debug var task in the ModelOperationToTask class on line 169 is null on second call of this class.

!ENTRY org.eclipse.ui 4 0 2017-08-23 10:25:26.451
!MESSAGE Unhandled event loop exception
!STACK 0

java.lang.NullPointerException
	at org.eclipse.sirius.business.internal.helper.task.ModelOperationToTask.createTask(ModelOperationToTask.java:169)
	at org.eclipse.sirius.business.internal.helper.task.ExecuteToolOperationTask.createTask(ExecuteToolOperationTask.java:168)
	at org.eclipse.sirius.business.internal.helper.task.ExecuteToolOperationTask.createChildrenTasks(ExecuteToolOperationTask.java:149)
	at org.eclipse.sirius.business.internal.helper.task.ExecuteToolOperationTask.<init>(ExecuteToolOperationTask.java:98)
	at org.eclipse.sirius.business.api.helper.task.TaskHelper.buildTaskFromModelOperation(TaskHelper.java:105)
	at org.eclipse.sirius.tree.tools.internal.command.TreeCommandFactory.buildCommandFromModelOfTool(TreeCommandFactory.java:246)
	at org.eclipse.sirius.tree.tools.internal.command.TreeCommandFactory.buildCreateLineCommandFromTool(TreeCommandFactory.java:280)
	at org.eclipse.sirius.tree.ui.tools.internal.editor.actions.CreateToolItemAction.run(CreateToolItemAction.java:133)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:473)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:565)
	at org.eclipse.jface.action.ActionContributionItem.lambda$4(ActionContributionItem.java:397)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:86)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5252)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1348)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4522)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4107)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1044)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:680)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:594)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
	at com.bug.rcp.Application.start(Application.java:18)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1499)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1472)
Comment 1 Pierre-Charles David CLA 2017-08-23 05:40:17 EDT
Hi,

from the look of the stack, one possible explanation would be that the org.eclipse.sirius.ui.properties is not present in the runtime context (where you actually run your modeler). The "Open Dialog" and "Open Wizard" operations are not actually contributed by the core of Sirius, but by the the (optional) EEF-based properties view support feature. It's possible that you have this feature installed in your development environment (it must be because you were able to create an "Open Dialog" operation), but that it is not available in your runtime. If this explanation is correct, you can probably fix the issue by having an explicit dependency from your modeler plug-in to org.eclipse.sirius.ui.properties.

Can you confirm?

We'll need to document this (https://www.eclipse.org/sirius/doc/specifier/general/Model_Operations.html#dialogandwizard does not mention it), and make the code more robust to avoid the NPE anyway.
Comment 2 Laurent Fasani CLA 2017-08-28 10:16:09 EDT
This issue is effectively linked to that the plug-in that contains the Dialog declaration is not present in the runtime.

Scenario to reproduce:
* launch a runtime which have org.eclipse.sirius.ui.properties and oes.ui.properties.ext.widgets.reference
* import both vsp and Sirius modeling project(attached with this bug) into the runtime
* open testOpenDialogOp project and "my_diag1" diagram
* use create_class tool and click on diagram -> a dialog box is opened
* close dialog -> a class has been created

* Now, relaunch the runtime but without any of oes.ui.properties.xxx plug-in (change launch config and uncheck plug-in)
* open testOpenDialogOp project and "my_diag1" diagram
* use create_class tool and click on diagram -> NPE
Comment 3 Laurent Fasani CLA 2017-08-28 10:23:56 EDT
Created attachment 269995 [details]
vsp and testOpenDialogOp modeling project
Comment 4 M V CLA 2017-08-29 04:19:05 EDT
(In reply to Pierre-Charles David from comment #1)
> Hi,
> 
> from the look of the stack, one possible explanation would be that the
> org.eclipse.sirius.ui.properties is not present in the runtime context
> (where you actually run your modeler). The "Open Dialog" and "Open Wizard"
> operations are not actually contributed by the core of Sirius, but by the
> the (optional) EEF-based properties view support feature. It's possible that
> you have this feature installed in your development environment (it must be
> because you were able to create an "Open Dialog" operation), but that it is
> not available in your runtime. If this explanation is correct, you can
> probably fix the issue by having an explicit dependency from your modeler
> plug-in to org.eclipse.sirius.ui.properties.
> 
> Can you confirm?
> 
> We'll need to document this
> (https://www.eclipse.org/sirius/doc/specifier/general/Model_Operations.
> html#dialogandwizard does not mention it), and make the code more robust to
> avoid the NPE anyway.

Yes, I can confirm that this was fixing the problem.
Comment 5 Pierre-Charles David CLA 2017-08-29 05:46:34 EDT
(In reply to M V from comment #4)
> (In reply to Pierre-Charles David from comment #1)
> > Hi,
> > 
> > from the look of the stack, one possible explanation would be that the
> > org.eclipse.sirius.ui.properties is not present in the runtime context
> > (where you actually run your modeler). The "Open Dialog" and "Open Wizard"
> > operations are not actually contributed by the core of Sirius, but by the
> > the (optional) EEF-based properties view support feature. It's possible that
> > you have this feature installed in your development environment (it must be
> > because you were able to create an "Open Dialog" operation), but that it is
> > not available in your runtime. If this explanation is correct, you can
> > probably fix the issue by having an explicit dependency from your modeler
> > plug-in to org.eclipse.sirius.ui.properties.
> > 
> > Can you confirm?
> > 
> > We'll need to document this
> > (https://www.eclipse.org/sirius/doc/specifier/general/Model_Operations.
> > html#dialogandwizard does not mention it), and make the code more robust to
> > avoid the NPE anyway.
> 
> Yes, I can confirm that this was fixing the problem.

Thanks for the confirmation. We'll improve the documentation and update the code to provide a more useful error message if it occurs at runtime.
Comment 6 Eclipse Genie CLA 2017-09-12 09:59:50 EDT
New Gerrit change created: https://git.eclipse.org/r/104969
Comment 7 Eclipse Genie CLA 2017-09-15 06:03:55 EDT
New Gerrit change created: https://git.eclipse.org/r/105195
Comment 9 Florian Barbin CLA 2017-09-18 03:05:26 EDT
Will be marked as fixed once the Junit test (that fails on hudson for now) will be merged.
Comment 11 Pierre-Charles David CLA 2017-11-08 03:37:26 EST
Available in Sirius 5.1.0, see https://wiki.eclipse.org/Sirius/5.1.0.