猿问

JBoss 6.1.0 AS 过滤器在 web.xml 中的位置

尝试在 JBoss 6.1.0 中部署 WAR 时显示以下错误


DEPLOYMENTS IN ERROR:

  Deployment

"vfs:///D:/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_AS_6.x1555321418499/deploy/MyProject.war" is in error due to the following reason(s): 


 org.jboss.xb.binding.JBossXBRuntimeException: filter cannot appear in this position. Expected content of web-app is unordered_sequence: error-page* welcome-file-list? servlet-mapping* login-config? mime-mapping* distributable? session-config? security-role* taglib* security-constraint* context-param* servlet* {all descriptionGroup}? {unordered_sequence jndiEnvironmentRefsGroup}?

以下是web.xml文件


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

  <context-param>

    <param-name>resteasy.scan</param-name>

    <param-value>false</param-value>

  </context-param>


 <filter>

    <filter-name>AuthenticationFilter</filter-name>

    <filter-class>mypackage.restauthentication.RestAuthenticationFilter</filter-class>

 </filter>

 <filter-mapping>

    <filter-name>AuthenticationFilter</filter-name>

    <url-pattern>/services/*</url-pattern>

 </filter-mapping>


 <servlet>

    <servlet-name>REST Service</servlet-name>

        <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>


     <init-param>

      <param-name>jersey.config.server.provider.packages</param-name>

      <param-value>mypackage.restauthentication</param-value>

     </init-param>


根据错误信息, 被<filter>错误地放置在web.xml. web-app 的预期内容是 unordered_sequence: error-page* welcome-file-list? servlet 映射 * 登录配置?mime 映射 * 可分发?会话配置?安全角色* taglib* 安全约束* 上下文参数* servlet* {所有描述组}?{unordered_sequence jndiEnvironmentRefsGroup}?


放置相同物品的正确顺序是什么?这是一个 Web 存档,它使用基本身份验证部署 Jersey REST Web 服务。


波斯汪
浏览 103回答 1
1回答

茅侃侃

尝试这个 ..<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:web="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">&nbsp; <context-param>&nbsp; &nbsp; <param-name>resteasy.scan</param-name>&nbsp; &nbsp; <param-value>false</param-value>&nbsp; </context-param>&nbsp; <servlet>&nbsp; &nbsp; <servlet-name>REST Service</servlet-name>&nbsp; &nbsp; &nbsp; &nbsp; <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>&nbsp; &nbsp; &nbsp;<init-param>&nbsp; &nbsp; &nbsp; <param-name>jersey.config.server.provider.packages</param-name>&nbsp; &nbsp; &nbsp; <param-value>mypackage.restauthentication</param-value>&nbsp; &nbsp; &nbsp;</init-param>&nbsp; &nbsp;<load-on-startup>1</load-on-startup>&nbsp;</servlet>&nbsp;<servlet-mapping>&nbsp; &nbsp;<servlet-name>REST Service</servlet-name>&nbsp; &nbsp;<url-pattern>/service/*</url-pattern>&nbsp;</servlet-mapping>&nbsp;<filter>&nbsp; &nbsp; <filter-name>AuthenticationFilter</filter-name>&nbsp; &nbsp; <filter-class>mypackage.restauthentication.RestAuthenticationFilter</filter-class>&nbsp;</filter>&nbsp;<filter-mapping>&nbsp; &nbsp; <filter-name>AuthenticationFilter</filter-name>&nbsp; &nbsp; <url-pattern>/services/*</url-pattern>&nbsp;</filter-mapping></web-app>
随时随地看视频慕课网APP

相关分类

Java
我要回答