【发布时间】:2020-12-14 18:16:34
【问题描述】:
请帮忙!
我在配置 Embedded Jetty 以在 2 个类中运行 2 个 Jersey Servlet 时遇到问题,包条目。它从 Eclipse 运行,但是一旦导出为可运行的 jar 文件,我得到 ERROR: 500,第二次运行。
它是 Maven 项目,我用来创建可运行 jar 的工具是 <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId>,
Server 点配置如下:
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
context.setContextPath("/");
HttpConfiguration https = new HttpConfiguration();
https.addCustomizer(new SecureRequestCustomizer());
ServerConnector connector = new ServerConnector(jettyServer);
connector.setPort(10001);
jettyServer.setConnectors(new Connector[] { connector });
jettyServer.setHandler(context);
ServletHolder jerseyServletEntry = context.addServlet(org.glassfish.jersey.servlet.ServletContainer.class,
"/entry/*");
jerseyServletEntry.setInitOrder(0);
jerseyServletEntry.setInitParameter("jersey.config.server.provider.classnames",
EntryPoint.class.getCanonicalName());
EntryPoint.logger.info("Server is starting up... ");
ServletHolder jerseyServletNoEntry = context.addServlet(org.glassfish.jersey.servlet.ServletContainer.class,
"/noentry/*");
jerseyServletNoEntry.setInitOrder(1);
jerseyServletNoEntry.setInitParameter("jersey.config.server.provider.classnames",
NoEntryPoint.class.getCanonicalName());
NoEntryPoint.logger.info("Server is starting up... ");
我遇到的邮递员错误:
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1" />
<title>Error 500 </title>
</head>
<body>
<h2>HTTP ERROR: 500</h2>
<p>Problem accessing /entry/input//7858/768434. Reason:
<pre> Request failed.</pre>
</p>
<hr /><i><small>Powered by Jetty://</small></i>
</body>
提醒:在 Eclipse 中运行良好,在控制台中使用 java -jar 命令运行时不会出现错误。
【问题讨论】:
-
尝试注册this exception mapper。查看是否有任何未处理的异常抛出。