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

java.jang.UnsatisfiedLinkError in macOS Monterey (Apple Silicon) #8

Closed
bjeanes opened this issue Aug 25, 2022 · 5 comments
Closed

java.jang.UnsatisfiedLinkError in macOS Monterey (Apple Silicon) #8

bjeanes opened this issue Aug 25, 2022 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@bjeanes
Copy link

bjeanes commented Aug 25, 2022

Describe the bug

Double-clicking (after right-click > open for first time launch) crashes with an error asking to look at console.

Executing from CLI:

java -jar ~/Downloads/ModbusMechanic/ModbusMechanic.jar
Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: /var/folders/tb/dc9bcxw57mlf9_5s6ffd1kx80000gn/T/jna--87988168/jna12023659475483233029.tmp
	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2398)
	at java.base/java.lang.Runtime.load0(Runtime.java:785)
	at java.base/java.lang.System.load(System.java:1979)
	at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:761)
	at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:736)
	at com.sun.jna.Native.<clinit>(Native.java:131)
	at jtermios.macosx.JTermiosImpl.<clinit>(JTermiosImpl.java:55)
	at jtermios.JTermios.<clinit>(JTermios.java:317)
	at purejavacomm.CommPortIdentifier$1.<init>(CommPortIdentifier.java:200)
	at purejavacomm.CommPortIdentifier.getPortIdentifiers(CommPortIdentifier.java:193)
	at com.intelligt.modbus.jlibmodbus.serial.SerialPortFactoryPJC.getPortIdentifiersImpl(SerialPortFactoryPJC.java:45)
	at com.intelligt.modbus.jlibmodbus.serial.SerialPortAbstractFactory.getPortIdentifiers(SerialPortAbstractFactory.java:55)
	at com.intelligt.modbus.jlibmodbus.serial.SerialUtils.getPortIdentifiers(SerialUtils.java:67)
	at modbusmechanic.ModbusMechanic.getPortNames(ModbusMechanic.java:131)
	at modbusmechanic.PacketFrame.getPortNames(PacketFrame.java:1662)
	at modbusmechanic.PacketFrame.initComponents(PacketFrame.java:239)
	at modbusmechanic.PacketFrame.<init>(PacketFrame.java:74)
	at modbusmechanic.ModbusMechanic.main(ModbusMechanic.java:114)

Setting class path explicitly to the included lib directory does not change the error.

To Reproduce

I merely unzipped the latest release, and then as above.

Expected behavior

App launches

Screenshots

The pop-up macOS gave about looking at console only happened on first launching via right-click > Open and confirming. Unfortunately it doesn't pop up again so I can't get a screenshot

Desktop (please complete the following information):

  • OS: macOS
  • Version: Monterey (12.4)
  • Arch: M1 Max (Apple Silicon)

Java Runtime Version

Additional context

❯ java --version
openjdk 18.0.1 2022-04-19
OpenJDK Runtime Environment Homebrew (build 18.0.1+0)
OpenJDK 64-Bit Server VM Homebrew (build 18.0.1+0, mixed mode, sharing)
@bjeanes
Copy link
Author

bjeanes commented Aug 25, 2022

I also tried installing a different version of OpenJDK from the link in the README and had the same output there:

/Library/Java/JavaVirtualMachines/openjdk.jdk/Contents/Home/bin/java -jar ~/Downloads/ModbusMechanic/ModbusMechanic.jar
Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: /var/folders/tb/dc9bcxw57mlf9_5s6ffd1kx80000gn/T/jna--87988168/jna2915415394505014223.tmp
	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2398)
	at java.base/java.lang.Runtime.load0(Runtime.java:785)
	at java.base/java.lang.System.load(System.java:1979)
	at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:761)
	at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:736)
	at com.sun.jna.Native.<clinit>(Native.java:131)
	at jtermios.macosx.JTermiosImpl.<clinit>(JTermiosImpl.java:55)
	at jtermios.JTermios.<clinit>(JTermios.java:317)
	at purejavacomm.CommPortIdentifier$1.<init>(CommPortIdentifier.java:200)
	at purejavacomm.CommPortIdentifier.getPortIdentifiers(CommPortIdentifier.java:193)
	at com.intelligt.modbus.jlibmodbus.serial.SerialPortFactoryPJC.getPortIdentifiersImpl(SerialPortFactoryPJC.java:45)
	at com.intelligt.modbus.jlibmodbus.serial.SerialPortAbstractFactory.getPortIdentifiers(SerialPortAbstractFactory.java:55)
	at com.intelligt.modbus.jlibmodbus.serial.SerialUtils.getPortIdentifiers(SerialUtils.java:67)
	at modbusmechanic.ModbusMechanic.getPortNames(ModbusMechanic.java:131)
	at modbusmechanic.PacketFrame.getPortNames(PacketFrame.java:1662)
	at modbusmechanic.PacketFrame.initComponents(PacketFrame.java:239)
	at modbusmechanic.PacketFrame.<init>(PacketFrame.java:74)
	at modbusmechanic.ModbusMechanic.main(ModbusMechanic.java:114)

@SciFiDryer
Copy link
Owner

Hi,

Thanks for reporting the issue. I did some research and this appears to be related to that JNA version not supporting the Apple Silicon architecture. I'll update JNA to a newer version which should resolve the error in the next release. If you want to update it on your own as a provisional workaround, just replace the JNA bundle with 5.7.0 or newer and update the manifest.txt to include the library's path. I only have access to x86 Apple hardware, so I cannot test.

@SciFiDryer SciFiDryer added the bug Something isn't working label Aug 26, 2022
@bjeanes
Copy link
Author

bjeanes commented Aug 26, 2022

Unfortunately it may not be that simple. I am guessing that JNA might have some breaking API changes, because it changes the error to:

java -jar /Applications/ModbusMechanic/ModbusMechanic.jar
Exception in thread "main" java.lang.NoSuchMethodError: 'void com.sun.jna.Native.setPreserveLastError(boolean)'
	at jtermios.macosx.JTermiosImpl.<clinit>(JTermiosImpl.java:55)
	at jtermios.JTermios.<clinit>(JTermios.java:317)
	at purejavacomm.CommPortIdentifier$1.<init>(CommPortIdentifier.java:200)
	at purejavacomm.CommPortIdentifier.getPortIdentifiers(CommPortIdentifier.java:193)
	at com.intelligt.modbus.jlibmodbus.serial.SerialPortFactoryPJC.getPortIdentifiersImpl(SerialPortFactoryPJC.java:45)
	at com.intelligt.modbus.jlibmodbus.serial.SerialPortAbstractFactory.getPortIdentifiers(SerialPortAbstractFactory.java:55)
	at com.intelligt.modbus.jlibmodbus.serial.SerialUtils.getPortIdentifiers(SerialUtils.java:67)
	at modbusmechanic.ModbusMechanic.getPortNames(ModbusMechanic.java:131)
	at modbusmechanic.PacketFrame.getPortNames(PacketFrame.java:1662)
	at modbusmechanic.PacketFrame.initComponents(PacketFrame.java:239)
	at modbusmechanic.PacketFrame.<init>(PacketFrame.java:74)
	at modbusmechanic.ModbusMechanic.main(ModbusMechanic.java:114)

@SciFiDryer
Copy link
Owner

I was able to reproduce that exact error in 2.2 after replacing the JNA library. I updated the upstream serial library for the new API bindings and I no longer got errors with the newer JNA in v2.2.1 which is now posted. Now that it launches, 2.2.1 should support your M1 arch. Let me know if you still get errors.

@bjeanes
Copy link
Author

bjeanes commented Aug 26, 2022

Yes! It works, thank you :)

@bjeanes bjeanes closed this as completed Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants