デプロイ中に失敗するWebアプリケーションがあります。次のエラーが発生します:
Aug 8, 2014 7:00:21 PM org.springframework.web.context.ContextLoader initWebApplicationContext
SEVERE: Context initialization failed
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 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0' while setting constructor argument with key [3]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0': Cannot resolve reference to bean 'CustomLoginSuccessHandler' while setting bean property 'authenticationSuccessHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'CustomLoginSuccessHandler': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.abc.xyz.ldapservices.LDAPUtil com.abc.xyz.web.CustomLoginSuccessHandler.ldapContact; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ldapContact' defined in ServletContext resource [/WEB-INF/spring/spring-security.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy213 implementing org.springframework.ldap.core.LdapOperations,org.springframework.beans.factory.InitializingBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'org.springframework.ldap.core.LdapTemplate' for property 'ldapTemplate'; nested exception is Java.lang.IllegalStateException: Cannot convert value of type [$Proxy213 implementing org.springframework.ldap.core.LdapOperations,org.springframework.beans.factory.InitializingBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.springframework.ldap.core.LdapTemplate] for property 'ldapTemplate': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.Java:329)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.Java:107)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.Java:353)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.Java:154)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.Java:1391)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.Java:1132)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.Java:522)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.Java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.Java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.Java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.Java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.Java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.Java:589)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.Java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.Java:479)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.Java:383)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.Java:283)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.Java:112)
at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.Java:661)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.Java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.Java:120)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.Java:57)
at weblogic.servlet.internal.EventsManager.executeContextListener(EventsManager.Java:241)
at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.Java:198)
at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.Java:183)
at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.Java:1783)
at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.Java:2807)
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.Java:1661)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.Java:822)
at weblogic.application.internal.ExtensibleModuleWrapper$StartStateChange.next(ExtensibleModuleWrapper.Java:360)
at weblogic.application.internal.ExtensibleModuleWrapper$StartStateChange.next(ExtensibleModuleWrapper.Java:356)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.Java:42)
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.Java:138)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.Java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.Java:213)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.Java:208)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.Java:42)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.Java:70)
at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.Java:24)
at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.Java:729)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.Java:42)
at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.Java:258)
at weblogic.application.internal.SingleModuleDeployment.activate(SingleModuleDeployment.Java:48)
at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.Java:165)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.Java:80)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.Java:586)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.Java:148)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.Java:114)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.Java:339)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.Java:846)
at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.Java:1275)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.Java:442)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.Java:176)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.Java:195)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.Java:13)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.Java:68)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.Java:550)
at weblogic.work.ExecuteThread.execute(ExecuteThread.Java:295)
at weblogic.work.ExecuteThread.run(ExecuteThread.Java:254)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#2': Cannot resolve reference to bean 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0' while setting constructor argument with key [3]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0': Cannot resolve reference to bean 'CustomLoginSuccessHandler' while setting bean property 'authenticationSuccessHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'CustomLoginSuccessHandler': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.abc.xyz.ldapservices.LDAPUtil com.abc.xyz.web.CustomLoginSuccessHandler.ldapContact; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ldapContact' defined in ServletContext resource [/WEB-INF/spring/spring-security.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy213 implementing org.springframework.ldap.core.LdapOperations,org.springframework.beans.factory.InitializingBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'org.springframework.ldap.core.LdapTemplate' for property 'ldapTemplate'; nested exception is Java.lang.IllegalStateException: Cannot convert value of type [$Proxy213 implementing org.springframework.ldap.core.LdapOperations,org.springframework.beans.factory.InitializingBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.springframework.ldap.core.LdapTemplate] for property 'ldapTemplate': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.Java:329)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.Java:107)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.Java:353)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.Java:154)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.Java:615)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.Java:148)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.Java:1049)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.Java:953)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.Java:490)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.Java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.Java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.Java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.Java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.Java:194)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.Java:323)
web.xmlに構成XMLをロードしています:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
WEB-INF/spring/spring-security.xml
WEB-INF/spring/applicationContext-db.xml
WEB-INF/spring/applicationContext.xml
</param-value>
</context-param>
エラーは私のspring-security.xmlファイルから来ています。
<security:http auto-config="true" use-expressions="true"
access-denied-page="/auth/denied">
<security:intercept-url pattern="/auth/login"
access="permitAll" />
<security:intercept-url pattern="/main/admin"
access="hasRole('ROLE_ADMIN')" />
<security:intercept-url pattern="/main/common"
access="hasRole('ROLE_RI')" />
<security:form-login login-page="/auth/login"
authentication-failure-url="/auth/login?error=true"
default-target-url="/main/common" authentication-success-handler-ref="CustomLoginSuccessHandler" />
<security:logout invalidate-session="true" logout-url="/auth/logout"
success-handler-ref="CustomLogoutSuccessHandler" />
</security:http>
<bean id="CustomLoginSuccessHandler"
class="com.abc.xyz.web.CustomLoginSuccessHandler">
<property name="ldapContact" ref="ldapContact"></property>
</bean>
<bean id="CustomLogoutSuccessHandler"
class="com.abc.xyz.web.CustomLogoutSuccessHandler">
</bean>
<security:authentication-manager>
<security:ldap-authentication-provider
user-search-filter="(uid={0})" user-search-base="ou=Users"
group-search-filter="(roleOccupant={0})" group-search-base="ou=Groups"
group-role-attribute="cn" role-prefix="ROLE_">
</security:ldap-authentication-provider>
</security:authentication-manager>
<security:ldap-server url="ldap://localhost:389/dc=maxcrc,dc=com"
manager-dn="cn=Manager,dc=maxcrc,dc=com" manager-password="secret" />
<security:global-method-security
secured-annotations="enabled" />
<!-- <bean id="placeHolderConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
<property name="location" value="/WEB-INF/classes/ldap.properties"></property>
</bean>
<context:property-placeholder location="classpath:WEB-INF/classes/ldap.properties"/>
-->
<bean id="contextSource"
class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
<constructor-arg value="ldap://localhost:389/dc=maxcrc,dc=com" />
<property name="userDn" value="cn=Manager,dc=maxcrc,dc=com" />
<property name="password" value="secret" />
</bean>
<bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
<constructor-arg ref="contextSource" />
<property name="ignorePartialResultException" value="true" />
</bean>
<bean id="ldapContact" class="com.abc.xyz.ldapservices.LDAPUtil">
<property name="ldapTemplate" ref="ldapTemplate" />
</bean>
私のCustomLoginSuccessHandlerクラスは次のようなものです:
public class CustomLoginSuccessHandler implements AuthenticationSuccessHandler {
/** The redirect strategy. */
private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
/** The ldap contact. */
@Autowired
LDAPUtil ldapContact;
Springは初めてですが、Beanの依存関係の構成が原因だと思います。
1。Spring Beanの依存関係のシーケンスは何ですか、web.xmlのXML構成のシーケンスを使用しますか?
2。参照先の下で定義されているXMLファイルでBeanAを参照すると、問題が発生しますか?
[〜#〜]編集[〜#〜]
私のLDAPUtilクラスは次のようなものです。
private LdapOperations ldapTemplate;
public void setLdapTemplate(LdapTemplate ldapTemplate) {
this.ldapTemplate = ldapTemplate;
}
エラーは有用な要素を与えます。原因(チェーンの最後のエラー)は(文字列を削除)です:
「ldapContact」という名前のBeanの作成中にエラーが発生しました...タイプ「$ Proxy213を実装する... LdapOperations ...」のプロパティ値をプロパティ「ldapTemplate」の必須タイプ「.... LdapTemplate」に変換できませんでした
LdapUtil
sourceを表示しませんでしたが、CustomSuccessHandler
とエラーから、どこかに含まれていると思います:
@Autowired
LdapTemplate ldapTemplate;
このエラーは、ldapTemplate
beanの周囲にAOPプロキシメカニズムがあることを示しています。
デフォルトでSpringAOPがJDKプロキシを使用し、プロキシがすべてのインターフェイスを実装するが、元のクラスを拡張しないことを除いて、問題はありません。インターフェイスを介してldapTemplate
を参照することで、エラーを修正できるはずです。
@Autowired
LdapOperations ldapTemplate;
または、xmlファイルの<aop:config proxy-target-class = "true">
(またはアノテーションを使用している場合は<aop:aspectj-autoproxy proxy-target-class="true"/>
)を使用して、元のクラスを拡張するcglibプロキシを使用するようにSpringに依頼することもできます。ただし、これにはcglib jarがパス上にある必要があり、インターフェイスを使用できるため、最初のソリューションを使用することをお勧めします。
編集:
編集した投稿は、ldapTemplate
をLdapUtil
にロードする方法を示しています。そのようにインターフェースを使用する必要がある場合は、クラスとしてロードします。
private LdapOperations ldapTemplate;
public void setLdapTemplate(LdapOperations ldapTemplate) {
this.ldapTemplate = ldapTemplate;
}