MacOS “LSOpenURLsWithRole() failed with error”

Note to self: I often get the following Mac LSOpenURLsWithRole failed with error ... error message when trying to open a Java application I’ve just built on a Mac OS X system:

LSOpenURLsWithRole() failed with error -10810 for the file

This happens when I try to open my new application like this:

$ open release/BlueParrot.app
LSOpenURLsWithRole() failed with error -10810 for the file /Users/al/Projects/BlueParrot/release/BlueParrot.app.

Solution

The problem is that I’m usually missing one jar file or another in my application. For instance, I just mis-typed the name of a jar file in my Ant build.xml file, so while the build appeared to work properly, it really did not. The solution is to make sure all of the jar files are actually deployed to the Mac application build, i.e., under the Mac ’.app’ folder.

Update: This also happened to me when creating a Mac Java Swing application that needed "accessibility" permission. I got the usual -10810 error when trying to open the application, and only found the problem by looking at the /var/log/system.log file, where I found the error message pointing me in the right direction.