【发布时间】:2015-05-18 21:10:02
【问题描述】:
我正在尝试将 Spring webapp 从 Websphere Application Server 迁移到 JBoss AS,但是在部署时遇到了这个问题:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'org.springframework.security.filterChains':
Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#2'
while setting bean property 'sourceList' with key [2]; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#2':
Cannot resolve reference to bean 'preAuthenticationFilter' while setting constructor argument with key [3];
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'preAuthenticationFilter': Injection of autowired dependencies failed;
nested exception is org.springframework.beans.factory.BeanCreationException:
Could not autowire field: private com.m.g.utils.WebUtils com.m.g.auth.PreAuthenticationFilter.webUtils;
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'webUtils': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field:
private com.m.g.helper.Delegate com.m.g.utils.WebUtils.Delegate;
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'delegate' defined in URL [file:/workspace/Web/WebContent/WEB-INF/core-context.xml]:
Cannot resolve reference to bean 'authenticationService' while setting bean property 'authenticationService';
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'authenticationService' defined in URL [file:/workspace/M-G-Web/WebContent/WEB-INF/core-context.xml]: Initialization of bean failed;
nested exception is org.springframework.beans.ConversionNotSupportedException:
Failed to convert property value of type 'org.springframework.ldap.core.LdapTemplate' to required type 'org.springframework.ldap.core.LdapTemplate' for property 'ldapTemplate'; nested exception is java.lang.IllegalStateException:
Cannot convert value of type [org.springframework.ldap.core.LdapTemplate] to required type [org.springframework.ldap.core.LdapTemplate] for property 'ldapTemplate': no matching editors or conversion strategy found
Core-context.xml 的相关部分如下所示:
<bean id="authenticationService" class="com.m.g.serviceimpl.AuthenticationServiceImpl">
<property name="wmbService" ref="wmbService" />
<property name="authenticationDAO" ref="authenticationDAO" />
<property name="customerDAO" ref="customerDAO" />
<property name="ldapTemplate" ref="ldapTemplate" />
</bean>
...
<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
<property name="url" value="#{systemProperties['ad.write.url']}" />
<property name="base" value="" />
<property name="userDn" value="#{systemProperties['ad.admin.userDn']}" />
<property name="password" value="#{systemProperties['ad.admin.password']}" />
</bean>
<bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
<constructor-arg ref="contextSource" />
</bean>
以及AuthenticationServiceImpl.java的相关部分:
@Component("authenticationService")
public class AuthenticationServiceImpl implements IAuthenticationService {
private IWMBService wmbService;
@Autowired
private IAuthenticationDAO authenticationDAO;
@Autowired
private IServiceFactory serviceFactory;
@Autowired
private CustomerManagementDAO customerDAO;
private LdapTemplate ldapTemplate;
@Autowired
private IProperties properties;
我已经搜索试图找出为什么会发生此错误,但我还没有找到任何有效的方法。这个完全相同的代码在 Websphere 下工作,所以我怀疑它类似于构建路径问题。非常感谢任何帮助!
【问题讨论】:
-
您确定要向我们展示所有相关内容吗?我没有在您的 XML 中看到名为
ldapTemplate的类型为LdapTemplate的属性。 -
很好,我错过了 XML 文件中实际的 ldapTemplate bean 定义。我在上面更新了它。
-
你误会我了。该错误表示 Spring 无法创建
authenticationServicebean,因为它的LdapTemplate类型的属性之一有问题。您的 XML 没有定义LdapTemplate类型的property,所以我看不出这怎么可能。 -
另外,为什么你同时拥有
authenticationServicebean 的 XML 声明和authenticationServicebean 的 Java@Component声明? -
我太傻了,我错误地粘贴了 XML 的关键部分。你是对的,它确实被定义为一个属性。同样对于 bean 声明,我最初并没有编写代码库的这个特定部分,所以我不确定为什么会做出这个决定。
标签: java spring jboss spring-security websphere