LibreSign / libresign

✍️ Nextcloud app to sign PDF documents
https://libresign.coop
491 stars 57 forks source link

Setup with Nextcloud AIO #1409

Closed bigbeka closed 6 months ago

bigbeka commented 1 year ago

Issue: Error - Java not installed message; Advice: Run occ libresign:install --java

To reproduce:

Screenshots Screenshot 2023-02-05 at 22 52 31

Environment information (please complete the following information):

Searching here or elsewhere did not reveal that someone else had similar issue.

vitormattos commented 7 months ago

Have anything strange because you have the file and the message is not about without file, sounds that is about any dependency wrong.

The file is downloaded from here if is x64 https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.2+13/OpenJDK21U-jre_x64_linux_hotspot_21.0.2_13.tar.gz

And from here if is aarch64: https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.2+13/OpenJDK21U-jre_aarch64_linux_hotspot_21.0.2_13.tar.gz

Could you download the tar file to your architecture, extract and test if bin/java --verison will work fine? Pay attention to directory.

To use the same way of LibreSign to identify the architecture, you can use the follow command:

php -r "echo php_uname('m') . PHP_EOL;"

The logic to choose what file will be downloaded considering the return of function php_uname is that:

if ($architecture === 'x86_64') {
} else {
}
martin-77 commented 7 months ago

Ok, this is crazy - maybe I make a mistake, but even the downloaded version does not work (forget about wrong folders I produce)

c2bc57ffc481:/mnt/ncdata/appdata_ocmhlw0tagos/libresign/java/jdk-21.0.2+13-jre/bin/jdk-21.0.2+13-jre/bin$ php -r "echo php_uname('m') . PHP_EOL;"
x86_64
c2bc57ffc481:/mnt/ncdata/appdata_ocmhlw0tagos/libresign/java/jdk-21.0.2+13-jre/bin/jdk-21.0.2+13-jre/bin$ ./java --version
bash: ./java: cannot execute: required file not found
c2bc57ffc481:/mnt/ncdata/appdata_ocmhlw0tagos/libresign/java/jdk-21.0.2+13-jre/bin/jdk-21.0.2+13-jre/bin$ ls -la
total 104
drwxr-xr-x 2 www-data www-data  4096 Jan 17 06:55 .
drwxr-xr-x 6 www-data www-data  4096 Jan 17 06:55 ..
-rwxr-xr-x 1 www-data www-data 16240 Jan 17 06:55 java
-rwxr-xr-x 1 www-data www-data 16304 Jan 17 06:55 jfr
-rwxr-xr-x 1 www-data www-data 16344 Jan 17 06:55 jrunscript
-rwxr-xr-x 1 www-data www-data 16312 Jan 17 06:55 jwebserver
-rwxr-xr-x 1 www-data www-data 16304 Jan 17 06:55 keytool
-rwxr-xr-x 1 www-data www-data 16336 Jan 17 06:55 rmiregistry
c2bc57ffc481:/mnt/ncdata/appdata_ocmhlw0tagos/libresign/java/jdk-21.0.2+13-jre/bin/jdk-21.0.2+13-jre/bin$

the folder contains the same files as the java/bin which was downloaded by libresign itself. Not sure if I make a mistake...

vitormattos commented 7 months ago

the folder contains the same files as the java/bin which was downloaded by libresign itself. Not sure if I make a mistake...

Yes, is the same content because is the same file that LibreSign setup get.

Did you put at the same place? I ask because at your previous message is the same place. The place to extract the content is not important at this moment because I suggested to download and run the handmade test only to check if will works to you and the strange is that don't works.

martin-77 commented 7 months ago

It is in ab sub-sub-folder of libresign. but something prevents java from being executed. And I do not understand, why at all. the java file is executable by www-data and I am www-data...

vitormattos commented 7 months ago

Yes, this is the strange point and I don't know how to solve. Let's think more about and wait for comments from others.

cube-one-gxp-lifescience-partner commented 6 months ago

Hello, same issue as @martin-77 . This might have something to do with the docker containers using alpine. Java can be executed as expected outside the container on ubuntu.

martin-77 commented 6 months ago

Are you on nc28 or 29? @cubeoneGmbH

cube-one-gxp-lifescience-partner commented 6 months ago

I'm on nc28.

neocult-de commented 6 months ago

I am testing LibreSign on NC28 with Nextcloud-AIO. The issue is that the container is alpine which is not build with glibc libraries and therefore the Java cant be executed inside the container. Running the following adds compatibility to glibc and then java and pdftk for that matter will be recognized and work for me.

apk add gcompat libstdc++

Please keep in mind, that this task might need to be repeated every time nextcloud-aio-nextcloud is updated. The dependencies are in the persistent ncdata folder though.

An automation could be to put the call to install gcompat into cron (as root or a user in the docker group) and schedule it after the nightly backup/update for nextcloud-aio:

0 5 * docker exec -it nextcloud-aio-nextcloud apk add gcompat libstdc++

Hope that helps people want to try LibreSign with Nextcloud-AIO

EDIT: It is no longer working for me after repulling the container. It makes java executable and able to run but will not initialize the JVM correctly.

As a workaround for testing: Install all the binaries, but replace the java version with an alpine compatible one. The one available in alpine directly via:

apk add openjdk11

Then make a symlink

ln -s /usr/bin/java java #inside the java/bin folder of libresign

or

ln -s /usr/bin/java /mnt/ncdata/appdata_YOURID/libresign/java/jdk-VERSION-jre/bin/java

Keep in mind the java version check will still fail in the gui because you have another version now running, but pdftk should be on green. You have working java version in alpine and the Addon works. But it is untested.

martin-77 commented 6 months ago

sadly, this did not solve my issue. running v29 - maybe there is something different?

Error occurred during initialization of VM
Unable to load jimage library: /mnt/ncdata/appdata_ocmhlw0tagos/libresign/java/jdk-21.0.2+13-jre/lib/libjimage.so

libjimage.so is not in the lib-folder

cube-one-gxp-lifescience-partner commented 6 months ago

Unfortunately this is also the case for nc28 but the libjimage.so file is existing and has correct permissions.

cube-one-gxp-lifescience-partner commented 6 months ago

With the updated solution @neocult-de provided PDFtk is now recognized properly. But jsignpdf still won't run and so does the whole application.

"Necessary Java to run JSignPdf | jsignpdf"

vitormattos commented 6 months ago

ref: https://github.com/LibreSign/libresign/issues/3026

vitormattos commented 6 months ago

Do you think that using Alpine as a base Linux distribution will be possible to reproduce the problem? I don't have any instances with Nextcloud AIO and looking at the documentation of AIO, I haven't found a way to run AIO locally to reproduce the issue.

martin-77 commented 6 months ago

@szaimen might be the one, we all need ;-) sorry for the ping... But to be honest, libresign would be wonderfull see implemented in Nextcloud AIO.

szaimen commented 6 months ago

Hi @vitormattos you could try https://github.com/nextcloud/all-in-one/discussions/588#discussioncomment-3450343

martin-77 commented 6 months ago

It is not the questiuon of setting up Nextcloud-AIO itself but adding jdk-21.0.2+13-jre / java jdk on top of the the alpine image. As you can see, a simple apk install did not do the trick -> https://github.com/LibreSign/libresign/issues/1409#issuecomment-2104749277 - maybe you find some time to support or inspire us @szaimen . And thanks for your quick reply! You are unbelievable!

szaimen commented 6 months ago

Should be possible by so, no? https://github.com/nextcloud/all-in-one?tab=readme-ov-file#how-to-add-os-packages-permanently-to-the-nextcloud-container

neocult-de commented 6 months ago

The openjdk version shipped in the alpine repositories is outdated and can not be used. Therefore how to add os packages does not apply even though it would solve the issue if we could A rely on an updated version in Alpine and B LibreSign to actually use the shipped version.

There is another solution just by LibreSign to actually download a fitting release depending on the distro / c-library it finds. Details and a Workaround for now I have listed here in the feature request: https://github.com/LibreSign/libresign/issues/3026#issuecomment-2126754011

Persistence of the downloaded binaries in docker / Nextcloud-AIO is given by saving and using the extra binaries in the app data folder within the NCPATH.

vitormattos commented 6 months ago

I made this change:

I wish to launch a new RC today to be more easy to test, but if possible, would be best getting the changes of this PR and making a test changing the file in your environment and launch a new stable release.

vitormattos commented 6 months ago

Could you check again at the newest release of LibreSign?

martin-77 commented 6 months ago

had to remove previous install and run occ files:scan-app-data libresign but then, installation was possible without any problems! Thanks a lot!

neocult-de commented 6 months ago

The bugfix is out and working. So update the app via the AppStore and for making it work because the old checksum might be still there in the files follow the general reinstall procedure:

occ libresign:uninstall --all occ files:scan-app-data libresign occ libresign:install --all # Or use the web interface to install binaries


It works on Nextcloud-AIO stable (Nextcloud 28.0.5) that LibreSign 8.0.2 is correctly backported. A uninstall --all and reinstall via the web interface and via command line both works. A reinstallation of java by itself as well.

It works as well on Nextcloud-AIO with manual update to Nextcloud 29.0.0 and with LibreSign 9.0.2 in the same way.

Both were directly installed with the release from the App Store

vitormattos commented 6 months ago

Closing this issue as solved 🎉

Thanks a lot by contribution of all that give a comment at this issue.

If this issue persists, don't hesitate to open a new issue making reference to this.

[!NOTE]

If you like this app, don't hesitate to help us

Ways to help this project: