vivo-project/VIVO

Mac M1 chip

Closed this issue · 5 comments

Describe the bug
VIVO can't be built on mac M1 chip

To Reproduce
Steps to reproduce the behavior:

  1. mvn clean install
  2. See errors

Environment (please complete the following information):

  • OS: MacOS
  • VIVO version 1.15.0

Additional context
This issue is open for the needs of discussion and finding exact issue (for instance which dependency should be updated).

Failing tests during build:

[ERROR] Errors: 
[ERROR]   ProgramLoginTest.newPasswordEqualsOldPassword » NoClassDefFound Could not initialize class edu.cornell.mannlib.vitro.webapp.controller.authenticate.ProgramLoginTest
[ERROR]   ProgramLoginTest.newPasswordMissing » NoClassDefFound Could not initialize class edu.cornell.mannlib.vitro.webapp.controller.authenticate.ProgramLoginTest
[ERROR]   ProgramLoginTest.newPasswordNotNeeded » NoClassDefFound Could not initialize class edu.cornell.mannlib.vitro.webapp.controller.authenticate.ProgramLoginTest
[ERROR]   ProgramLoginTest.newPasswordTooLong » NoClassDefFound Could not initialize class edu.cornell.mannlib.vitro.webapp.controller.authenticate.ProgramLoginTest
[ERROR]   ProgramLoginTest.<clinit>:43->createUserAccount:102 » UnsatisfiedLink Can't load library: /var/folders/j0/j876tt4n21184ydf23m30q0m0000gq/T/jna--515919130/jna13933430274976356358.tmp
[ERROR]   ProgramLoginTest.noUsername » NoClassDefFound Could not initialize class edu.cornell.mannlib.vitro.webapp.controller.authenticate.ProgramLoginTest
[ERROR]   ProgramLoginTest.success » NoClassDefFound Could not initialize class edu.cornell.mannlib.vitro.webapp.controller.authenticate.ProgramLoginTest
[ERROR]   ProgramLoginTest.successWithNewPassword » NoClassDefFound Could not initialize class edu.cornell.mannlib.vitro.webapp.controller.authenticate.ProgramLoginTest
[ERROR]   ProgramLoginTest.unrecognizedUser » NoClassDefFound Could not initialize class edu.cornell.mannlib.vitro.webapp.controller.authenticate.ProgramLoginTest
[ERROR]   ProgramLoginTest.wrongPassword » NoClassDefFound Could not initialize class edu.cornell.mannlib.vitro.webapp.controller.authenticate.ProgramLoginTest
[ERROR]   AuthenticateTest.prepareUserAccounts:134->createUserFromUserInfo:212 » NoClassDefFound Could not initialize class de.mkammerer.argon2.Argon2Factory$Argon2Types

Example startup error if built skipping tests:

2023-10-09 16:06:45,612 ERROR [StartupManager] edu.cornell.mannlib.vitro.webapp.auth.policy.RootUserPolicy$Setup@41df5842 Threw unexpected error
java.lang.UnsatisfiedLinkError: Can't load library: /usr/local/tomcat/temp/jna--515919130/jna8069372811509798274.tmp

Forgive me if this as a tangent, possibly pointing to the cause.

I would check Tomcat 9 Openjdk 11 first. Vivo does not like later versions.

I do Vivo development on a M1 Apple & x86 ubuntu. But the build I use is https://github.com/uncw-library/vivo-docker2/ . (The "stock" branch is the most stable & simplest branch.)

One thought is you could git clone my repo, checkout the "stock" branch, then
docker build -t vivo-docker2/vivo ./vivo && docker build -t vivo-docker2/solr ./solr && docker compose up solr -d && sleep 30 && docker compose up -d
And compare the dependencies within vivo-docker2/vivo (or vivo-docker2/solr) versus your machine.

@GarrettArm Thanks, I will give the docker a shot if these issues can't sorted natively. I did try to build using OpenJDK 11 without success.

We are keeping this ticket open for the discussion about any issue linked with running VIVO at M1 chip. If there is no any complaint in the next three months we will close this ticket as resolved.

Per @milospp's comment on vivo-project/Vitro#425, it's possible to install an x86_64 version of Java on an M1 machine (surprisingly). I was able to build and run VIVO once I did that. Not ideal, but a fine workaround for now.

For me...

$ /usr/libexec/java_home -V
Matching Java Virtual Machines (4):
    21 (arm64) "Homebrew" - "OpenJDK 21" /opt/homebrew/Cellar/openjdk/21/libexec/openjdk.jdk/Contents/Home
    20.0.2 (arm64) "Eclipse Adoptium" - "OpenJDK 20.0.2" /Library/Java/JavaVirtualMachines/temurin-20.jdk/Contents/Home
    17.0.9 (x86_64) "Eclipse Adoptium" - "OpenJDK 17.0.9" /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
    11.0.20.1 (arm64) "Homebrew" - "OpenJDK 11.0.20.1" /opt/homebrew/Cellar/openjdk@11/11.0.20.1/libexec/openjdk.jdk/Contents/Home

I changed Tomcat's JRE_HOME to the x86_64 option by setting it in /usr/local/tomcat/bin/setenv.sh
export JAVA_HOME=$(/usr/libexec/java_home -v17)