Description
Original report by Anton Folumenov (Bitbucket: Anton Folumenov).
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 #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)