I have a program that uses JavaFX WebView to open a webpage that sends too many chains. The Third-Party web page did not do this until a week ago.
Here is my pom file.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>opn.greenwebs</groupId>
<artifactId>WebViewExample</artifactId>
<version>1.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>16</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>16</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>16</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.6</version>
<configuration>
<mainClass>opn.greenwebs.webviewexample.App</mainClass>
</configuration>
<executions>
<execution>
<!-- Default configuration for running -->
<!-- Usage: mvn clean javafx:run -->
<id>default-cli</id>
</execution>
<execution>
<!-- Configuration for manual attach debugging -->
<!-- Usage: mvn clean javafx:run@debug -->
<id>debug</id>
<configuration>
<options>
<option>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:8000</option>
</options>
</configuration>
</execution>
<execution>
<!-- Configuration for automatic IDE debugging -->
<id>ide-debug</id>
<configuration>
<options>
<option>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}</option>
</options>
</configuration>
</execution>
<execution>
<!-- Configuration for automatic IDE profiling -->
<id>ide-profile</id>
<configuration>
<options>
<option>${profiler.jvmargs.arg1}</option>
<option>${profiler.jvmargs.arg2}</option>
<option>${profiler.jvmargs.arg3}</option>
<option>${profiler.jvmargs.arg4}</option>
<option>${profiler.jvmargs.arg5}</option>
</options>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<executable>java</executable>
<arguments>
<argument>--module-path</argument>
<modulepath/>
<argument>-classpath</argument>
<classpath/>
<argument>opn.greenwebs.webviewexample.App</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
and my fxml controller.
package opn.greenwebs.webviewexample;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.beans.value.ObservableValue;
import javafx.concurrent.Worker;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
public class AppyController implements Initializable {
@FXML
WebView webView;
@FXML
WebEngine webEngine;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
webEngine = webView.getEngine();
webEngine.setOnError(event2 -> {
System.out.println("hey what is the error " + event2.getMessage());
});
}
@FXML
private void handleClose(ActionEvent event) {
System.out.println("we are closing the door");
System.exit(0);
}
@FXML
private void handleLoadWeb(ActionEvent event) {
try {
Worker<Void> worker = webEngine.getLoadWorker();
worker.stateProperty().addListener((ObservableValue<? extends Worker.State> observable, Worker.State oldValue, Worker.State newValue) -> {
System.out.println("what is newValue " + newValue);
if (newValue == Worker.State.FAILED) {
System.out.println("what is the message " + worker.getException());
}
});
webEngine.load("https://ec.synnex.ca/ecx/");
} catch (Exception e) {
System.out.println("we have an exception " + e.getLocalizedMessage());
}
}
}
and my fxml file.
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.web.WebView?>
<AnchorPane id="AnchorPane" prefHeight="414.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/16" xmlns:fx="http://javafx.com/fxml/1" fx:controller="opn.greenwebs.webviewexample.AppyController">
<children>
<WebView fx:id="webView" layoutX="14.0" layoutY="14.0" prefHeight="358.0" prefWidth="572.0" AnchorPane.bottomAnchor="42.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="14.0" />
<Button layoutX="534.0" layoutY="374.0" mnemonicParsing="false" onAction="#handleLoadWeb" text="Load Web Page" AnchorPane.bottomAnchor="14.0" AnchorPane.rightAnchor="14.0" />
<Button layoutX="433.0" layoutY="375.0" mnemonicParsing="false" onAction="#handleClose" text="Close" AnchorPane.bottomAnchor="14.0" AnchorPane.rightAnchor="122.0" />
</children>
</AnchorPane>
I get this error:
javax.net.ssl.SSLProtocolException: The certificate chain length (11) exceeds the maximum allowed length (10)
at java.base/sun.security.ssl.CertificateMessage$T13CertificateMessage.<init>(CertificateMessage.java:874)
at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.consume(CertificateMessage.java:1169)
at java.base/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:396)
at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:480)
at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:458)
at java.base/sun.security.ssl.TransportContext.dispatch(TransportContext.java:199)
at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:171)
at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1498)
at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1404)
at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:441)
at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:412)
at java.base/sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:574)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:183)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1653)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1577)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:224)
at opn.greenwebs/opn.greenwebs.Main1.lambda$start$2(Main1.java:88)
at javafx.base/com.sun.javafx.binding.ExpressionHelper$SingleChange.fireValueChangedEvent(ExpressionHelper.java:181)
at javafx.base/com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80)
at javafx.base/javafx.beans.property.ReadOnlyStringPropertyBase.fireValueChangedEvent(ReadOnlyStringPropertyBase.java:78)
at javafx.base/javafx.beans.property.ReadOnlyStringWrapper.fireValueChangedEvent(ReadOnlyStringWrapper.java:103)
at javafx.base/javafx.beans.property.StringPropertyBase.markInvalid(StringPropertyBase.java:111)
at javafx.base/javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:145)
at javafx.web/javafx.scene.web.WebEngine.updateLocation(WebEngine.java:434)
at javafx.web/javafx.scene.web.WebEngine$LoadWorker.dispatchLoadEvent(WebEngine.java:1358)
at javafx.web/javafx.scene.web.WebEngine$PageLoadListener.dispatchLoadEvent(WebEngine.java:1240)
at javafx.web/com.sun.webkit.WebPage.fireLoadEvent(WebPage.java:2524)
at javafx.web/com.sun.webkit.WebPage.fwkFireLoadEvent(WebPage.java:2369)
at javafx.web/com.sun.webkit.WebPage.twkOpen(Native Method)
at javafx.web/com.sun.webkit.WebPage.open(WebPage.java:1246)
at javafx.web/javafx.scene.web.WebEngine.load(WebEngine.java:901)
at opn.greenwebs/opn.greenwebs.Main1.start(Main1.java:113)
at opn.greenwebs/opn.greenwebs.App.lambda$addAppToTray$4(App.java:261)
at FXTrayIcon@3.0.0/com.dustinredmond.fxtrayicon.AWTUtils.lambda$null$0(AWTUtils.java:74)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:447)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:446)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:831)
@Dave_Thompson_085 suggests to add -Djdk.tls.maxCertificateChainLength=15
to JVM options.
Where do I put the JVM option so my maven project will work again?