I´m trying to implement a Jetty Server inside a Swing / JavaFX application. There is a similar project with Tomcat: https://www.beyondjava.net/how-to-wrap-bootsfaces-or-jsf-in-general-as-a-native-desktop-application
Now I´m trying to change this to Jetty. This is in my main code (instead tomcat)
public void run() throws Exception {
Server server = new Server(8080);
Path basePath = new File("src/main/webapp/").toPath().toRealPath();
WebAppContext context = new WebAppContext();
context.setContextPath("/");
// Configuring from Development Base
context.setBaseResource(new PathResource(basePath.resolve("src/main/webapp")));
// Add webapp compiled classes & resources (copied into place from
// src/main/resources)
Path classesPath = basePath.resolve("target/webapp/WEB-INF/classes");
context.setExtraClasspath(classesPath.toAbsolutePath().toString());
server.setDumpAfterStart(true);
server.setHandler(context);
server.start();
}
In the pom.xml I´ve added this:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>9.4.48.v20220622</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>9.4.48.v20220622</version>
</dependency>
If I start the Main function the Webapp (index.xhtml) is not showing. Ijust got:
Any idea what is wrong?
Here the web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<!--param-value>Production</param-value -->
<param-value>Development</param-value>
</context-param>
<!-- The BootsFaces_THEME context-param controls the loading of the Themes -->
<servlet>
<servlet-name>facesServlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Map following files to the JSF servlet -->
<servlet-mapping>
<servlet-name>facesServlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
The faces-config.xml is currently empty