Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
TheNopePlant opened this issue Oct 2, 2021 · 7 comments

Comments

@TheNopePlant
Copy link

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
Copy link
Owner

What version of Raspberry Pi are you running on?

@lukehutch
Copy link
Owner

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

@TheNopePlant
Copy link
Author

TheNopePlant commented Oct 2, 2021

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
Copy link
Owner

lukehutch commented Oct 2, 2021

OK, so running as root has no problems then? Related bug: Pi4J/pi4j-v2#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:

  • git clone https://github.com/lukehutch/Adafruit-OLED-Bonnet-Toolkit.git
  • cd Adafruit-OLED-Bonnet-Toolkit ; mvn install ; cd ..
  • git clone https://github.com/lukehutch/usb-copier.git
  • Then copy target/usb-copier-0.0.2-jar-with-dependencies.jar to /home/pi on the Raspberry Pi.

On the Raspberry Pi:

  • Run raspi-config and enable Interfacing Options -> Advanced Options -> i2c
  • apt-get install openjdk-11-jdk wiringpi pigpio nano udevil
  • sudo nano /etc/cmdline.txt
    • add kernel option: (otherwise GPIO handler cannot access /dev/mem)
      • iomem=relaxed
  • sudo nano /etc/config.txt
    • add options:
      • dtparam=i2c_arm=on
      • dtparam=i2c_baudrate=1000000
  • Extract libpi4j-pigpio.so to /home/pi (this is needed due to a bug in the library loading code)
    • cd ; unzip -j /path/to/usb-copier-0.0.2-jar-with-dependencies.jar lib/armhf/libpi4j-pigpio.so
  • Add to /etc/rc.local :
    • sudo bash -c 'nohup java -Dpi4j.library.path=/home/pi -jar /home/pi/usb-copier-0.0.2-jar-with-dependencies.jar &'

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

@TheNopePlant
Copy link
Author

TheNopePlant commented Oct 2, 2021

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
Copy link
Author

TheNopePlant commented Oct 2, 2021

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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants