Skip to content

Instantly share code, notes, and snippets.

@alexalouit

alexalouit/fix.sh

Last active Aug 25, 2020
Embed
What would you like to do?
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}
@gwsales

This comment has been minimized.

Copy link

@gwsales gwsales commented Feb 27, 2020

Getting an error:
unzip: cannot find or open jruby-complete-9.2.7.0.jar, jruby-complete-9.2.7.0.jar.zip or jruby-complete-9.2.7.0.jar.ZIP.

@gwsales

This comment has been minimized.

Copy link

@gwsales gwsales commented Feb 27, 2020

current jruby in JARDIR is jruby-complete-9.2.9.0.jar

May also want to add a way to use the version var in lines 21, 22, and 26 so you only have to change this in one place.

@beirtipol

This comment has been minimized.

Copy link

@beirtipol beirtipol commented Apr 21, 2020

Many thanks for this! Helped me build my own Logstash image for my PI4

@parthdmaniar

This comment has been minimized.

Copy link

@parthdmaniar parthdmaniar commented Jun 2, 2020

Thank you very much.

@osuide

This comment has been minimized.

Copy link

@osuide 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

This comment has been minimized.

Copy link

@gwsales 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

This comment has been minimized.

Copy link

@osuide 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

This comment has been minimized.

Copy link

@gwsales 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

This comment has been minimized.

Copy link

@gwsales gwsales commented Jun 3, 2020

This should work:

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

This comment has been minimized.

Copy link

@kolyan-skalny kolyan-skalny commented Jun 14, 2020

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
You can’t perform that action at this time.