2
我試圖遷移從WebSphere Application Server到JBoss AS Spring的web應用程序,但在部署的時候我遇到了這樣的問題:IllegalStateException異常:無法將類型LdapTemplate的價值LdapTemplate
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
的相關部分核心-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定義。我在上面更新了它。 – tc1
你誤會了我。錯誤表示Spring未能創建'authenticationService' bean,因爲類型爲'LdapTemplate'的屬性有問題。你的XML沒有定義'LdapTemplate'類型的'property',所以我不明白這是可能的。 –