Search code examples
javamacosjpackage

LSOpenURLsWithRole() failed with error -10810 for an application built with jpackage


Not long ago I built my application installer with jpackage.

I tested it on my development machine (macos version 10.15.2) and on another slightly older machine (macos version 10.12.6). On both machines the program ran perfectly.

As since this last test my program has evolved, I wanted to repeat this deployment test. On my development machine everything is going as expected while on the other machine I now get this message:

"LSOpenURLsWithRole() failed with error -10810 for the file /Applications/myApplication.app."

The only trace I could find (in /var/log/system.log) is like this: "Jul 23 12:03:29 iMac com.apple.xpc.launchd 1 (com.myAppPackage.main.24860 [4219]): Service exited with abnormal code: 1"

Which doesn't mean much to me.

As I assumed at the beginning that the cause of the problem was with the new code, I tried to test with traces by simplifying more and more the code until finally arriving at an even simpler version (very simple) than the one that had performed correctly the first time. But still the same scenario, on my machine the application starts without problem and on the other machine there is this error -10810.

On the other hand, if on the second machine I run the jar file everything runs normally.

I don't know if anything has changed on the second machine but now I feel like everything I build with jpackage refuses to run on that machine. I also have a feeling that the Java code is not even running or is not causing the problem.

It is not blocking for the moment but it is a little alarming for the continuation if no solution appears.

If anyone has an idea or even information on how to investigate I welcome them.

Here is an example to reproduce :

The main class and the JavaFx window (no package)

public class MainApp {
    
    private static MainApp singleton;
    
    public static void main(String[] args) {
        singleton = new MainApp();
        BootLogs.inition(args, singleton);
    }

    public void bootInit() {
        BootLogs.addText("Enter main().");
    }
}
import java.io.PrintWriter;
import java.io.StringWriter;

import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.control.TextArea;
import javafx.scene.layout.Priority;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class BootLogs extends Application {

    private static MainApp mainApp;
    
    private static BootLogs singleton;
    
    private VBox messageVbox = new VBox();
    private TextArea txtArea = new TextArea();
    
    public static void inition(final String[] args, final MainApp mainApp) {
        BootLogs.mainApp = mainApp;
        launch(args);
    }
    
    @Override
    public void start(Stage stage) throws Exception {
        singleton = this;
        
        stage.setTitle("Boot logs");
        
        StackPane root = new StackPane();
        root.setStyle("-fx-border-width: 30;-fx-border-color: gray;");
        root.getChildren().add(messageVbox);
        
        messageVbox.getChildren().add(txtArea);
        
        VBox.setVgrow(txtArea, Priority.ALWAYS);
        txtArea.setEditable(false);
        
          
        stage.setScene(new Scene(root, 450, 450));
        stage.centerOnScreen();
        messageVbox.setVisible(true);
        
        Platform.setImplicitExit(true);
        Platform.runLater(() -> mainApp.bootInit());
        
        stage.show();
    }

    public static void addText(String txt) {
        singleton.txtArea.setText(singleton.txtArea.getText() + "\n" + txt);
    }
    
    public static void addText(String txt, Throwable e) {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        e.printStackTrace(pw);
        singleton.txtArea.setText(singleton.txtArea.getText() + "\n" + txt + pw.toString() + "\n");
    }
}

The build.gradle file :

plugins {
    // Apply the java-library plugin for API and implementation separation.
    id 'java-library'
    id 'eclipse'
    
    //Plugin javafx.
    id 'org.openjfx.javafxplugin' version '0.0.10'
}

repositories {
    // Use JCenter for resolving dependencies.
    jcenter()
}

dependencies {
    
    testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.2")
    testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.2")
    
}

javafx {
    version = "11"
    modules = [ 'javafx.controls', 'javafx.fxml', 'javafx.swing' ]
}

tasks.named('jar') {
    
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
    
    inputs.files( configurations.runtimeClasspath )

    manifest {
        attributes('Implementation-Title': project.name,
                   'Implementation-Version': '1.0',
                   'Main-Class': 'MainApp')
    }
        
    from {
        configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
    }
}

The jpackage options (the eclipse project name is ZD) :

/Library/Java/JavaVirtualMachines/zulu15.32.15-ca-jdk15.0.3-macosx_x64/zulu-15.jdk/Contents/Home/bin/jpackage \
-i /Users/ ... /ZD/external_resources \
-n AppTest \
--main-class MainApp \
--main-jar /Users/ ... /ZD/app/build/libs/app.jar \
--icon /Users/ ... /ZDInstaller/AnyConv.com__graou_logo_77_66_0.icns

The installation of MainApp on the two machines is done without problem.

Here is the application launched on my machine:

enter image description here

But on the other machine (I tested the example shown here too) there is still the error -10810. I remind you that 3 to 4 weeks ago, much less simple code had worked.


Solution

  • I don't know if this is the best solution but I think I have found a solution.

    The executable installed from a ".dmg" created with jpackage in a macos version 10.15 works on this version 10.15 but not on a version 10.12. And it turns out that the converse is true: The executable installed from a ".dmg" created with jpackage in a macos 10.12 version works on version 10.12 but not on version 10.15.

    Even if I haven't checked with other versions, there is a good chance that an executable will work in a macos version you have to build the ".dmg" via jpackage in the same macos version.