archimatetool / archi

Archi: ArchiMate Modelling Tool
https://www.archimatetool.com
MIT License
954 stars 268 forks source link

Jasper report does nothing when Archi is launched with a custom language pack #857

Closed jbsarrodie closed 2 years ago

jbsarrodie commented 2 years ago

Hi,

I've found a bug or edge case. I usually run Archi with a custom language pack for all sort of reasons (by adding -nl myorgname in Archi.ini). This language pack being a custom one, there is no matching locale in the jasper report dialog. When running the report the first time everything is fine and the report is created, but it no more work if you run the report a second time: the jasperreport dialog doesn't even appear and a stack trace is logged (see below).

It seems that checking for null before calling fComboLocale.setSelection(...) in ExportJasperReportsWizardPage2#createControl fixes it. I'm commiting a fix.

stack trace:

!ENTRY org.eclipse.e4.ui.workbench 4 0 2022-07-11 16:09:21.169
!MESSAGE Command 'com.archimatetool.jasperreports.command.Jasper' failed
!STACK 0
org.eclipse.core.commands.ExecutionException: Error executing 'com.archimatetool.jasperreports.command.Jasper': org.eclipse.core.runtime.AssertionFailedException: null argument:
    at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:170)
    at org.eclipse.core.commands.Command.executeWithChecks(Command.java:488)
    at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:487)
    at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:213)
    at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.executeItem(HandledContributionItem.java:438)
    at org.eclipse.e4.ui.workbench.renderers.swt.AbstractContributionItem.handleWidgetSelection(AbstractContributionItem.java:449)
    at org.eclipse.e4.ui.workbench.renderers.swt.AbstractContributionItem.lambda$2(AbstractContributionItem.java:475)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4243)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1063)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4060)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3632)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
    at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:644)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:551)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:156)
    at com.archimatetool.editor.Application.start(Application.java:81)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1467)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1440)
Caused by: org.eclipse.e4.core.di.InjectionException: org.eclipse.core.runtime.AssertionFailedException: null argument:
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:68)
    at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317)
    at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:251)
    at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173)
    at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:156)
    ... 33 more
Caused by: org.eclipse.core.runtime.AssertionFailedException: null argument:
    at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:88)
    at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:76)
    at org.eclipse.jface.viewers.StructuredSelection.<init>(StructuredSelection.java:82)
    at com.archimatetool.jasperreports.ExportJasperReportsWizardPage2.createControl(ExportJasperReportsWizardPage2.java:208)
    at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:178)
    at org.eclipse.jface.wizard.WizardDialog.createPageControls(WizardDialog.java:743)
    at org.eclipse.jface.wizard.WizardDialog.createContents(WizardDialog.java:635)
    at org.eclipse.jface.window.Window.create(Window.java:431)
    at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1094)
    at org.eclipse.jface.window.Window.open(Window.java:788)
    at com.archimatetool.jasperreports.JasperReportsHandler.execute(JasperReportsHandler.java:42)
    at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:283)
    at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:97)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
    ... 37 more
Phillipus commented 2 years ago

The null check works, but I was interested in why it was null. I've committed a change to master that ensures the locale is never null and that a custom default locale (if specified on the command line) is added to the combo box.

You can delete your branch if you like. :-)

jbsarrodie commented 2 years ago

The null check works, but I was interested in why it was null. I've committed a change to master that ensures the locale is never null and that a custom default locale (if specified on the command line) is added to the combo box.

I was sure there was a better fix than mine. Thank you !

You can delete your branch if you like. :-)

Done ;-)

Phillipus commented 2 years ago

Fixed in Archi 4.10