【问题标题】:The prefix "xsi" for attribute "xsi:schemaLocation" associated with an element type "web-app" is not bound与元素类型“web-app”关联的属性“xsi:schemaLocation”的前缀“xsi”未绑定
【发布时间】:2018-09-12 13:33:16
【问题描述】:

启动tomcat时出现错误:

javax.servlet.UnavailableException: org.xml.sax.SAXParseException: 与元素类型“web-app”关联的属性“xsi:schemaLocation”的前缀“xsi”未绑定。

我正在尝试将我的 Java(基于 Maven)项目部署到我的 Tomcat 8 服务器上并启动它。清理所有项目并构建工作区后;删除每个项目上的所有构建路径错误后。当我尝试在 tomcat 中部署项目并启动它时,出现以下错误:

    Apr 02, 2018 1:29:22 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet [action] in web application [/bss] threw load() exception
javax.servlet.UnavailableException: org.xml.sax.SAXParseException: The prefix "xsi" for attribute "xsi:schemaLocation" associated with an element type "web-app" is not bound.
    at org.apache.struts.action.ActionServlet.init(ActionServlet.java:402)
    at javax.servlet.GenericServlet.init(GenericServlet.java:158)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1227)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1140)

我不确定是什么导致了这个问题,以及哪个 jar 完全丢失了,这将解决这个问题。

【问题讨论】:

标签: java eclipse maven tomcat deployment


【解决方案1】:

您很可能在web.xml 文件中缺少xsi 命名空间的声明。将xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 添加到web-app 元素。示例:

<web-app
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
   version="2.5">
   <!-- ... -->
</web-app>

【讨论】:

  • 我的 web.xml 文件中确实有上述内容
  • @JasmiraRichelleFernandes 发布您的web.xml
猜你喜欢
  • 2016-10-12
  • 1970-01-01
  • 2020-04-05
  • 2015-06-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-05
相关资源
最近更新 更多