Can’t initialize JCEF in Mac OS Mojave with OpenJDK 11
My Java app which uses JCEF works fine in Windows and Linux with OpenJDK 11. Now I have to run it in Mac OS Mojave with OpenJDK 11, but I can’t do it due to the problem with JCEF initialization.
The sample app for Mac OS, created within the process of building JCEF from the sources, runs fine.
So, I guess two options:
- Maybe I doing JCEF initialization wrong in my app. So please help me to find the proper example of JCEF initialization in Mac OS.
- The current JCEF version cannot be initialized in Mac OS at all. It can be real, because I have standard Mac OS with standard JDK and performed standard steps to build and run JCEF.
I got several problems with code signing and with paths. There were no such problems neither in Windows or Linux, but I found solutions. But finally, my app fails to initialize JCEF at native-method CefApp#N_Initialize with the following error message:
When, app stops with the message in console:
Process finished with exit code 133 (interrupted by signal 5: SIGTRAP)
Here is my code of JCEF initialization method:
if (!CefApp.startup()) { System.out.println("Startup initialization failed!"); return; } CefApp cefApp; final CefSettings settings = new CefSettings(); settings.windowless_rendering_enabled = true; settings.remote_debugging_port = 9999; if (CefApp.getState() != CefApp.CefAppState.INITIALIZED) { cefApp = CefApp.getInstance(settings); } else { cefApp = CefApp.getInstance(); } CefClient cefClient = cefApp.createClient();
My app fails at the last line, regardless of CefSettings parameters.
I performed following steps:
1. built JCEF in my Mac OS in /Users/username/projects/jcef as described at https://bitbucket.org/chromiumembedded/java-cef/wiki/BranchesAndBuilding, section “Manual Building”, step 1.
2. Added JVM parameter to startup configuration, similar to configuration in Windows and Linux:
-Djava.library.path=/Users/username/projects/jcef/jcef_build/native/Release
And got exception:
Exception in thread "main" java.lang.UnsatisfiedLinkError: /Users/username/projects/jcef/jcef_build/native/Release/libjcef.dylib: dlopen(/Users/username/projects/jcef/jcef_build/native/Release/libjcef.dylib, 1): no suitable image found. Did find:
/Users/username/projects/jcef/jcef_build/native/Release/libjcef.dylib: code signature in (/Users/username/projects/jcef/jcef_build/native/Release/libjcef.dylib) 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.
When I tried to sign libjcef.dylib with ad-hoc signature using command:
sudo codesign -f -s - /Users/username/projects/jcef/jcef_build/native/Release/libjcef.dylib
, and got another code signature error, but nothing changed at all. When I completely disabled System Integrity Protection by csrutil disable
command in recovery mode (hold Command+R when power on and go to Utilities > Terminal) and became able to move forward.
3. The next error was:
dlopen /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/bin/../Frameworks/Chromium Embedded Framework.framework/Chromium Embedded Framework: dlopen(/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/bin/../Frameworks/Chromium Embedded Framework.framework/Chromium Embedded Framework, 261): image not found
Failed to load the CEF framework.
Due to unknown reason, JCEF was trying to find framework image in JDK's catalogue, instead of catalogue specified in java.library.path
. After several attempts to solve that, I copied entire framework into JDK's catalogue, from
/Users/username/projects/jcef/jcef_build/native/Release/jcef_app.app/Contents/Frameworks
to
/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/Frameworks
4.And got the error about icudtl.dat (it seems to be related to the 5 years old opened issue https://bitbucket.org/chromiumembedded/java-cef/issues/109/linux-mac-fix-discovery-of-icudtldat)::)
[0815/171724.303768:ERROR:icu_util.cc(136)] icudtl.dat not found in bundle
[0815/171724.304115:ERROR:icu_util.cc(172)] Invalid file descriptor to ICU data received.
So, I copied icudtl.dat from
/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/Frameworks/Chromium Embedded Framework.framework/Resources/icudtl.dat
to JDK’s directory:
/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/bin/icudtl.dat
Finally, after all actions above were performed, I started my app and it was aborted at method CefApp#N_Initialize with the message:
Process finished with exit code 133 (interrupted by signal 5: SIGTRAP)
Comments (8)
-
-
reporter I tried month ago with newer version of JCEF, but got the same result.
-
I am facing the same issue on MacOS Mojave with JDK 8.
Exception in thread "main" java.lang.UnsatisfiedLinkError: /jcef_build/native/Release/libjcef.dylib: dlopen(*/jcef_build/native/Release/libjcef.dylib, 1): Library not loaded: @rpath/Frameworks/Chromium Embedded Framework.framework/Chromium Embedded FrameworkReferenced from: */jcef_build/native/Release/libjcef.dylib
Reason: image not found
Did you manage to solve this issue?
-
Did you apply the related PR? https://bitbucket.org/chromiumembedded/java-cef/pull-requests/53
-
@bilal.iqbal Does that problem reproduce with the JCEF sample apps?
Note the build-related changes in 7f3a577a must also be applied to your application.
-
@Marshall Greenblatt i git clone the code from this repository and followed the mentioned instruction for manual build on MacOS:
https://bitbucket.org/chromiumembedded/java-cef/wiki/BranchesAndBuilding
When i try to run sample application the issue # 109 reproduced, https://bitbucket.org/chromiumembedded/java-cef/issues/109 , even after trying your suggested directory structure and run.sh script i am unable to run a successful initialization. Am i missing something? Please suggest. I am susing JDK 1.8.0_221 and Mac OS 10.14.6. Thanks -
Also having this issue on Mac OS 10.15.4 and openjdk version "11.0.5" 2019-10-15 using the latest commit.
Attempting to run a test browser using the following arguments and adding the appropriate java.library.path.
When I attempt to run the program I get the same icudtl.dat discovery error from issue 109. I have also attempted using the library structure solution from 109 and get the same error.
The sample jcef_app however runs normally.
-
Issue
#385was marked as a duplicate of this issue. - Log in to comment
Were you able to solve your problem?