使用名称org.springframework.security.saml.metadata.ExtendedMetadataDelegate创建bean时出错:无法解析匹配的构造函数

时间:2015-04-22 09:40:01

标签: spring-security jboss7.x spring-saml

我必须为客户集成Shibboleth SP身份验证,我需要将它与JBoss AS 7上的J2EE应用程序(JSF2,EJB3,JPA2)集成。
我正在使用这个库:

  1. spring-security-core-3.2.5和依赖
  2. spring-security-saml2-core-1.0.0和依赖项
  3. spring framework 4.1.3
  4. 目前有一个实现JdbcDaoImpl的bean用于身份验证和授权。我已经成功部署了Spring SAML Sample应用程序,但我无法将其集成到我的应用程序中。我在部署期间收到异常,似乎无法构造ExtendedMetadataDelegate bean,其定义如下:

    <beans:bean id="metadata" class="org.springframework.security.saml.metadata.CachingMetadataManager">
        <beans:constructor-arg>
            <beans:list>
                <!-- Example of classpath metadata with Extended Metadata -->
                <beans:bean class="org.springframework.security.saml.metadata.ExtendedMetadataDelegate">
                    <beans:constructor-arg>
                        <beans:bean class="org.opensaml.saml2.metadata.provider.ResourceBackedMetadataProvider">
                            <beans:constructor-arg>
                                <beans:bean class="java.util.Timer"/>
                            </beans:constructor-arg>
                            <beans:constructor-arg>
                                <beans:bean class="org.opensaml.util.resource.ClasspathResource">
                                    <beans:constructor-arg value="/CustomerIDPMetadata.xml"/>
                                </beans:bean>
                            </beans:constructor-arg>
                            <beans:property name="parserPool" ref="parserPool"/>
                        </beans:bean>
                    </beans:constructor-arg>
                    <beans:constructor-arg>
                        <beans:bean class="org.springframework.security.saml.metadata.ExtendedMetadata"></beans:bean>
                    </beans:constructor-arg>
                </beans:bean>
                <!-- Example of HTTP metadata without Extended Metadata -->
                <beans:bean class="org.opensaml.saml2.metadata.provider.HTTPMetadataProvider">
                    <!-- URL containing the metadata -->
                    <beans:constructor-arg>
                        <beans:value type="java.lang.String">https://customer/Metadata/Metadata.xml</beans:value>
                    </beans:constructor-arg>
                    <!-- Timeout for metadata loading in ms -->
                    <beans:constructor-arg>
                        <beans:value type="int">15000</beans:value>
                    </beans:constructor-arg>
                    <beans:property name="parserPool" ref="parserPool"/>
                </beans:bean>
                <!-- Example of file system metadata without Extended Metadata -->
                <!--
                <bean class="org.opensaml.saml2.metadata.provider.FilesystemMetadataProvider">
                    <constructor-arg>
                        <value type="java.io.File">/usr/local/metadata/idp.xml</value>
                    </constructor-arg>
                    <property name="parserPool" ref="parserPool"/>
                </bean>
                -->
            </beans:list>
        </beans:constructor-arg>
        <!-- OPTIONAL used when one of the metadata files contains information about this service provider -->
        <!-- <property name="hostedSPName" value=""/> -->
        <!-- OPTIONAL property: can tell the system which IDP should be used for authenticating user by default. -->
        <!-- <property name="defaultIDP" value="http://localhost:8080/opensso"/> -->
    </beans:bean>    
    

    堆栈跟踪:

      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#0': Cannot resolve reference to bean 'metadataGeneratorFilter' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'metadataGeneratorFilter' defined in ServletContext resource [/WEB-INF/security-app-context.xml]: Cannot create inner bean 'org.springframework.security.saml.metadata.MetadataGenerator#115824e4' of type [org.springframework.security.saml.metadata.MetadataGenerator] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.saml.metadata.MetadataGenerator#115824e4': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.security.saml.metadata.MetadataGenerator.setSamlWebSSOFilter(org.springframework.security.saml.SAMLProcessingFilter); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'samlWebSSOProcessingFilter': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.security.saml.SAMLProcessingFilter.setContextProvider(org.springframework.security.saml.context.SAMLContextProvider); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contextProvider': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.security.saml.context.SAMLContextProviderImpl.setMetadata(org.springframework.security.saml.metadata.MetadataManager); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'metadata' defined in ServletContext resource [/WEB-INF/security-app-context.xml]: Cannot create inner bean 'org.springframework.security.saml.metadata.ExtendedMetadataDelegate#7a0347fc' of type [org.springframework.security.saml.metadata.ExtendedMetadataDelegate] while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.saml.metadata.ExtendedMetadataDelegate#7a0347fc' defined in ServletContext resource [/WEB-INF/security-app-context.xml]: Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359) [spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108) [spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:382) [spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:157) [spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:637) [spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:140) [spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1131) [spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1034) [spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504) [spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) [spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) [spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) [spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) [spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351) [spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        ... 25 more
    

    ExtendedMetadataDelegate构造函数采用MetadataProvider和ExtendedMetadata,这部分配置似乎是正确的。
    有什么想法吗?

1 个答案:

答案 0 :(得分:0)

解决。在eclipse中,我在部署部分为Web项目指定了导出所有spring-saml-sample jar。