【发布时间】:2020-04-02 09:45:06
【问题描述】:
我已经为这个问题苦苦挣扎了几个星期。我有一些我最近从 Spring 4 迁移到 Spring 5 的遗留代码。代码在 localhost 上运行良好,但是当上传到 WebSphere Application Server 时它会严重崩溃。
错误如下所示:
错误页面异常
SRVE0260E:服务器无法使用为您的应用程序指定的错误页面来处理下面打印的原始异常。
原始例外:
错误信息: javax.servlet.ServletException: Filter [springSecurityFilterChain]: 无法初始化
错误代码: 500
目标 Servlet: 主要
错误堆栈:
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:来自文件 [/opt/IBM/WebSphere/AppServer/profiles/******/installedApps/******/ 的 XML 文档中的第 8 行******.ear/******.war/WEB-INF/classes/spring/spring-security.xml] 无效;嵌套异常是 org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: 匹配通配符是严格的,但找不到元素“http”的声明。
在堆栈堆栈堆栈等等......
我已经研究了一周,我想我已经尝试过所有常见的嫌疑人。
- 我在我的 Maven 依赖项中使用所有 Spring 模块的相同版本 (5.2.0)。
- 我确实有 spring-security-config 作为依赖项。
- 我已经检查了打包的应用程序。我的
.ear包含我的.war,而spring-security-config.jar又包含在其WEB-INF/lib文件夹中。
奇怪的是,我尝试从耳朵中删除 spring-security-config.jar 并且错误仍然相同。然后我开始怀疑 spring-beans.xsd 的定义。我编写了一个简单的脚本来输出我的第一级依赖项(无传递依赖)上的所有打包文件,但那里只有一个 spring-beans.xsd 和一个 spring-security.xsd。
由于该问题仅存在于 WebSphere Application Server 上,因此我尝试将类加载器配置为首先使用本地类,以防万一某些服务器端版本的 spring 与我的软件发生冲突。这对结果没有任何影响。
这是我的spring-security.xml 配置文件的样子:
<?xml version="1.0" encoding="UTF-8"?>
<b:beans xmlns="http://www.springframework.org/schema/security"
xmlns:b="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">
<http security="none" pattern="/services/**"/>
<http security="none" pattern="/css/**"/>
<http security="none" pattern="/fonts/**"/>
<http security="none" pattern="/images/**"/>
<http security="none" pattern="/js/**"/>
<http security="none" pattern="/error/**"/>
<http security="none" pattern="/api/**"/>
<http>
<intercept-url pattern="/validationCheck" access="permitAll"/>
<intercept-url pattern="/validationCheckStatus/**" access="permitAll"/>
<intercept-url pattern="/ping" access="permitAll"/>
<intercept-url pattern="/login.htm" access="permitAll" requires-channel="https"/>
<intercept-url pattern="/login-error.htm" access="permitAll" requires-channel="https"/>
<intercept-url pattern="/logout" access="hasRole('ROLE_USER')" requires-channel="https"/>
<intercept-url pattern="/**" access="hasRole('ROLE_USER')" requires-channel="https"/>
<logout logout-url="/logout" logout-success-url="/"/>
<form-login login-page="/login.htm" authentication-failure-url="/login-error.htm"
login-processing-url="/login.htm" default-target-url="/index.htm"
always-use-default-target="true"/>
<port-mappings>
<!-- Default ports -->
<port-mapping http="80" https="443"/>
<!-- Websphere default ports -->
<port-mapping http="9080" https="9443"/>
<!-- Websphere DES default ports -->
<port-mapping http="9082" https="9445"/>
<!-- Tomcat default ports -->
<port-mapping http="8080" https="8443"/>
<!-- Jetty custom ports -->
<port-mapping http="7777" https="7443"/>
</port-mappings>
</http>
<authentication-manager>
<authentication-provider ref="customAuthenticationProvider"/>
</authentication-manager>
</b:beans>
任何帮助将不胜感激。
【问题讨论】:
标签: xml spring-security configuration websphere