archi-contribs / database-plugin

Database export/import plugin that store models in a central database repository
Other
81 stars 23 forks source link

export a model - null pointer exception #158

Closed kaising closed 1 year ago

kaising commented 1 year ago

Got a stacktrace when exporting: using archi 4.9.3 database export plugin version: 4.9.6

java.lang.NullPointerException java.lang.NullPointerException org.archicontribs.database.model.DBArchimateModel.resolveSourceAndTargetConnections(DBArchimateModel.java:878) org.archicontribs.database.model.commands.DBResolveConnectionsCommand.execute(DBResolveConnectionsCommand.java:36) org.archicontribs.database.data.DBCompoundCommand.checkAndExecute(DBCompoundCommand.java:57) org.archicontribs.database.GUI.DBGuiExportModel.export(DBGuiExportModel.java:2515) org.archicontribs.database.GUI.DBGuiExportModel$1.widgetSelected(DBGuiExportModel.java:131) org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:252) org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) org.eclipse.swt.widgets.Display.sendEvent(Display.java:4243) org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1063) org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4060) org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3632) org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155) org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046) org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155) org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:644) org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:551) org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:156) com.archimatetool.editor.Application.start(Application.java:81) org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203) org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136) org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401) org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) java.base/java.lang.reflect.Method.invoke(Unknown Source) org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659) org.eclipse.equinox.launcher.Main.basicRun(Main.java:596) org.eclipse.equinox.launcher.Main.run(Main.java:1467)

herve91 commented 1 year ago

which database brand and version ?

ricardo-cabral commented 1 year ago

Hello @herve91 ,

I am pretty new to the ArchiMate world and the company where I work decided to use it and to follow the standards of TOGAF.

First I want to thank you for writing this plugin, it is very helpful and I hope I can contribute to it somehow.

So, I think I have a similar problem to this and I did some investigation and some debugging in the code to try to understand it a bit better so maybe we could try to find a solution for it.

A quick overview:

Steps I have done so far:

1 - The variable faultyEObjectSelected inside DBArchimateModel does not do the check when the plugin is loaded at first time. 2- When I click in the Export button I get the following error:

java.lang.Exception: Failed to resolve source relationship for AccessRelationship:""(id-e3ad492b6d214ae393af2b46dbcf158f)
    at org.archicontribs.database.model.DBArchimateModel.resolveSourceAndTargetRelationships(DBArchimateModel.java:794)
    at org.archicontribs.database.model.commands.DBResolveRelationshipsCommand.execute(DBResolveRelationshipsCommand.java:36)
    at org.archicontribs.database.data.DBCompoundCommand.checkAndExecute(DBCompoundCommand.java:57)
    at org.archicontribs.database.GUI.DBGuiExportModel.export(DBGuiExportModel.java:2958)
    at org.archicontribs.database.GUI.DBGuiExportModel$1.widgetSelected(DBGuiExportModel.java:135)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:252)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4251)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4068)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3645)
    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:643)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:550)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:171)
    at com.archimatetool.editor.Application.start(Application.java:70)
    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:402)
    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(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    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)

3 - If I click in the OK button in the dialog, close the plugin by myself and open it a second time with the option to export to the database the variable allFaultyObjects is filled with the wrong relationships

4 - If I click on the OK button it wont work as the method returns always null and the listener below just dispose the component

okButton.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(SelectionEvent arg0) {                       
                        selectItemsShell.dispose();

                    }
                });

5 - What I did to avoid this error, was to return a list of EObject and I added the values inside the map which is coming from the method signature


final List<EObject> toBeDeleted =new ArrayList<>(); 

okButton.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(SelectionEvent arg0) {                       
                        toBeDeleted.addAll(map.keySet());
                        selectItemsShell.dispose();

                    }
                }); 

6 - Now If I click in the OK button the values are returned and the Delete Command is execute, removing the relationships from the model. I also get the message saying that the inconsistent components have been removed

7 - If I click in the button Export again the variable allSourceRelationshipsToResolve from DBArchimateModel has the wrong relationships that I have just deleted and I get the following error:

java.lang.Exception: Failed to resolve source relationship for FlowRelationship:""(id-e48572fff0064579acb48ebc1b9670d3)
    at org.archicontribs.database.model.DBArchimateModel.resolveSourceAndTargetRelationships(DBArchimateModel.java:794)
    at org.archicontribs.database.model.commands.DBResolveRelationshipsCommand.execute(DBResolveRelationshipsCommand.java:36)
    at org.archicontribs.database.data.DBCompoundCommand.checkAndExecute(DBCompoundCommand.java:57)
    at org.archicontribs.database.GUI.DBGuiExportModel.export(DBGuiExportModel.java:2958)
    at org.archicontribs.database.GUI.DBGuiExportModel$1.widgetSelected(DBGuiExportModel.java:135)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:252)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4251)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4068)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3645)
    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:643)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:550)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:171)
    at com.archimatetool.editor.Application.start(Application.java:70)
    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:402)
    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(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    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)

8 - If I click in the Button Ok and close the plugin, and open it again, all my faulty objects appear again to be deleted.

I hope it clarifies some of the points and I will be more than happy if I can help with this somehow.

Regards,

Ricardo Cabral

herve91 commented 1 year ago

Hello Ricardo,

Welcome to the Togaf and Archimate world :)

Could you please confirm the version of Archi and the version of the plugin that you're using ?

At the same time, I need to confirm one thing with you regarding the model you wish to export : has it been loaded from and archimate file or imported from the database using the plugin ?

ricardo-cabral commented 1 year ago

Hello @herve91,

Thanks for your reply.

The screenshot containing the error message is below. Plugin version is: v4.9.6, Archi version: 4.10.10

Just a couple of more details.

Basically, we started using Archi manually, after that we integrated the collaboration plugin and now I am trying to export it to the database

First version was a normal Archimate project generated by Archi, once it is in git I am using the git version.

I exported the project once more in a file(project is valid in Archi) , and the relationship id and source id and target id are not in the XML generated by the tool, however, I am able to find the ids in the respective tables into the database

Perhaps my databased is corrupted somehow. I am just avoiding to drop it in case you think it is worth it to do some investigation.

I am also attaching the result of the query I have done in the DB Regards,

image

image

kaising commented 1 year ago

I am using mysql 5.5. But I have found a solution to avoid the problem. The db schema in mysql must be define like this: charset: utf8-mb4 collation: utf8-mb4-unicode-ci

since then, no more issues. regards, G

Le jeu. 26 janv. 2023 à 10:09, ricardo-cabral @.***> a écrit :

Hello @herve91 https://github.com/herve91,

Thanks for your reply.

The screenshot containing the error message is below. Plugin version is: v4.9.6, Archi version: 4.10.10

Just a couple of more details.

  • I have a personal Archi model at home and it worked well. I did not get the error when I tried yesterday.
  • I tried it again today, to export and I got the same error even when I do not run it using eclipse.

Basically, we started using Archi manually, after that we integrated the collaboration plugin and now I am trying to export it to the database

First version was a normal Archimate project generated by Archi, once it is in git I am using the git version.

I exported the project once more in a file(project is valid in Archi) , and the relationship id and source id and target id are not in the XML generated by the tool, however, I am able to find the ids in the respective tables into the database

  • I removed the model and used the import from the database and I get the same error but for a different component. (Failed to resolve source relationship for...)

Perhaps my databased is corrupted somehow. I am just avoiding to drop it in case you think it is worth it to do some investigation.

Regards,

[image: image] https://user-images.githubusercontent.com/8196121/214795962-bc85b8c1-c570-400c-aae1-ddcefe679daa.png

— Reply to this email directly, view it on GitHub https://github.com/archi-contribs/database-plugin/issues/158#issuecomment-1404722300, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQRJSLMWNH2U2QJGQNFGTLWUI5K7ANCNFSM6AAAAAASV56XJU . You are receiving this because you authored the thread.Message ID: @.***>

herve91 commented 1 year ago

Hello, Did you have any chance to change your database charset ? Did it fixed your issue ?

kaising commented 1 year ago

yep. I have changed the charset and it solves the issue. it's working since then. regards, g

Le ven. 27 janv. 2023 à 15:08, Hervé Jouin @.***> a écrit :

Hello, Did you have any chance to change your database charset ? Did it fixed your issue ?

— Reply to this email directly, view it on GitHub https://github.com/archi-contribs/database-plugin/issues/158#issuecomment-1406555251, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQRJSJ57PIKGRPALWM4I3LWUPJELANCNFSM6AAAAAASV56XJU . You are receiving this because you authored the thread.Message ID: @.***>

ricardo-cabral commented 1 year ago

I have also found a fix to the problem, but I am not able to define the reason.

I have found some relationships without the linked components as you can see in the image below.

I believe Archi somehow cached those relationships because It was not being exported to the xml file as well.

So I deleted all those faulty relationships manually, even with that, for some reason Archi and the Plugin was bringing that problem back.

I did a backup of my database, resolved again the wrong relationships and exported that to a new database and it works fine.

I believe it was not a problem in the plugin itself, perhaps some garbage information stored somewhere.

image

Regards,

herve91 commented 1 year ago

Great news.

And thank you very much to @kaising for providing the solution.

I close the case but I will investigate why it happens and search for a way to fix it.

herve91 commented 1 year ago

Thanks @ricardo-cabral. Even if the issue is not caused by my plugin, it happens when using my plugin so I'll definitelysearch a way to fix it :)