Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

NPE in setApplicationUrl using POJO construction #129

Open
jmkgreen opened this issue May 6, 2014 · 5 comments
Open

NPE in setApplicationUrl using POJO construction #129

jmkgreen opened this issue May 6, 2014 · 5 comments

Comments

@jmkgreen
Copy link

jmkgreen commented May 6, 2014

This was working fine in 1.0.3.

ProviderSignInController controller = new ProviderSignInController(connectionFactoryLocator,
usersConnectionRepository, new SpringSecuritySignInAdapter(userBean, userService, preferencesRepository, regCode));
 controller.setApplicationUrl(this.applicationUrl);

Pretty much as per your documentation, wrapped in a method annotated @Bean and in a class annotated @Configuration.

I did not now expect the following stacktrace:

Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.social.connect.web.ProviderSignInController com.mjog.portal.spring.social.config.SpringControllerFactory.providerSignInController()] threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:181)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:586)
... 48 more
Caused by: java.lang.NullPointerException
at org.springframework.social.connect.web.ProviderSignInController.setApplicationUrl(ProviderSignInController.java:142)

(Our boring code omitted).

Basically setApplicationUrl() now expects afterPropertiesSet() to have been already called. Within POJO construction this is not the case.

Unable to proceed, unless I've again got something badly misunderstood here.

@t-botz
Copy link

t-botz commented Jun 2, 2014

There is the exact same bug on ConnectController

@ba0708
Copy link

ba0708 commented Dec 23, 2014

I am facing the exact same problem. What to do?

@sumit784
Copy link

sumit784 commented Feb 7, 2015

Did anyone fixed it.. This is probably the reason why I am getting incorrect URI errors on "Google & Linkedin" .

any timeline for fixing this ?

@serhii-samoilenko
Copy link

I had to fix it like this:

@Bean(initMethod = "workaroundInit")
public ConnectController connectController(
        ConnectionFactoryLocator connectionFactoryLocator,
        ConnectionRepository connectionRepository) {

    return new ConnectController(connectionFactoryLocator, connectionRepository) {
        // Workaround for issue: https://github.com/spring-projects/spring-social/issues/129
        public void workaroundInit() {
            setApplicationUrl(applicationUrl);
         }
    };
}

@juanromanf
Copy link

Other workaround for ConnectController ( v1.1.0-RELEASE)

    @Bean
    public ConnectController connectController(ConnectionFactoryLocator connectionFactoryLocator, ConnectionRepository connectionRepository) throws Exception {

        ConnectController connectController = new ConnectController(connectionFactoryLocator, connectionRepository);
        connectController.afterPropertiesSet();
        connectController.setApplicationUrl(applicationURL);

        return connectController;
    }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

6 participants