FULL PRODUCT VERSION :
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux core 3.19.0-51-generic #58~14.04.1-Ubuntu SMP Fri Feb 26 22:02:58 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
I packaged JavaFX in an OSGI bundle and using the WebView from and JFXPanel.
Loading external URLs with
webEngine.load(externalURL)
works without problems.
When trying to load bundled HTML resources in the webEngine only an empty scene is displayed, i.e. the resources from the bundle cannot be resolved.
I assume the problem is that the webview cannot resolve resource urls of the form
bundle://117.0:1/info.html
which are a result of the OSGI packaging.
No error message, just empty scene.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
- package javafx in an osgi bundle (required to provide access to the javafx components for class loader)
- package an html resource in the package (/src/main/resources/info.html)
- use the JavaFX tutorial/example for WebView and Browser
- try to loadPage from bundle in browser
URL queryURL = getClass().getResource("/info.html");
loadPage(queryURL.toString());
- white scene
Everything works when running same example as application without packaging as OSGI bundle.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The HTML resource should be displayed and referenced resources in the HTML should be resolved, i.e. if an image is referenced relative to the bundle HTML resource it should be resolved from the bundle also.
ACTUAL -
empty scene, nothing displayed
ERROR MESSAGES/STACK TRACES THAT OCCUR :
no error messages, not crash logs.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class Browser extends Region {
final WebView browser = new WebView();
final WebEngine webEngine = browser.getEngine();
public Browser() {
//apply the styles
getStyleClass().add("browser");
// external URLs work
// webEngine.load("http://sabiork.h-its.org/newSearch/index");
// String content works
// webEngine.loadContent("<html><h1>Hello world</h1></html>");
// Resource content does not work
URL queryURL = getClass().getResource("/info.html");
System.out.println(queryURL);
loadPage(queryURL.toString());
//add the web view to the scene
getChildren().add(browser);
}
private void loadPage(String url) {
Platform.runLater(new Runnable() {
@Override
public void run() {
webEngine.load(url);
}
});
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Required to extract all resources from jar in temporary folder on filesystem and reference the resources from there.
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux core 3.19.0-51-generic #58~14.04.1-Ubuntu SMP Fri Feb 26 22:02:58 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
I packaged JavaFX in an OSGI bundle and using the WebView from and JFXPanel.
Loading external URLs with
webEngine.load(externalURL)
works without problems.
When trying to load bundled HTML resources in the webEngine only an empty scene is displayed, i.e. the resources from the bundle cannot be resolved.
I assume the problem is that the webview cannot resolve resource urls of the form
bundle://117.0:1/info.html
which are a result of the OSGI packaging.
No error message, just empty scene.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
- package javafx in an osgi bundle (required to provide access to the javafx components for class loader)
- package an html resource in the package (/src/main/resources/info.html)
- use the JavaFX tutorial/example for WebView and Browser
- try to loadPage from bundle in browser
URL queryURL = getClass().getResource("/info.html");
loadPage(queryURL.toString());
- white scene
Everything works when running same example as application without packaging as OSGI bundle.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The HTML resource should be displayed and referenced resources in the HTML should be resolved, i.e. if an image is referenced relative to the bundle HTML resource it should be resolved from the bundle also.
ACTUAL -
empty scene, nothing displayed
ERROR MESSAGES/STACK TRACES THAT OCCUR :
no error messages, not crash logs.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class Browser extends Region {
final WebView browser = new WebView();
final WebEngine webEngine = browser.getEngine();
public Browser() {
//apply the styles
getStyleClass().add("browser");
// external URLs work
// webEngine.load("http://sabiork.h-its.org/newSearch/index");
// String content works
// webEngine.loadContent("<html><h1>Hello world</h1></html>");
// Resource content does not work
URL queryURL = getClass().getResource("/info.html");
System.out.println(queryURL);
loadPage(queryURL.toString());
//add the web view to the scene
getChildren().add(browser);
}
private void loadPage(String url) {
Platform.runLater(new Runnable() {
@Override
public void run() {
webEngine.load(url);
}
});
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Required to extract all resources from jar in temporary folder on filesystem and reference the resources from there.
- relates to
-
JDK-8152420 [WebView] Icon font doesn't work if single page application will be loaded from jar
-
- Resolved
-