Answer the question
In order to leave comments, you need to log in
What is the correct way to create a war to run the built-in Jetty server?
Using IntelliJ IDEA I'm trying to create a war file to run with Jetty without using servlets.
The code is like this:
package org.example;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.HandlerList;
public class HelloWorld {
public static void main(String[] args) throws Exception {
Server server = new Server(8080);
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] {new SimpleHandler()});
server.setHandler(handlers);
server.start();
server.join();
}
}
Answer the question
In order to leave comments, you need to log in
You launch an application (namely a java application) and set a handler for it, which is visible and processed when requests are received. In the case of deploying to a container, your handler installation code will not be executed and, accordingly, you get the current behavior. You have 2 ways:
1. run your application as a java application (java -jar ...)
2. write your handler in the server config
As a result, I settled on a way to run java -jar
To do this, I create one jar file with all the libraries
What you wrote cannot be run in a container. In fact, you create a container with your hands, why do you need it at all?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question