Skip to content

Instantly share code, notes, and snippets.

@alexalouit
Last active February 12, 2021 15:52
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save alexalouit/a857a6de10dfdaf7485f7c0cccadb98c to your computer and use it in GitHub Desktop.
Save alexalouit/a857a6de10dfdaf7485f7c0cccadb98c to your computer and use it in GitHub Desktop.
fix Logstash error "logstash load error: ffi/ffi -- java.lang.NullPointerException: null" on Raspbian
#!/bin/bash
# based on https://github.com/mew2057/CAST/blob/6c7f7d514b7af3c512635ec145aa829c535467dc/csm_big_data/config-scripts/logstashFixupScript.sh
# see: https://github.com/elastic/logstash/issues/10755
apt-get update
apt-get install -f zip unzip
STARTDIR=$(pwd)
JARDIR="/usr/share/logstash/logstash-core/lib/jars"
JAR="jruby-complete-9.2.9.0.jar"
JRUBYDIR="${JAR}-dir"
PLATDIR="META-INF/jruby.home/lib/ruby/stdlib/ffi/platform/arm-linux"
cd ${JARDIR}
unzip -d ${JRUBYDIR} ${JAR}
cd "${JRUBYDIR}/${PLATDIR}"
cp -n types.conf platform.conf
cd "${JARDIR}/${JRUBYDIR}"
zip -r ${JAR} *
mv -f ${JAR} ..
cd ${JARDIR}
rm -rf ${JRUBYDIR}
chown logstash:logstash ${JAR}
sync
sync
cd ${STARTDIR}
@osuide
Copy link

osuide commented Jun 3, 2020

I ran the fix but still have the load error. Fix runs successfully and adds a platform.conf
What am I missing? Please assist.
PI4 with Ubuntu.

@gwsales
Copy link

gwsales commented Jun 3, 2020

@osuide check the version or checkout this fix.sh that can help you with with newer versions (9.2.9.0+) for jruby / logstash:
https://gist.github.com/gwsales/5a27e6282063f902014d851247c5f448. There has been recent logstash releases that could be using a different version of jruby.

@osuide
Copy link

osuide commented Jun 3, 2020

@gwsales I did manually update my script to ~11.1
It ran successfully and I have confirmed by unzipping the jar file that platfom.conf was actually added to the .jar.

@gwsales
Copy link

gwsales commented Jun 3, 2020

Current release for jruby included in logstash: jruby-complete-9.2.11.1.jar

This script should be updated to auto discover jruby version with a find. I'll get around to it when I have time.

@gwsales
Copy link

gwsales commented Jun 3, 2020

This should work:

JAR=$(basename $(find /usr/share/logstash/logstash-core/lib/jars/ -name "jruby-complete*.jar"))

@kolyan-skalny
Copy link

Thanks, working also for jruby-complete-9.2.11.1.jar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment