问题
Error Seen while starting tomcat:
javax.servlet.UnavailableException: org.xml.sax.SAXParseException: The prefix "xsi" for attribute "xsi:schemaLocation" associated with an element type "web-app" is not bound.
I am trying to deploy my Java (Maven Based) projects onto my Tomcat 8 server and start it. After cleaning all the project and building the workspace; After removing all build path errors on each project. When I try to deploy the projects in tomcat and start it, i get below error:
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)
I am not sure what is causing the issue and which jar is exactly missing which will resolve this issue.
回答1:
You are most probably missing the declaration of the xsi namespace in your web.xml file. Add xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" to the web-app element. Example:
<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>
来源:https://stackoverflow.com/questions/49626429/the-prefix-xsi-for-attribute-xsischemalocation-associated-with-an-element-t