임베디드 부두 컨테이너에 간단한 서블릿을 만들려고합니다. 내장 된 부두. java.lang.IllegalStateException :! STOPPED
public class Application {
public static void main(String[] args) throws Exception {
//-Dport=8188
int port = 8188;
if(System.getProperty("port") != null) {
port = Integer.valueOf(System.getProperty("port"));
}
//-Dhost="127.0.0.1"
String host = System.getProperty("host");
if(host == null || host.isEmpty()) {
host = "127.0.0.1";
}
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
InetAddress address = InetAddress.getByName(host);
InetSocketAddress socketAddress = new InetSocketAddress(address, port);
Server jettyServer = new Server(socketAddress);
jettyServer.setHandler(context);
ServletHolder jerseyServlet = context.addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*");
jerseyServlet.setInitOrder(0);
// Initializing servlet
jerseyServlet.setInitParameter(
"jersey.config.server.provider.classnames",
Proxy.class.getCanonicalName()
);
try {
jettyServer.start();
jettyServer.join();
} finally {
jettyServer.destroy();
}
}
}
내가 아무 것도하지 않는 간단한 서블릿을 추가 이 내 부두 구성입니다. 나는 그것을 시작할 때, 나는 오류가 발생
public class Proxy extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doRequest(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doRequest(request, response);
}
private void doRequest(HttpServletRequest request, HttpServletResponse response) throws IOException {
PrintWriter writer = response.getWriter();
writer.println("GOT IT!");
}
}
: 실수는 어디
2016-08-14 10:53:42.338:INFO::main: Logging initialized @110ms
2016-08-14 10:53:47.404:INFO:oejs.Server:main: jetty-9.3.z-SNAPSHOT
2016-08-14 10:53:47.923:INFO:oejsh.ContextHandler:main: Started [email protected]{/,null,AVAILABLE}
Exception in thread "main" java.lang.IllegalStateException: !STOPPED
at org.eclipse.jetty.server.handler.HandlerWrapper.destroy(HandlerWrapper.java:135)
at ru.gridr.Application.main(Application.java:50)
단지 응답 일부 문자열을 썼다? 누군가 간단한 예를 보여줄 수 있습니까? 당신이 jettyServer.destroy()
을 수행 할 때