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

Bug 473803

Summary: Papyrus versions 1.1.0, 1.1.1, 1.1.2, 1.1.3 and 2.0.0 fail to export diagrams as images (Eclipse Neon and Mars)
Product: [Modeling] Papyrus Reporter: Luís de Sousa <luis.de.sousa>
Component: DiagramAssignee: Anatoliy Tischenko <tischenko>
Status: RESOLVED FIXED QA Contact:
Severity: blocker    
Priority: P3 CC: borlander, charles, fred.eckertson, klaas.gadeyne, renan.lavarec, rschnekenburger, tischenko, ulf.i.olsson
Version: 2.0.0Flags: fred.eckertson: review?
Target Milestone: 3.0.0   
Hardware: PC   
OS: Linux   
See Also: https://git.eclipse.org/r/55931
https://git.eclipse.org/c/papyrus/org.eclipse.papyrus.git/commit/?id=97fc57c4467177a83f1ad907079e88b43ec5b54a
https://git.eclipse.org/r/61922
https://git.eclipse.org/r/77996
https://git.eclipse.org/c/papyrus/org.eclipse.papyrus.git/commit/?id=19f521c824e2c072bfa0bea24e1d896f208c10e8
https://git.eclipse.org/r/78166
https://git.eclipse.org/c/papyrus/org.eclipse.papyrus.git/commit/?id=3df3f613b9d4f241015574a5e5bb46275f133893
Whiteboard: montages
Attachments:
Description Flags
Use Case diagram producing the exception reported above.
none
Code Fix for "Export All Diagrams" issue. fred.eckertson: review?

Description Luís de Sousa CLA 2015-07-29 03:10:54 EDT
Created attachment 255501 [details]
Use Case diagram producing the exception reported above.

I just started using Papyrus on Mars and am not able to export diagrams to any image format. At the moment I am only working with Use Case diagrams; I am attaching a very simple example.

The error log reports the following:

Message
-------
Unhandled event loop exception

Exception Stack Trace
---------------------
org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException)
	at org.eclipse.swt.SWT.error(SWT.java:4491)
	at org.eclipse.swt.SWT.error(SWT.java:4406)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3794)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3433)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:654)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:598)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:139)
	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:380)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
	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:497)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1488)
Caused by: java.lang.NullPointerException
	at org.eclipse.papyrus.infra.gmfdiag.export.actions.ExportAllDiagramsParameter.getOutputDirectoryPath(ExportAllDiagramsParameter.java:94)
	at org.eclipse.papyrus.infra.gmfdiag.export.engine.ExportAllDiagramsEngine$2.run(ExportAllDiagramsEngine.java:481)
	at org.eclipse.ui.internal.UILockListener.doPendingWork(UILockListener.java:162)
	at org.eclipse.ui.internal.UISynchronizer$3.run(UISynchronizer.java:154)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
	... 24 more

Session Data
------------
eclipse.buildId=4.5.0.I20150603-2000
java.version=1.8.0_45
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_GB
Framework arguments:  -product org.eclipse.epp.package.java.product
Command-line arguments:  -data file:/home/desousa/Eclipse/Mars/Workspace.Tudor/ -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.java.product

Thank you.
Comment 1 Luís de Sousa CLA 2015-07-29 03:16:51 EDT
I have now tested other types of models and always get this same exception. This seems to be a general bug with Papyrus.

Thank you.
Comment 2 Anatoliy Tischenko CLA 2015-08-05 11:08:19 EDT
I can't reproduce with the current code (neither master/neon nor for mars SR1)
The described NPE does not depend on your diagrams, but may depend on the exact sequence of your actions. 
Can you please provide step by step way for you to invoke the export?
Comment 3 Luís de Sousa CLA 2015-08-07 03:04:09 EDT
These are the steps to reproduce this exception (Eclipse 4.5.0 with Papyrus 1.1.0):

1. Open the project containing the model
2. Navigate in the Project Explorer to the folder containing the model
3. Right click on the model and select "Export All Diagrams..."
4. Optionally change the output format
5. Click OK

I have Eclipse set up to send exceptions. You may access the last one I submitted here:

https://dev.eclipse.org/recommenders/community/confess/#/incidents/Ngz8jQw3ehVzJ64ro4nlzVvKT1btRBRuGIC05i9jckWnuYtwHDyRqf1OJC3EUNjd

Thank you.
Comment 4 Anatoliy Tischenko CLA 2015-08-11 07:03:09 EDT
I've just verified that the bug is not reproduced anymore in the most recent version 1.1.1, available at http://download.eclipse.org/modeling/mdt/papyrus/updates/releases/mars/. 
Please update
Comment 5 Luís de Sousa CLA 2015-08-11 08:54:48 EDT
I am sorry, but the bug is still there with Papyrus 1.1.1. Here is the latest submission:

https://dev.eclipse.org/recommenders/community/confess/#/incidents/lLXEy9tlu8kMkIFKliI6s6qnF7f2rQEQ0n3yBW4rv4X7uaWWxQb0pMmoVj6OkJBi

Thank you.
Comment 6 Fred Eckertson CLA 2015-08-14 15:26:01 EDT
I struggled with a problem like this for a short while because my model directory is not inside my eclipse workspace directory. 

If your setup is the same, then you can work around this by [not optionally] browsing to and selecting the exact same output directory that the "Export All Diagrams" dialog says it will use. 

I have a code fix that alleviates this annoyance, I will attach it presently.
Comment 7 Fred Eckertson CLA 2015-08-14 15:53:05 EDT
Created attachment 255870 [details]
Code Fix for "Export All Diagrams" issue.

I, Fred Eckertson, wrote 100% of the code changes I am providing.
This code contains no cryptography
I have the right to contribute code to Eclipse.
I contribute this content under the EPL.

The fix consists of the addition of lines 170-183. 

Without this fix, Papyrus fails to export the diagrams if the model directory is not in the eclipse workspace directory unless one first browses to and selects an output directory manually. This is despite the fact that a valid output directory (which will typically be the desired output directory) is displayed by default in the "Export All Diagrams" dialog.
Comment 8 Luís de Sousa CLA 2015-08-15 13:04:31 EDT
I am out of the office these days, I cannot try Fred's suggestion right away. However, I would like to note that by default versioning plug-ins such as EGit store all assets outside the workspace. This is a recommended practice and greatly facilitates migration between Eclipse versions. In a properly organised development environment workspaces contain solely metadata. The contrary is the exception rather than rule.

Fred: I doubt this is the correct place to submit a code fix. I advise you to seek guidance on this. And thanks for sharing.

Regards.
Comment 9 Eclipse Genie CLA 2015-09-14 18:56:48 EDT
New Gerrit change created: https://git.eclipse.org/r/55931
Comment 11 Anatoliy Tischenko CLA 2015-09-18 12:19:06 EDT
gerrit is merged. close the bug
Comment 12 Luís de Sousa CLA 2015-11-09 11:00:27 EST
This bug is still not fixed in the latest Papyrus version (1.1.2). Here is an exception report from today:

https://dev.eclipse.org/recommenders/community/confess/#/incidents/VstW9wjlIrv1FccyxTfilDD1yRJmJ5ySov8m9VtueLzbHfjqzlz7b6Wyi1h3M2om

Regards.
Comment 13 Eclipse Genie CLA 2015-12-03 17:01:16 EST
New Gerrit change created: https://git.eclipse.org/r/61922
Comment 14 Renan Lavarec CLA 2016-02-22 04:15:00 EST
Hello,
I go the same error on the Papyrus 1.1.3

----------------------------------------
Papyrus
Version: Mars.3 (4.5.3)
Build id: 2015-12-06T05:06:04Z

----------------------------------------
Papyrus	1.1.3.201512060525	org.eclipse.papyrus.rcp.product	null

----------------------------------------
null
org.eclipse.ui
Error
Mon Feb 22 10:05:00 CET 2016
Unhandled event loop exception

org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException)
	at org.eclipse.swt.SWT.error(SWT.java:4491)
	at org.eclipse.swt.SWT.error(SWT.java:4406)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4155)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3772)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:654)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:598)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:139)
	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:380)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
Caused by: java.lang.NullPointerException
	at org.eclipse.papyrus.infra.gmfdiag.export.actions.ExportAllDiagramsParameter.getOutputDirectoryPath(ExportAllDiagramsParameter.java:94)
	at org.eclipse.papyrus.infra.gmfdiag.export.engine.ExportAllDiagramsEngine$2.run(ExportAllDiagramsEngine.java:481)
	at org.eclipse.ui.internal.UILockListener.doPendingWork(UILockListener.java:162)
	at org.eclipse.ui.internal.UISynchronizer$3.run(UISynchronizer.java:154)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
	... 23 more
Comment 15 Ulf Olsson CLA 2016-03-23 04:26:41 EDT
Hint (and a workaround): if you select the Browse button and re-select the same target diagram generation works as advertised.
Comment 16 Luís de Sousa CLA 2016-07-27 10:29:39 EDT
*** Bug 498581 has been marked as a duplicate of this bug. ***
Comment 17 Luís de Sousa CLA 2016-07-27 10:35:27 EDT
So this bug is still out there. I bumped on it today with Eclipse Neon, and even opened a dupe bug. It seems all Papyrus versions from 1.1.0 to 2.0.0 are affected.

The workaround suggested by Ulf Olsson works in some cases. Sometimes re-initialising Eclipse before trying it helps.
Comment 18 Eclipse Genie CLA 2016-07-27 12:10:46 EDT
New Gerrit change created: https://git.eclipse.org/r/77996
Comment 20 Eclipse Genie CLA 2016-07-29 10:52:14 EDT
New Gerrit change created: https://git.eclipse.org/r/78166
Comment 21 Eclipse Genie CLA 2016-08-01 03:57:18 EDT
Gerrit change https://git.eclipse.org/r/78166 was merged to [streams/2.0-maintenance].
Commit: http://git.eclipse.org/c/papyrus/org.eclipse.papyrus.git/commit/?id=3df3f613b9d4f241015574a5e5bb46275f133893
Comment 22 Remi Schnekenburger CLA 2016-08-01 03:58:22 EDT
(In reply to Eclipse Genie from comment #18)
> New Gerrit change created: https://git.eclipse.org/r/77996

With the patch pushed on Neon and Oxygen, I could not reproduce the issue described in this bug.
closing task.