The public knowledge pool and discussion forum of the OWS community. Do not post confidential information here!
Janak Mulani
Posts: 758 Joined: 24 Mar 2020, 13:37
Post
by Janak Mulani » 02 Sep 2021, 14:38
An App that uses JavaFX WebView from OpenJfx when started with OWS, crashes as soon as a URL is loaded in the. WebView.
The JRE used to run the App is Java 11 or higher.
The OpneJfx lib versions tried were 11.0.2, and also 16.
Jnlp file: (Note that s_ prefix means signed jar)
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+">
<information>
<title>FXApp</title>
<vendor>Karakun AG</vendor>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.8+" />
<jar href="s_javafx-controls-16-win.jar"/>
<jar href="s_javafx-graphics-16-win.jar"/>
<jar href="s_javafx-base-16-win.jar"/>
<jar href="s_javafx-fxml-16-win.jar"/>
<jar href="s_javafx-web-16-win.jar"/>
<jar href="s_javafx-media-16-win.jar"/>
<jar href="s_javafx-swing-16-win.jar"/>
<jar href="javafx-test.jar"/>
</resources>
<application-desc main-class="com.karakun.ows.javafx_test.FXWebViewLauncher"/>
<!-- FXAppLauncher FXWebViewLauncher SwingFXAppLauncher SwingFXWebViewAppLauncher -->
</jnlp>
JavaFx App:
Code: Select all
public class FXWebViewApp extends Application {
public static void main(String[] args) {
launch(args);
}
public void start(Stage primaryStage) {
primaryStage.setTitle("JavaFX WebView Example");
final WebView webView = new WebView();
TextField text1 = new TextField();
text1.setTooltip(new Tooltip("Type Url without protocol"));
Button btn = new Button();
btn.setText("Load");
btn.setOnAction(e -> {
webView.getEngine().load("http://" + text1.getText());
}
);
//Creating a Grid Pane
GridPane gridPane = new GridPane();
//Setting size for the pane
gridPane.setMinSize(400, 200);
//Setting the padding
gridPane.setPadding(new Insets(10, 10, 10, 10));
//Setting the vertical and horizontal gaps between the columns
gridPane.setVgap(10);
gridPane.setHgap(5);
gridPane.setAlignment(Pos.CENTER);
gridPane.add(text1, 0, 0);
gridPane.add(btn, 0, 1);
gridPane.add(webView, 0, 2);
Scene scene = new Scene(gridPane, 960, 600);
primaryStage.setScene(scene);
primaryStage.show();
}
}
Janak Mulani
Posts: 758 Joined: 24 Mar 2020, 13:37
Post
by Janak Mulani » 02 Sep 2021, 14:52
It seems that the App with WebView was crashing on loading a URL because of bug OpenJfx. 11.0.2 to 16.
This bug has been fixed in OpenJfx v 17-ea+16.:So one can specify those jars in the jnlp file:
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+">
<information>
<title>FXApp</title>
<vendor>Karakun AG</vendor>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="11*" />
<jar href="s_javafx-controls-17-ea+16-win.jar"/>
<jar href="s_javafx-graphics-17-ea+16-win.jar"/>
<jar href="s_javafx-base-17-ea+16-win.jar"/>
<jar href="s_javafx-fxml-17-ea+16-win.jar"/>
<jar href="s_javafx-web-17-ea+16-win.jar"/>
<jar href="s_javafx-media-17-ea+16-win.jar"/>
<jar href="s_javafx-swing-17-ea+16-win.jar"/>
<jar href="javafx-test.jar"/>
</resources>
<application-desc main-class="com.karakun.ows.javafx_test.FXWebViewLauncher"/>
<!-- FXAppLauncher FXWebViewLauncher SwingFXAppLauncher SwingFXWebViewAppLauncher -->
</jnlp>
However When the above jnlp is run with OWS the App it self does not start complaining that JavaFx classes are not found. Log file:
Code: Select all
Launch Error: Could not launch JNLP file. ( (javafx/application/Application (javafx.application.Application)))
net.sourceforge.jnlp.LaunchException: Fatal: Launch Error: Could not launch JNLP file.
...
Caused by: java.lang.ClassNotFoundException: javafx.application.Application
Janak Mulani
Posts: 758 Joined: 24 Mar 2020, 13:37
Post
by Janak Mulani » 02 Sep 2021, 15:00
There is a bug in OWS 1.4.0 such that it is not able to handle jar file names like
javafx-controls-17-ea+16-win.jar . Character
+ in
ea+16 is problematic. It results in the following error:
Code: Select all
Error while activating jars
java.io.FileNotFoundException: <path>\s_javafx-controls-17-ea 16-win.jar
The workaround is to rename the OpenJfx jars and use the renamed jars in the jnlp file:
Code: Select all
...
<resources>
<j2se version="11*" />
<jar href="s_javafx-controls-17-win.jar"/>
<jar href="s_javafx-graphics-17-win.jar"/>
<jar href="s_javafx-base-17-win.jar"/>
<jar href="s_javafx-fxml-17-win.jar"/>
<jar href="s_javafx-web-17-win.jar"/>
<jar href="s_javafx-media-17-win.jar"/>
<jar href="s_javafx-swing-17-win.jar"/>
<jar href="javafx-test.jar"/>
</resources>
...