嵌入式 Jetty 无法解析 Web.xml当类路径中存在 JSP jar 时



在将我的应用程序作为嵌入式码头启动时,我收到以下错误:

Exception initializing TldLocationsCache: XML parsing error on file /WEB-INF/web.xml: (line 2, col 9): Document is invalid: no grammar found.

我的网站.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app 
   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"
version="3.0">
<welcome-file-list>
 <welcome-file>index.html</welcome-file>
</welcome-file-list>

启动代码:

    Server server = new Server(8080);
    WebAppContext context = new WebAppContext();
    context.setResourceBase("WebContent");
    context.setDescriptor("/WEB-INF/web.xml");
    context.setContextPath("/" + "test");
    context.setParentLoaderPriority(false);
    server.setHandler(context);
    server.start();
    server.join();

在尝试缩小问题范围时,我注意到当我将与 jsp 相关的 jar 添加到类路径时会发生这种情况。没有这些罐子,我不会收到此错误。

lib/jsp:
javax.el-3.0.0.jar                jetty-jsp-9.2.10.v20150310.jar
javax.servlet.jsp-2.3.2.jar       jetty-jsp-jdt-2.3.3.jar
javax.servlet.jsp-api-2.3.1.jar   org.eclipse.jdt.core-3.8.2.v20130121.jar
javax.servlet.jsp.jstl-1.2.2.jar
org.eclipse.jetty.orbit.javax.servlet.jsp.jstl-1.2.0.v201105211821.jar
lib/apache-jsp:
org.eclipse.jetty.apache-jsp-9.2.10.v20150310.jar
org.eclipse.jetty.orbit.org.eclipse.jdt.core-3.8.2.v20130121.jar

您问题中的启动代码严重不足以为 JSP 设置 Web 应用程序。

请参阅先前的答案:未配置嵌入式码头 Web 服务器 JSP 支持

相关内容

最新更新