当类路径中存在jsp jar时,嵌入式码头无法解析web.xml [英] embedded jetty unable to parse web.xml when jsp jars present in classpath

查看:167
本文介绍了当类路径中存在jsp jar时,嵌入式码头无法解析web.xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以嵌入式码头启动我的应用程序时出现以下错误:

I'm getting the following error when starting my app as embedded jetty:

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

我的web.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添加到类路径中时会发生这种情况.没有这些罐子,我不会收到此错误.

When trying to narrow down the problem I noticed that this happens when I add the jsp related jars to the classpath. Without those jars I don't get this error.

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应用程序.

That startup code in your question is woefully insufficient to setup a webapp for JSP.

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

这篇关于当类路径中存在jsp jar时,嵌入式码头无法解析web.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆