我有一个spring配置文件 service.xml ,导入 applicationContext.xml ,我的applicationContext.xml导入 security.xml 。
现在我的 service.xml 定义了一个bean说
<bean id="mySecurityInterceptor" class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor">
<property name="validationActions" value="UsernameToken" />
<property name="securementActions" value="UsernameToken" />
<property name="validationCallbackHandler" ref="myPasswordCallbackHandler" />
这个 myPasswordCallbackHandler bean在security.xml中定义,但在加载应用程序上下文时,我找不到myPasswordCallbackHandler的bean定义。
如何引用此 myPasswordCallbackHandler bean?
谢谢!
这是stackTrace:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySecurityInterceptor' defined in ServletContext resource [/WEB-INF/service.xml]: Cannot resolve reference to bean 'mySecurityPasswordCallbackHandler' while setting bean property 'validationCallbackHandler'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'mySecurityPasswordCallbackHandler' is defined
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 64 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'mySecurityPasswordCallbackHandler' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1083)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:274)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:266)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
这是我的myPasswordCallbackHandler def:
<beans:bean id="myPasswordCallbackHandler"
class="org.springframework.ws.soap.security.wss4j.callback.SpringPlainTextPasswordValidationCallbackHandler">
<beans:property name="authenticationManager" ref="authenticationManager"/>
答案 0 :(得分:1)
看起来你的某个地方可能有拼写错误,你的帖子中有两个bean的引用:mySecurityPasswordCallbackHandler
和myPasswordCallbackHandler
。确保使用正确的名称。
答案 1 :(得分:0)
不确定这是否会有所帮助,但您可以尝试明确的依赖
<bean id="mySecurityInterceptor" class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor" depends-on="myPasswordCallbackHandler">
<property name="validationActions" value="UsernameToken" />
<property name="securementActions" value="UsernameToken" />
<property name="validationCallbackHandler" ref="myPasswordCallbackHandler" />
假设你有一个名为myPasswordCallbackHandler的bean并且所有import语句都是正确的,我没有看到任何使用问题。