javajavafxreporting-services

JavaFX WebView doesn't show SSRS web page


I'm trying to show a SSRS page on a WebView using JavaFX. The problem is that apparently JavaFX doesn't want their developers to be able to debug anything going on inside their WebView. I can't get the HTTPS error code, I cant get any console output, I tried using JEditorPane with Java Swing and putting it inside JavaFX with a SwingNode but I had no luck since JEditorPane doesn't execute JavaScript, though it actually showed the HTML content, meaning I can get access to it and it's not a 401 error.

Here's the code and the printed output:

// If the category indicates a stampa (print) type, load a web page in a WebView
if (category.toLowerCase().contains("stampa") || category.toLowerCase().contains("stampe")) {
            System.out.println("[DEBUG] Category indicates a print type. Proceeding with SSL configuration and WebView setup.");

            // Build and debug the URL based on the category
            System.out.println("[DEBUG] Building URL based on category.");
            String cleanedName = StringUtils.stripAccents(category);
            System.out.println("[DEBUG] After stripping accents: " + cleanedName);
            cleanedName = WordUtils.capitalize(cleanedName);
            System.out.println("[DEBUG] After capitalizing: " + cleanedName);
            cleanedName = cleanedName.replaceAll("\\s+", "");
            System.out.println("[DEBUG] After removing spaces: " + cleanedName);
            String url = "http://DESKTOP-P7MCH3L/ReportServer/Pages/ReportViewer.aspx?%2fia2000%2f"
                    + cleanedName + "&rs:Command=Render";
            System.out.println("[DEBUG] Final URL: " + url);

            // Set the default authenticator with debug logging
            System.out.println("[DEBUG] Setting default authenticator.");
            Authenticator.setDefault(new Authenticator() {
                @Override
                protected PasswordAuthentication getPasswordAuthentication() {
                    System.out.println("[DEBUG] getPasswordAuthentication called. Host: " + getRequestingHost() + ", Port: " + getRequestingPort());
                    return new PasswordAuthentication("DOMAIN\\username", "password".toCharArray());
                }
            });

            // Create and configure the JavaFX WebView with debugging statements
            System.out.println("[DEBUG] Creating JavaFX WebView.");
            WebView wv = new WebView();
            wv.getEngine().setJavaScriptEnabled(true);
            System.out.println("[DEBUG] JavaScript enabled in WebView engine.");

            // Add listener to log page load status
            wv.getEngine().getLoadWorker().stateProperty().addListener((obs, oldState, newState) -> {
                System.out.println("[DEBUG] WebView load state changed from " + oldState + " to " + newState);
            });

            System.out.println("[DEBUG] Loading URL in WebView.");
            wv.getEngine().load(url);

            // Embed the WebView in the JavaFX scene graph with debug logging
            System.out.println("[DEBUG] Embedding WebView into the scene graph.");
            root.setCenter(wv);
            setContent(root);
            System.out.println("[DEBUG] WebView setup complete. Exiting print preview handling.");
            return;
}

Output:

[DEBUG] Category indicates a print type.
[DEBUG] Building URL based on category.
[DEBUG] After stripping accents: Stampe inquilini
[DEBUG] After capitalizing: Stampe Inquilini
[DEBUG] After removing spaces: StampeInquilini
[DEBUG] Final URL: http://DESKTOP-P7MCH3L/ReportServer/Pages/ReportViewer.aspx?%2fia2000%2fStampeInquilini&rs:Command=Render
[DEBUG] Setting default authenticator.
[DEBUG] Creating JavaFX WebView.
[DEBUG] JavaScript enabled in WebView engine.
[DEBUG] Loading URL in WebView.
[DEBUG] WebView load state changed from READY to SCHEDULED
[DEBUG] WebView load state changed from SCHEDULED to RUNNING
[DEBUG] Embedding WebView into the scene graph.
[DEBUG] WebView setup complete. Exiting print preview handling.
[DEBUG] WebView load state changed from RUNNING to CANCELLED

Process finished with exit code 0

I am open to workarounds and other solutions.

Currently my SSRS configuration setup has a service account setup under that domain with that username and password. Am I missing something about the authentication? I can access it without any problems from my browser.


Solution

  • I finally found a solution, and it's really, really easy. Just add the flag -Dcom.sun.webkit.useHTTP2Loader=false when compiling/building. Thanks to this comment.