Archi Forum

Archi => General Archi Discussion => Topic started by: OndrejM on May 16, 2018, 13:41:40 PM

Title: ArchiMate command line tool requires SWT lib
Post by: OndrejM on May 16, 2018, 13:41:40 PM
Hi All,
I would like to automatically generate html exports from openExchange format on a linux machine. Unfortunately I can't execute it using command line tool due to missing SWT library. Is it required to have it or is there any change to survive without it? I don't need any GUI here.

Thanks
Ondrej



java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
/home/machacek/.archi4/.config/org.eclipse.osgi/35/0/.cp/libswt-pi3-gtk-4763.so: libgtk-3.so.0: cannot open shared object file: No such file or directory
no swt-pi3-gtk in java.library.path
/home/machacek/.swt/lib/linux/x86_64/libswt-pi3-gtk-4763.so: libgtk-3.so.0: cannot open shared object file: No such file or directory
Can't load library: /home/machacek/.swt/lib/linux/x86_64/libswt-pi3-gtk.so

at org.eclipse.swt.internal.Library.loadLibrary(Library.java:327)
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:236)
at org.eclipse.swt.internal.gtk.OS.<clinit>(OS.java:58)
at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:124)
at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:80)
at org.eclipse.swt.widgets.Display.<clinit>(Display.java:140)
at com.archimatetool.xmlexchange.commandline.ImportXMLProvider.ensureDefaultDisplay(ImportXMLProvider.java:119)
at com.archimatetool.xmlexchange.commandline.ImportXMLProvider.run(ImportXMLProvider.java:73)
at com.archimatetool.commandline.CentralScrutinizer.runProviderOptions(CentralScrutinizer.java:149)
at com.archimatetool.commandline.CentralScrutinizer.start(CentralScrutinizer.java:74)
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)
Title: Re: ArchiMate command line tool requires SWT lib
Post by: Phil Beauvoir on May 16, 2018, 15:55:37 PM
It needs access to the SWT library for things like Color objects.

Is the path "/home/machacek/.archi4/" accessible to Archi? Can you run Archi on this machine in normal mode?

This is the location where an Eclipse-based app copies the SWT files to.

Title: Re: ArchiMate command line tool requires SWT lib
Post by: OndrejM on May 16, 2018, 19:16:24 PM
thanks for the comment,
it has access to .archi4 folder. The thing is there is not gtk or any other gui-like library. Its intended to use this machine only for generating html export after commit of .archimate file. That's why Archi can't be executed in a normal mode.

should I install SWT (or GTK) there?

Thank you

Ondrej
Title: Re: ArchiMate command line tool requires SWT lib
Post by: Phil Beauvoir on May 16, 2018, 19:20:22 PM
You can't install SWT there. When Archi runs (or an Eclipse-based app) it copies some files to ~/.archi4/.config/org.eclipse.osgi/*.* location. SWT files should be there.

Are you saying you cannot run Archi on this machine? Archi CLI needs some kind of graphics support even if virtual driver in order to generate diagrams and access the SWT lib.
Title: Re: ArchiMate command line tool requires SWT lib
Post by: OndrejM on May 16, 2018, 19:37:10 PM
I see, should I install libgtk-3 or swt-pi3-gtk then?

when I execute Archi in the normal mode, log says the following:


java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
/home/machacek/.archi4/.config/org.eclipse.osgi/35/0/.cp/libswt-pi3-gtk-4763.so: libgtk-3.so.0: cannot open shared object file: No such file or directory
no swt-pi3-gtk in java.library.path
/home/machacek/.swt/lib/linux/x86_64/libswt-pi3-gtk-4763.so: libgtk-3.so.0: cannot open shared object file: No such file or directory
Can't load library: /home/machacek/.swt/lib/linux/x86_64/libswt-pi3-gtk.so

at org.eclipse.swt.internal.Library.loadLibrary(Library.java:327)
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:236)
at org.eclipse.swt.internal.gtk.OS.<clinit>(OS.java:58)
at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:124)
at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:80)
at org.eclipse.swt.widgets.Display.<clinit>(Display.java:140)
at org.eclipse.ui.internal.Workbench.createDisplay(Workbench.java:765)
at org.eclipse.ui.PlatformUI.createDisplay(PlatformUI.java:160)
at com.archimatetool.editor.Application.start(Application.java:70)
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)




Thank you
Ondrej
Title: Re: ArchiMate command line tool requires SWT lib
Post by: Phil Beauvoir on May 16, 2018, 19:58:01 PM
No, you should not need to install anything.

Try deleting the /home/machacek/.archi4/ directory and run Archi normally again. Then check to see if the SWT file has been copied over. Sounds like something is stopping the file from being copied.
Title: Re: ArchiMate command line tool requires SWT lib
Post by: Phil Beauvoir on May 16, 2018, 20:00:24 PM
Actually, I may be wrong about this.

Try Googling "libgtk-3.so.0: cannot open shared object file: No such file or directory"

Perhaps you do need to install something!
Title: Re: ArchiMate command line tool requires SWT lib
Post by: OndrejM on May 16, 2018, 20:08:59 PM
I think so, probably libgtk is needed cause swt files are there:


/home/machacek/.archi4/
|-- .config
|   |-- org.eclipse.core.runtime
|   |   |-- .contributions.3
|   |   |-- .contributors.3
|   |   |-- .extraData.3
|   |   |-- .mainData.3
|   |   |-- .manager
|   |   |   |-- .fileTable.10
|   |   |   |-- .fileTable.9
|   |   |   `-- .fileTableLock
|   |   |-- .namespaces.3
|   |   |-- .orphans.3
|   |   `-- .table.3
|   |-- org.eclipse.equinox.app
|   |   `-- .manager
|   |       `-- .fileTableLock
|   |-- org.eclipse.osgi
|   |   |-- 115
|   |   |   `-- 0
|   |   |       `-- .cp
|   |   |           `-- lib
|   |   |               |-- commons-csv-1.5.jar
|   |   |               `-- commons-io-2.5.jar
|   |   |-- 140
|   |   |   `-- 0
|   |   |       `-- .cp
|   |   |           |-- lib
|   |   |           |   |-- com.jcraft.jsch_0.1.54.v20170116-1932.jar
|   |   |           |   |-- org.eclipse.jgit-4.10.0.201712302008-r.jar
|   |   |           |   |-- slf4j-api-1.7.25.jar
|   |   |           |   `-- slf4j-simple-1.7.25.jar
|   |   |           `-- org.archicontribs.modelrepository.jar
|   |   |-- 35
|   |   |   `-- 0
|   |   |       `-- .cp
|   |   |           |-- libswt-gtk-4763.so
|   |   |           |-- libswt-pi3-gtk-4763.so
|   |   |           `-- libswt-pi-gtk-4763.so
|   |   |-- 92
|   |   |   `-- 0
|   |   |       `-- .cp
|   |   |           `-- lib
|   |   |               `-- commons-cli-1.4.jar
|   |   |-- framework.info.1
|   |   `-- .manager
|   |       |-- .fileTable.1
|   |       |-- .fileTable.2
|   |       `-- .fileTableLock
|   `-- org.eclipse.update
|       |-- history
|       |   |-- 1526497383000.xml
|       |   `-- 1526497394000.xml
|       |-- last.config.stamp
|       `-- platform.xml
`-- .metadata
    `-- .log


thank you very much for your support
Title: Re: ArchiMate command line tool requires SWT lib
Post by: Jean-Baptiste Sarrodie on May 17, 2018, 11:02:36 AM
Hi,

Try googling "linux run eclipse headles gtk".

i came up with this (https://stackoverflow.com/questions/10165693/eclipse-cannot-load-swt-libraries) which seems pretty close to your error.

JB
Title: Re: ArchiMate command line tool requires SWT lib
Post by: OndrejM on May 18, 2018, 07:31:04 AM
thank you very much
  I have also realised that you need some Xserver in order to make it running - maybe worth thinking about doing some Archi API (command line interface) which runs without these dependencies.
Title: Re: ArchiMate command line tool requires SWT lib
Post by: Phil Beauvoir on May 18, 2018, 07:39:08 AM
As I said, in order to generate diagrams, or reference SWT objects like Color this is necessary. For example, when importing from the exchange format, a SWT Color object is created. This in turn references a Display object.
Title: Re: ArchiMate command line tool requires SWT lib
Post by: OndrejM on May 22, 2018, 10:58:16 AM
fixed by installing the following packages (RedHat/CentOS):
- gtk3
- xvfb

then you need to start xvfb on a specific display port and export DISPLAY variable accordingly.
example;

Xvfb :99 &
export DISPLAY=:99
  Archi -application com.archimatetool.commandline.app -consoleLog -nosplash --xmlexchange.import ... --html.createReport ...
  pkill -f 'Xvfb :99'


thanks all for the support
Title: Re: ArchiMate command line tool requires SWT lib
Post by: Phil Beauvoir on May 22, 2018, 11:04:19 AM
Thanks for sharing the info.

It's similar to the unit tests that run on Travis. This has to be added to the travis.yml file:

export DISPLAY=:99.0
sh -e /etc/init.d/xvfb start
Title: Re: ArchiMate command line tool requires SWT lib
Post by: Phil Beauvoir on May 22, 2018, 11:12:00 AM
I added a note on this to the wiki https://github.com/archimatetool/archi/wiki/Archi-Command-Line-Interface