最近做项目中碰到一个问题,在Tomcat下配置web.xml,应用启动正常,但放在Weblogic环境,就启动报错。
<Unable to load descriptor ... /WEB-INF/web.xml of module xxx.war.
The error is weblogic.descriptor.DescriptorException: VALIDATION PROBLEMS WERE FOUND
problem: cvc-complex-type.2.4a:
Expected element 'web-resource-name@http://java.sun.com/xml/ns/javaee'
instead of 'url-pattern@http://java.sun.com/xml/ns/javaee'
here in element web-resource-collection@http://java.sun.com/xml/ns/javaee:
后面经过排查,是添加了禁止Options 协议访问的配置,在weblogic下就报错误了。配置如下
<security-constraint>
<web-resource-collection>
<url-pattern>/*</url-pattern>
<http-method>PUT</http-method>
<http-method>DELETE</http-method>
<http-method>HEAD</http-method>
<http-method>OPTIONS</http-method>
<http-method>TRACE</http-method>
</web-resource-collection>
<auth-constraint></auth-constraint>
</security-constraint>
目前还没找到 weblogic 下处理方法