lukehutch / usb-copier

USB drive copier example project for Raspberry Pi with the Adafruit 128x64 bonnet
MIT License
18 stars 7 forks source link

Failed to start build jar file - Failed to load class "org.slf4j.impl.StaticLoggerBinder" #2

Open TheNopePlant opened 2 years ago

TheNopePlant commented 2 years ago

Issue arrises when trying to load final compiled build on the raspberry pi

java -jar usb-copier-0.0.2-jar-with-dependencies.jar [2021-10-02 08:54:43 625] [INFO ] Initializing Bonnet SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Exception in thread "main" java.lang.ExceptionInInitializerError at aobtk.hw.Bonnet.(Bonnet.java:106) at aobtk.hw.Bonnet.(Bonnet.java:75) at main.Main.main(Main.java:75) Caused by: java.lang.RuntimeException: Could not set up digital input 4 at aobtk.hw.HWButton.(HWButton.java:65) at aobtk.hw.HWButton.(HWButton.java:47) ... 3 more Caused by: java.lang.reflect.UndeclaredThrowableException at com.sun.proxy.$Proxy1.create(Unknown Source) at com.pi4j.context.Context.create(Context.java:325) at com.pi4j.internal.IOCreator.create(IOCreator.java:58) at com.pi4j.internal.IOCreator.create(IOCreator.java:106) at aobtk.hw.HWButton.(HWButton.java:62) ... 4 more Caused by: java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at com.pi4j.provider.impl.ProviderProxyHandler.invoke(ProviderProxyHandler.java:100) ... 9 more Caused by: com.pi4j.library.pigpio.PiGpioException: PIGPIO ERROR: PI_INIT_FAILED; pigpio initialisation failed at com.pi4j.library.pigpio.impl.PiGpioBase.validateResult(PiGpioBase.java:263) at com.pi4j.library.pigpio.impl.PiGpioBase.validateResult(PiGpioBase.java:249) at com.pi4j.library.pigpio.impl.PiGpioNativeImpl.gpioInitialise(PiGpioNativeImpl.java:95) at com.pi4j.library.pigpio.PiGpio.initialize(PiGpio.java:146) at com.pi4j.plugin.pigpio.provider.gpio.digital.PiGpioDigitalInputProviderImpl.create(PiGpioDigitalInputProviderImpl.java:60) at com.pi4j.plugin.pigpio.provider.gpio.digital.PiGpioDigitalInputProviderImpl.create(PiGpioDigitalInputProviderImpl.java:41) ... 14 more

lukehutch commented 2 years ago

What version of Raspberry Pi are you running on?

lukehutch commented 2 years ago

Also, please try running this project as root -- that may solve the problem.

TheNopePlant commented 2 years ago

Running RPi Zero W. 2017 date code, not sure of revision of board however. EDIT: It is a V1.1 board

Running as root does launch, however it will not start as root on boot

lukehutch commented 2 years ago

OK, so running as root has no problems then? Related bug: https://github.com/Pi4J/pi4j-v2/issues/60

Here are my notes for how to install the USB copier project, and get it running at boot. Sorry that this is not documented yet!

On the build machine:

On the Raspberry Pi:

Some steps may need to be tweaked a little, I'm not sure. Please let me know if this works.

TheNopePlant commented 2 years ago

1 issue when loading as root manually.

pi@toastdoom:~ $ sudo java -jar usb-copier-0.0.2-jar-with-dependencies.jar [2021-10-02 10:23:23 592] [INFO ] Initializing Bonnet SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. [2021-10-02 10:23:28 851] [FINE ] Opening I2C bus 1 [2021-10-02 10:23:29 051] [FINE ] Opened I2C bus 1, device 0x3c`

However this does load the display, mount drives and allows me to copy without any issues.

Have since added the line to /etc.rc.local (see below):

!/bin/sh -e rc.local This script is executed at the end of each multiuser runlevel. Make sure that the script will "exit 0" on success or any other value on error. In order to enable or disable this script just change the execution bits.

By default this script does nothing. Print the IP address _IP=$(hostname -I) || true if [ "$_IP" ]; then printf "My IP address is %s\n" "$_IP" fi

exit 0

sudo bash -c 'nohup java -Dpi4j.library.path=/home/pi -jar /home/pi/usb-copier-0.0.2-jar-with-dependencies.jar &'

This still does not load on boot. Is it possible that the sudo bash script needs to be loaded before exit 0

TheNopePlant commented 2 years ago

Update:

Can confirm that you need to have sudo bash -c 'nohup java -Dpi4j.library.path=/home/pi -jar /home/pi/usb-copier-0.0.2-jar-with-dependencies.jar &' before exit 0 in the /etc/rc.local file.

Have since successfully booted to the usb-copier

lukehutch commented 2 years ago

Yes, correct, exit ends the script, so you need to put this before exit 0.