NullPointerException from ACLI using SSH protocol

Started by jp77, January 06, 2022, 15:41:52 PM

Previous topic - Next topic

jp77

Hello

I have some scripts that use the Archi Command Line Interface for model cloning.

These scripts worked perfectly with Archi 4.8.0 + CoArchi 0.6 but after upgrading to Archi 4.9.1 + CoArchi 0.8 when using SSH protocol there is a NullPointer exception from the ACLI.  Could this be an issue in the 4.9.1 ACLI or CoArchi?

Thanks in advance for any advice. More information below.


Our current versions being used are:
Previously working - Archi 4.8.0 / CoArchi 0.6.2.202004031233
Current versions - Archi 4.9.1 / CoArchi 0.8.0.202110121448
Ubuntu 18.04.6 LTS

To isolate and recreate the problem repeatably, the Archi Command Line interface has been tested standalone (from Ubuntu command line), with 4 variants:
   
Archi 4.9.1 using SSH credentials (id_rsa)
Archi 4.9.1 using password file
Archi 4.8.0 using SSH credentials (id_rsa)
Archi 4.8.0 using password file



When using Archi 4.9.1 [CoArchi 0.8] with SSH credentials, the NullPointer exception occurs:

/opt/Archi-4.9.1/Archi -application com.archimatetool.commandline.app -consoleLog -nosplash --modelrepository.cloneModel ssh://git@server:1234/ndaf/repo.git --modelrepository.loadModel /home/user/.archi4/model-repository/test --modelrepository.identityFile /home/user/.ssh/id_rsa

java.lang.NullPointerException
   at org.archicontribs.modelrepository.commandline.LoadModelFromRepositoryProvider.run(LoadModelFromRepositoryProvider.java:125)   
at com.archimatetool.commandline.CentralScrutinizer.runProviderOptions(CentralScrutinizer.java:164)   
at com.archimatetool.commandline.CentralScrutinizer.start(CentralScrutinizer.java:82)   
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)

[LoadModelFromRepositoryProvider] Cloning from ssh://git@server:1234/ndaf/repo.git to /home/user/.archi4/model-repository/test

Note: The SSH credentials (id_rsa public/private keys) remain unchanged since the Archi 4.8.0 install.  Just in case, also tried generating new keys (and applying public key to Git account) but this makes no difference.



When using Archi 4.9.1 [CoArchi 0.8] with password file,  the command completes normally:

/opt/Archi-4.9.1/Archi -application com.archimatetool.commandline.app -consoleLog -nosplash --modelrepository.cloneModel http://server:1234/scm/ndaf/repo.git --modelrepository.loadModel /home/user/.archi4/model-repository/test --modelrepository.userName username --modelrepository.passFile /home/user/.ssh/pf.txt

[LoadModelFromRepositoryProvider] Cloning from http://server:1234/scm/ndaf/repo.git to /home/user/.archi4/model-repository/test
[LoadModelFromRepositoryProvider] Model cloned!
[LoadModelFromRepositoryProvider] Loading model at /home/user/.archi4/model-repository/test
[LoadModelFromRepositoryProvider] Loaded model: 'NDEA'



When using Archi 4.8.0 [CoArchi 0.6] to see if things still work as they did before upgrading to 4.9.1, both methods (SSH credentials or password file) result in no output from the Archi Command Line Interface.  This could be because the models being imported have been updated since moving to Archi 4.9.1, and the Archi 4.8.0 version can no longer open these (Archi stops processing?).   Note: When using "–help" option the help is displayed, but all other options and even invalid options result in no output.

Phil Beauvoir

The NPE seems to be because the password is null. For SSH, the password has to be provided to access the identity File.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

jp77

With previous versions (Archi 4.8.0 + CoArchi 0.6) was getting errors when SSH passphrase was set so was using with no passphrase set.

Using Archi 4.9.1 + CoArchi 0.8, have regenerated the id_rsa SSH keys again this time setting a passphrase and applied to Git account.  Still getting the same result with exactly the same NPE.

Phil Beauvoir

#3
Are you using the --modelrepository.passFile option?

There is a bug in coArchi ACLI in that it expects to see a password from the password file in all cases. This can be worked around by providing a password in the password file even if it is a dummy one.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

jp77

Thanks Phil that workaround resolves it.

When using SSH, if I provide any passphrase when generating the id_rsa key this always gives a USERAUTH exception from the ACLI, but if I leave the passphrase blank it works fine. Not a big deal, but any idea why that's happening?

Phil Beauvoir

It should be the same behaviour as using a password to access the id_rsa file in the main app. Does it work there?
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.