I'm having a problem running my JavaFX application on a MacBook Air with an M1 chip. When I try to launch my application, I get the following error:
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at [email protected]/javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1858)
at [email protected]/javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1726)
at [email protected]/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at [email protected]/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:232)
at [email protected]/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:189)
at [email protected]/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at [email protected]/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at [email protected]/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at [email protected]/javafx.event.Event.fireEvent(Event.java:198)
at [email protected]/javafx.scene.Scene$ClickGenerator.postProcess(Scene.java:3684)
at [email protected]/javafx.scene.Scene$MouseHandler.process(Scene.java:3989)
at [email protected]/javafx.scene.Scene.processMouseEvent(Scene.java:1890)
at [email protected]/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2704)
at [email protected]/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:411)
at [email protected]/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:301)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
at [email protected]/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:450)
at [email protected]/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:424)
at [email protected]/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:449)
at [email protected]/com.sun.glass.ui.View.handleMouseEvent(View.java:551)
at [email protected]/com.sun.glass.ui.View.notifyMouse(View.java:937)
at [email protected]/com.sun.glass.ui.mac.MacView.notifyMouse(MacView.java:127)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:119)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at com.sun.javafx.reflect.Trampoline.invoke(MethodUtil.java:72)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at [email protected]/com.sun.javafx.reflect.MethodUtil.invoke(MethodUtil.java:270)
at [email protected]/com.sun.javafx.fxml.MethodHelper.invoke(MethodHelper.java:84)
at [email protected]/javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1853)
... 27 more
Caused by: java.lang.UnsatisfiedLinkError: /private/var/folders/pd/n13rr22d0wd6c9wc7x0mcmz00000gn/T/jna-445275207/jna5093040430395823145.tmp: dlopen(/private/var/folders/pd/n13rr22d0wd6c9wc7x0mcmz00000gn/T/jna-445275207/jna5093040430395823145.tmp, 0x0001): tried: '/private/var/folders/pd/n13rr22d0wd6c9wc7x0mcmz00000gn/T/jna-445275207/jna5093040430395823145.tmp' (fat file, but missing compatible architecture (have 'i386,x86_64,unknown', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/private/var/folders/pd/n13rr22d0wd6c9wc7x0mcmz00000gn/T/jna-445275207/jna5093040430395823145.tmp' (no such file), '/private/var/folders/pd/n13rr22d0wd6c9wc7x0mcmz00000gn/T/jna-445275207/jna5093040430395823145.tmp' (fat file, but missing compatible architecture (have 'i386,x86_64,unknown', need 'arm64'))
at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:331)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:197)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:139)
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2404)
at java.base/java.lang.Runtime.load0(Runtime.java:817)
at java.base/java.lang.System.load(System.java:2015)
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 com.sun.jna.Pointer.<clinit>(Pointer.java:41)
at com.kosprov.jargon2.nativeri.backend.NativeRiJargon2Backend.copyToMemory(NativeRiJargon2Backend.java:274)
at com.kosprov.jargon2.nativeri.backend.NativeRiJargon2Backend.rawHash(NativeRiJargon2Backend.java:77)
at com.kosprov.jargon2.nativeri.backend.NativeRiJargon2Backend.encodedHash(NativeRiJargon2Backend.java:140)
at [email protected]/com.kosprov.jargon2.internal.Jargon2BackendAdapter.encodedHash(Jargon2BackendAdapter.java:33)
at [email protected]/com.kosprov.jargon2.internal.HasherImpl.encodedHash(HasherImpl.java:245)
at sio.projet_helport/sio.projet_helport.ConnexionController.btnValiderConnexion(ConnexionController.java:69)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
... 34 more
The problem seems to be related to an architectural incompatibility between the native library I'm trying to load and the M1 chip in my MacBook Air. I'm using JavaFX 20.0.1 and my operating system is macOS. I'm really stuck, especially since when I try on Windows everything's fine.
Here is my pom file:
...
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>5.9.2</junit.version>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>20.0.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>20.0.1</version>
</dependency>
<dependency>
<groupId>com.kosprov.jargon2</groupId>
<artifactId>jargon2-api</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.kosprov.jargon2</groupId>
<artifactId>jargon2-native-ri-backend</artifactId>
<version>1.1.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
...
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>20</source>
<target>20</target>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<executions>
<execution>
<!-- Default configuration for running with: mvn clean javafx:run -->
<id>default-cli</id>
<configuration>
<mainClass>sio.projet_helport/sio.projet_helport.HelloApplication</mainClass>
<launcher>app</launcher>
<jlinkZipName>app</jlinkZipName>
<jlinkImageName>app</jlinkImageName>
<noManPages>true</noManPages>
<stripDebug>true</stripDebug>
<noHeaderFiles>true</noHeaderFiles>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Here's my controller class where I use the dependency to hash a password:
...
public void btnValiderConnexion(Event event) {
byte[] password = txtPas.getText().getBytes();
// Configure the hasher
Hasher hasher = jargon2Hasher()
.type(Type.ARGON2i)
.memoryCost(65536)
.timeCost(3)
.parallelism(1)
.saltLength(16)
.hashLength(16);
String encodedHash = hasher.password(password).encodedHash();
System.out.printf("Hash: %s%n", encodedHash);
Verifier verifier = jargon2Verifier();
boolean matches = verifier.hash(encodedHash).password(password).verifyEncoded();
}
I've heard of Rosetta, but I'm not sure how useful it is in my case. Also, I'm having trouble activating it on IntelliJ. I've tried to activate Rosetta, but I can't find the feature on the application information page in IntelliJ. I'm at a loss as to how to solve this problem.
enter image description here : Comparison image between Safari where I have the option to launch with Rosetta and IntelliJ.