具有Spring Security的异常Tomcat

时间:2014-07-31 09:26:16

标签: java maven spring-security tomee

当我尝试向我的pom.xml添加这些依赖项时:

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>3.2.4.RELEASE</version>
</dependency>

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.2.4.RELEASE</version>
</dependency> 

然后我启动Tomcat,发生此错误:

Grave: Error listenerStart
lug 31, 2014 10:57:10 AM org.apache.catalina.core.StandardContext startInternal
Grave: Context [/MyApp] startup failed due to previous errors
lug 31, 2014 10:57:10 AM org.apache.catalina.core.ApplicationContext log
Informazioni: Closing Spring root WebApplicationContext
lug 31, 2014 10:57:10 AM org.apache.catalina.core.StandardContext listenerStop
Grave: Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
    at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:171)
    at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1090)
    at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1064)
    at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1010)
    at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:558)
    at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:143)
    at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:5014)
    at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5659)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)

出了什么问题?我在WEB-INF \ lib下没有jar,但是它们都在maven文件夹下,我已经使用了3.2.2.RELEASE用于spring-core / web / contetext。 谢谢你的帮助。

1 个答案:

答案 0 :(得分:0)

[已解决]在我的spring-security.xml中,版本错误:

xsi:schemaLocation="http://www.springframework.org/schema/security/spring-security-3.1.xsd">

相反,它必须是:

xsi:schemaLocation="http://www.springframework.org/schema/security/spring-security-3.2.xsd">

非常感谢@Ben Green。