SystemTray
SystemTray copied to clipboard
SystemTray 4.1 does not seem to work on MacOS
Hello,
I'll try to describe the issue as best I can, and will also attach a project that reproduces the same issue or something at least similar, as I might have done something incorrectly.
We've been using SystemTray 3.17 and it has been working for us, but now we needed to add a notification to our application as well.
It seems that there was a conflict between Notification 3.7 and SystemTray 3.17, so we updated to version 4.1 and that resolved the conflict, however we have encountered several issues, the major one was that the application will no longer run on Mac machines due to an error coming from SystemTray.
2021-05-26 13:27:51.859 ERROR d.s.SystemTray Unable to create tray type: '_OsxNativeTray'
java.lang.reflect.InvocationTargetException: null
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at dorkbox.systemTray.SystemTray.get(SystemTray.java:783)
at dorkbox.systemTray.SystemTray.get(SystemTray.java:170)
at io.testproject.agent.launcher.Application.lambda$showSysTrayIcon$1(Application.java:319)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:830)
Caused by: java.lang.UnsatisfiedLinkError: /Users/user_name/Library/Caches/JNA/temp/jna11908943634558871412.tmp: dlopen(/Users/user_name/Library/Caches/JNA/temp/jna11908943634558871412.tmp, 1): no suitable image found. Did find:
/Users/user_name/Library/Caches/JNA/temp/jna11908943634558871412.tmp: code signature in (/Users/user_name/Library/Caches/JNA/temp/jna11908943634558871412.tmp) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2440)
at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2497)
at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2694)
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2627)
at java.base/java.lang.Runtime.load0(Runtime.java:744)
at java.base/java.lang.System.load(System.java:1873)
at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:1019)
at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:989)
at com.sun.jna.Native.<clinit>(Native.java:195)
at dorkbox.jna.macos.foundation.ObjectiveC.<clinit>(ObjectiveC.java:50)
at dorkbox.jna.macos.cocoa.NSObject.<clinit>(NSObject.java:27)
at dorkbox.systemTray.ui.osx.OsxMenu.<init>(OsxMenu.java:36)
at dorkbox.systemTray.ui.osx.OsxMenu.<init>(OsxMenu.java:51)
at dorkbox.systemTray.ui.osx._OsxNativeTray$1.<init>(_OsxNativeTray.java:70)
at dorkbox.systemTray.ui.osx._OsxNativeTray.<init>(_OsxNativeTray.java:70)
... 12 common frames omitted
Is the error we are seeing when running the application on MacOS (BigSur not an M1 chip). The application works fine on Linux and Windows machines.
These are the dependencies of the project:
implementation 'com.dorkbox:SystemTray:4.1'
compile group: 'com.dorkbox', name: 'Notify', version: '3.7'
I've created a smaller separate project which functions on a similar premise, it will create a system tray icon, and then show a toast message.
I should note that trying to use an image for the system tray icon the code will throw an exception with a missing method exception, so I used a tooltip instead.
This project will run fine on Windows, but will fail on MacOS with the following exception:

I am attaching the project here. NotificationPopUps.zip
Am I missing some other dependency? I've tried using:
Dorkbox-SystemTray-Util:2.20
And
com.dorkbox:Utilities:1.12
And these just cause other conflicts.
Again, I apologize if I've done anything incorrectly, I just can't seem to understand what is causing this problem.
facing the same issue in my app, and there's a potential fix in there too: https://github.com/Suwayomi/Tachidesk/issues/120 probably some internal api changed and SytemTray is misusing it?
forcing AWT seems to fix the issue?
if (System.getProperty("os.name").startsWith("Mac")) {
SystemTray.FORCE_TRAY_TYPE = SystemTray.TrayType.Awt
}
I hit this problem today, and
if (System.getProperty("os.name").startsWith("Mac")) {
SystemTray.FORCE_TRAY_TYPE = SystemTray.TrayType.Awt
}
Allows me to progress forward, so thanks for the tip :D
Sorry this took so long, but it was not easy. I have figured out what exactly is going on, and how to work-around it. macos11 (Big Sur) changed how to create UI elements.