Jetty and/or Servlet-api in JavaFX breaks deployme

2019-06-14 13:18发布

问题:

I try to embed (use) Jetty into my JavaFX 2.2 applet (which runs in a browser).

My problem is that, to host servlets I need to include the servlet-api-3.0.jar also (for javax.servlet namespaces) besides jetty-server.jar, jetty-servlet.jar and jetty-util.jar.

If I include the servlet-api.jar, my project compiles, but when I run it inside the browser, the deployment fails with the "JavaFX application could not launch due to system configuration (show error details). See java.com/javafx for troubleshooting information." error message.

If I remove the servlet-api.jar (and remove the relevant source) it deploys again.

For the JavaFX project the Java Platform is set to "Default JavaFX Platform", and it would be good to keep it this way to reduce the minimum footprint required.

I'm not a java(fx) expert (I come from .NET world), so I'd appreciate any help!

回答1:

You have an issue with signing the JARs. I'm not very familiar with signing JARs for JavaFX but here is the documentation:

http://docs.oracle.com/javafx/2/deployment/packaging.htm#BABJGFBH

http://docs.oracle.com/javafx/2/deployment/javafx_ant_task_reference001.htm#CIAFJGAB



回答2:

servlet-api-3.0.jar is what's known as a provided dependency.

It is not needed to be included in your war file, as the web app container (in this case Jetty) provides it for you. In your build tool, just exclude the servlet-api.jar from being bundled in your war file.

Note: jetty-server-9.0.0.M5.jar is also a provided dependency and has the same rules.