gpt4 book ai didi

spring - org.springframework.beans.factory.BeanCreationException : Error creating bean with name 'org.springframework.security.filterChains'

转载 作者:行者123 更新时间:2023-12-04 18:17:09 72 4
gpt4 key购买 nike

我用 STS、Roo 和 GWT 创建了一个新项目,并尝试包含 Spring Security。
从那时起,我收到以下错误。有没有人知道出了什么问题?!

org.springframework.beans.factory.BeanCreationException:创建名为“org.springframework.security.filterChains”的bean时出错:bean初始化失败;嵌套异常是 java.lang.NoSuchFieldError: NULL

堆栈跟踪:

    [INFO] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': Initialization of bean failed; nested exception is java.lang.NoSuchFieldError: NULL
[INFO] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
[INFO] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
[INFO] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
[INFO] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
[INFO] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
[INFO] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
[INFO] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)
[INFO] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
[INFO] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
[INFO] at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282)
[INFO] at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204)
[INFO] at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
[INFO] at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:543)
[INFO] at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
[INFO] at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1220)
[INFO] at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:513)
[INFO] at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
[INFO] at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:468)
[INFO] at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
[INFO] at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
[INFO] at org.mortbay.jetty.handler.RequestLogHandler.doStart(RequestLogHandler.java:115)
[INFO] at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
[INFO] at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
[INFO] at org.mortbay.jetty.Server.doStart(Server.java:222)
[INFO] at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
[INFO] at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:672)
[INFO] at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:509)
[INFO] at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1068)
[INFO] at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:811)
[INFO] at com.google.gwt.dev.DevMode.main(DevMode.java:311)
[INFO] Caused by: java.lang.NoSuchFieldError: NULL
[INFO] at org.springframework.expression.TypedValue.<clinit>(TypedValue.java:32)
[INFO] at org.springframework.expression.spel.support.StandardEvaluationContext.setRootObject(StandardEvaluationContext.java:88)
[INFO] at org.springframework.expression.spel.support.StandardEvaluationContext.<init>(StandardEvaluationContext.java:74)
[INFO] at org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:124)
[INFO] at org.springframework.beans.factory.support.AbstractBeanFactory.evaluateBeanDefinitionString(AbstractBeanFactory.java:1299)
[INFO] at org.springframework.beans.factory.support.BeanDefinitionValueResolver.evaluate(BeanDefinitionValueResolver.java:224)
[INFO] at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:311)
[INFO] at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
[INFO] at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:353)
[INFO] at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:153)
[INFO] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
[INFO] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
[INFO] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
[INFO] ... 29 more

我的 web.xml
    <!-- Enable escaping of form submission contents -->
<context-param>
<param-name>defaultHtmlEscape</param-name>
<param-value>true</param-value>
</context-param>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:META-INF/spring/applicationContext*.xml</param-value>
</context-param>


<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>

<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>




<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>



<filter>
<filter-name>HttpMethodFilter</filter-name>
<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter>

<filter>
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
<filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<filter-mapping>
<filter-name>HttpMethodFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<filter-mapping>
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<!-- Handles Spring requests -->
<servlet>
<servlet-name>Weltenbrand</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/spring/webmvc-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>



<servlet>
<servlet-name>requestFactory</servlet-name>
<servlet-class>de.roio.weltenbrand.server.CustomRequestFactoryServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Weltenbrand</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>



<servlet-mapping>
<servlet-name>requestFactory</servlet-name>
<url-pattern>/gwtRequest</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>10</session-timeout>
</session-config>

<servlet>
<servlet-name>authServlet</servlet-name>
<servlet-class>de.roio.weltenbrand.server.authentication.AuthServiceImpl</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>authServlet</servlet-name>
<url-pattern>/Weltenbrand/auth</url-pattern>
</servlet-mapping>

</web-app>

这里是applicationContext.xml:
<bean id="customAuthListener" class="de.roio.weltenbrand.server.authentication.CustomAuthListener"/>

<security:http auto-config="true">
<security:intercept-url pattern="/gwtspringsecurityproject/**" access="ROLE_USER"/>
<security:intercept-url pattern="/gwt/**" access="ROLE_USER"/>
<security:intercept-url pattern="/**/*.html" access="ROLE_USER"/>
<security:intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
</security:http>

<bean id="customAuthenticationProvider"
class="de.roio.weltenbrand.server.authentication.CustomAuthenticationProvider" />

<security:authentication-manager alias="authenticationManager">
<security:authentication-provider ref="customAuthenticationProvider"/>
</security:authentication-manager>

<context:property-placeholder location="classpath*:META-INF/spring/*.properties"/>

<context:spring-configured/>

<context:component-scan base-package="de.roio.weltenbrand">
<context:exclude-filter expression=".*_Roo_.*" type="regex"/>
<context:exclude-filter expression="org.springframework.stereotype.Controller" type="annotation"/>
</context:component-scan>
<bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" id="dataSource">
<property name="driverClassName" value="${database.driverClassName}"/>
<property name="url" value="${database.url}"/>
<property name="username" value="${database.username}"/>
<property name="password" value="${database.password}"/>
<property name="testOnBorrow" value="true"/>
<property name="testOnReturn" value="true"/>
<property name="testWhileIdle" value="true"/>
<property name="timeBetweenEvictionRunsMillis" value="1800000"/>
<property name="numTestsPerEvictionRun" value="3"/>
<property name="minEvictableIdleTimeMillis" value="1800000"/>
<property name="validationQuery" value="SELECT 1"/>
</bean>
<bean class="org.springframework.orm.jpa.JpaTransactionManager" id="transactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<tx:annotation-driven mode="aspectj" transaction-manager="transactionManager"/>
<bean class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" id="entityManagerFactory">
<property name="persistenceUnitName" value="persistenceUnit"/>
<property name="dataSource" ref="dataSource"/>
</bean>

最佳答案

问题的实际原因似乎是 spring-security 3.1.X 引入了旧版本的 spring,从而产生了无声的冲突。在我的例子中,spring-security-3.1.3.RELEASE 引入了 spring-expressions 3.0.7.RELEASE。明确添加此依赖项后,问题就消失了。

关于spring - org.springframework.beans.factory.BeanCreationException : Error creating bean with name 'org.springframework.security.filterChains' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11447534/

72 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com