LSOpenURLsWithRole() failed with error -10810 Downloaded and installed the AirStream application, and when I launched it nothing happens. In Terminal the output is

$ open /opt/homebrew-cask/Caskroom/airstream/latest/AirStream.app
LSOpenURLsWithRole() failed with error -10810 for the file /opt/homebrew-cask/Caskroom/airstream/latest/AirStream.app.


This seems to be a Java stub/launcher

$ file /opt/homebrew-cask/Caskroom/airstream/latest/AirStream.app/Contents/MacOS/JavaApplicationStub 
/opt/homebrew-cask/Caskroom/airstream/latest/AirStream.app/Contents/MacOS/JavaApplicationStub: Mach-O universal binary with 2 architectures
/opt/homebrew-cask/Caskroom/airstream/latest/AirStream.app/Contents/MacOS/JavaApplicationStub (for architecture i386):  Mach-O executable i386
/opt/homebrew-cask/Caskroom/airstream/latest/AirStream.app/Contents/MacOS/JavaApplicationStub (for architecture x86_64):    Mach-O 64-bit executable x86_64
Lees-MacBook-Pro:Casks hanxue$ oprn /opt/homebrew-cask/Caskroom/airstream/latest/AirStream.app/Contents/MacOS/JavaApplicationStub 


When I manually run it

$ open /opt/homebrew-cask/Caskroom/airstream/latest/AirStream.app/Contents/MacOS/JavaApplicationStub 


This is the result

/opt/homebrew-cask/Caskroom/airstream/latest/AirStream.app/Contents/MacOS/JavaApplicationStub ; exit;
$ /opt/homebrew-cask/Caskroom/airstream/latest/AirStream.app/Contents/MacOS/JavaApplicationStub ; exit;
JavaVM: Failed to load JVM: /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/bundle/Libraries/libserver.dylib
JavaVM: Failed to load JVM: /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/bundle/Libraries/libserver.dylib
JavaVM FATAL: Failed to load the jvm library.
[JavaAppLauncher Error] JNI_CreateJavaVM() failed, error: -1
logout


Java is properly installed, and I have other Java applications running without a hitch. How do I solve this error?
The error occurs because JVM failed to launch - the Java application itself has been hardcoded to load libserver.dylib. This file exist for Java 1.6 and older, but not for Java 1.7 and above. 

Workaround

Create the directory structure and symlink from libjvm.dylib to libserver.dylib

$ sudo mkdir -p /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/bundle/Libraries/
$ sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/jre/lib/server/libjvm.dylib /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/bundle/Libraries/libserver.dylib


Note that this is specific to JDK 1.8.0 update 5. The paths will need to be updated in three places for future versions.

Solution

Modify the Java application's code so that it will not look for libserver.dylib. You should really not hard-code the path to JVM. Instead, use /usr/libexec/java_home if you need the path of JVM in OSX.