Announcement Announcement Module
Collapse
No announcement yet.
Error creating bean : ProviderSignInController Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error creating bean : ProviderSignInController

    Hi,

    I am trying to add provider sign in capability my Spring application using ProviderSignInController.

    Here is xml configuration:

    Code:
        <bean class="org.springframework.social.connect.signin.web.ProviderSignInController">
            <constructor-arg index="0" value="http://localhost:8080/myapp"/>
            <constructor-arg index="1" ref="connectionFactoryLocator"/>
            <constructor-arg index="2" ref="usersConnectionRepository"/>
            <constructor-arg index="3" ref="connectionRepository"/>
            <constructor-arg index="4" ref="signInService"/>   	
        </bean>
    
        <bean id="connectionFactoryLocator" class="org.springframework.social.connect.support.ConnectionFactoryRegistry">
    		<property name="connectionFactories">
    		<list>
    			<bean class="org.springframework.social.linkedin.connect.LinkedInConnectionFactory">
    				<constructor-arg value="abc"/>
    				<constructor-arg value="KHufIUf"/>
    			</bean>
    		</list>
    		</property>
    		</bean>
    
        <bean id="usersConnectionRepository"
                   class="org.springframework.social.connect.jdbc.JdbcUsersConnectionRepository">
                    <constructor-arg ref="upcaseco_innoveDS"/>
                    <constructor-arg ref="connectionFactoryLocator"/>
                    <constructor-arg ref="textEncryptor"/>
        </bean>
    	
        <bean id="textEncryptor" class="org.springframework.security.crypto.encrypt.Encryptors"
                factory-method="noOpText"/>
    
        <bean id="connectionRepository" factory-method="createConnectionRepository"
                 factory-bean="usersConnectionRepository" scope="request">
                <constructor-arg value="#{request.userPrincipal}"/>
                <aop:scoped-proxy proxy-target-class="false"/>
        </bean>
    	
        <bean id="signInService" class="org.springframework.webflow.security.SpringSecuritySignInService"/>
    	
        <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
                <constructor-arg ref="upcaseco_innoveDS"/>
        </bean>
    The war file generation is successfull, but when I try to deploy it in tomcat, I get the following error:

    Code:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.social.connect.signin.web.ProviderSignInController#0' defined in class path resource [xx014-web-context.xml]: Unsatisfied dependency expressed through constructor argument with index 1 of type [javax.inject.Provider]: Ambiguous constructor argument types - did you specify the correct bean references as constructor arguments?
    Any suggestions on why I am getting this runtime error ?

    pom.xml has these dependencies defined:

    Code:
            <dependency>
                <groupId>org.springframework.social</groupId>
                <artifactId>spring-social-linkedin</artifactId>
                <version>1.0.0.M3</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.social</groupId>
                <artifactId>spring-social-web</artifactId>
                <version>1.0.0.M3</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.social</groupId>
                <artifactId>spring-social-core</artifactId>
                <version>1.0.0.M3</version>
            </dependency>

  • #2
    Well, the first ting that catches my eye is that you have explicitly specified 5 constructor arguments for ProviderSignInController when, in fact, ProviderSignInController has only one constructor and it only takes 3 arguments:

    Code:
    @Inject
    public ProviderSignInController(ConnectionFactoryLocator connectionFactoryLocator, UsersConnectionRepository usersConnectionRepository, SignInAdapter signInAdapter) {
    	this.connectionFactoryLocator = connectionFactoryLocator;
    	this.usersConnectionRepository = usersConnectionRepository;
    	this.signInAdapter = signInAdapter;
    	this.webSupport.setUseAuthenticateUrl(true);
    }
    Notice that this constructor is annotated with @Inject, which means it can be autowired and you don't need to explicitly specify its constructor arguments...and if you decide to do so, then you should only specify the 3 it needs.

    My recommendation is to remove the explicit <constructor-arg> elements and let Spring handle it for you. But if you want to keep them, then that bean should probably look like this:

    Code:
    <bean class="org.springframework.social.connect.signin.web.ProviderSignInController">
      <constructor-arg ref="connectionFactoryLocator"/>
      <constructor-arg ref="usersConnectionRepository"/>
      <constructor-arg ref="signInAdapter"/>   	
    </bean>
    Note that the 3rd argument is a reference to a bean whose class implements SignInAdapter. (Not Spring Web Flow's SpringSecuritySignInService as you've done).

    Also notice that you don't need to specify the index unless it's needed to resolve ambiguity; that is, if there were 2 arguments of the same type.

    Comment

    Working...
    X