gpt4 book ai didi

java - 非法状态异常 : Cannot convert value of type LdapTemplate to LdapTemplate

转载 作者:行者123 更新时间:2023-12-05 07:55:10 26 4
gpt4 key购买 nike

我正在尝试将 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 下工作,所以我怀疑它类似于构建路径问题。非常感谢任何帮助!

最佳答案

我终于搞清楚了。问题是我的项目中有两个不同版本的 spring-ldap-core,这导致了 LdapTemplate 的两个不同实现。移除其中一个 jar 解决了这个问题。

关于java - 非法状态异常 : Cannot convert value of type LdapTemplate to LdapTemplate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30312870/

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