spring social version 1.0.3: Why i've Field or property 'name' cannot be found on null error -


i use spring social 1.0.3 add "sign in facebook" , "sign in twitter" on login page. here login view page :

login view :

 <form action="<c:url value="/connect/twitter" />" method="post">   <p><button type="submit"><img src="<c:url value="/resources/images/social/twitter/sign-in-with-twitter-d.png" />"/>     </button></p> </form>    <form action="<c:url value="/connect/facebook" />" method="post">   <p><button type="submit"><img src="<c:url value="/resources/images/social/facebook/sign-in-with-facebook.png" />"/>     </button></p> </form> 

spring social xml configuration:

<context:property-placeholder location="classpath:application.properties" />      <bean id="connectionfactorylocator"        class="org.springframework.social.connect.support.connectionfactoryregistry">     <property name="connectionfactories">         <list>             <bean class="org.springframework.social.twitter.connect.twitterconnectionfactory">                 <constructor-arg value="${twitter.consumerkey}" />                 <constructor-arg value="${twitter.consumersecret}" />                            </bean>             <bean class="org.springframework.social.facebook.connect.facebookconnectionfactory">                 <constructor-arg value="${facebook.clientid}" />                 <constructor-arg value="${facebook.clientsecret}" />                             </bean>         </list>     </property> </bean>  <bean id="usersconnectionrepository"        class="org.springframework.social.connect.jdbc.jdbcusersconnectionrepository">     <constructor-arg ref="datasource" />     <constructor-arg ref="connectionfactorylocator" />     <constructor-arg ref="textencryptor" /> </bean>  <bean id="connectionrepository" factory-method="createconnectionrepository"        factory-bean="usersconnectionrepository" scope="request">     <constructor-arg value="#{request.userprincipal.name}" />     <aop:scoped-proxy proxy-target-class="false" /> </bean>   <bean id="textencryptor" class="org.springframework.security.crypto.encrypt.encryptors"                  factory-method="nooptext">          </bean>  <bean class="org.springframework.social.connect.web.connectcontroller">     <!-- relies on by-type autowiring constructor-args -->     <property name="applicationurl" value="${application.url}" /> </bean> </beans> 

application properties file:

#facebook facebook.clientid=ideletetherealvalue facebook.clientsecret=ideletetherealvalue  #twitter twitter.consumerkey=ideletetherealvalue twitter.consumersecret=ideletetherealvalue  application.url=http://localhost:8080/myapp 

the url application http://localhost:8080/myapp authorized in facebook application.

when click on "sign in twitter" or "sign in facebook", redirect twitter or facebook submit login , password.

1.twitter when submit credentials page ask me allow application allow application , following error :

debug [org.springframework.web.servlet.mvc.support.defaulthandlerexceptionresolver] [] http-bio-8080-exec-10 resolving exception handler [public java.lang.string org.springframework.social.connect.web.connectcontroller.connectionstatus(java.lang.string,org.springframework.web.context.request.nativewebrequest,org.springframework.ui.model)]: org.springframework.beans.factory.beanexpressionexception: expression parsing failed; nested exception org.springframework.expression.spel.spelevaluationexception: el1007e:(pos 0): field or property 'name' cannot found on null     debug [org.springframework.web.servlet.dispatcherservlet] [] http-bio-8080-exec-10 not complete request     org.springframework.beans.factory.beanexpressionexception: expression parsing failed; nested exception org.springframework.expression.spel.spelevaluationexception: el1007e:(pos 0): field or property 'name' cannot found on null   complete error here http://pastebin.com/hyricyfu 

2.facebook when submit credentials following error:

org.springframework.beans.factory.beanexpressionexception: expression parsing failed; nested exception org.springframework.expression.spel.spelevaluationexception: el1007e:(pos 0): field or property 'name' cannot found on null debug [org.springframework.web.servlet.mvc.support.defaulthandlerexceptionresolver] [] http-bio-8080-exec-2 resolving exception handler [public java.lang.string org.springframework.social.connect.web.connectcontroller.connectionstatus(java.lang.string,org.springframework.web.context.request.nativewebrequest,org.springframework.ui.model)]: org.springframework.beans.factory.beanexpressionexception: expression parsing failed; nested exception org.springframework.expression.spel.spelevaluationexception: el1007e:(pos 0): field or property 'name' cannot found on null debug [org.springframework.web.servlet.dispatcherservlet] [] http-bio-8080-exec-2 not complete request org.springframework.beans.factory.beanexpressionexception: expression parsing failed; nested exception org.springframework.expression.spel.spelevaluationexception: el1007e:(pos 0): field or property 'name' cannot found on null 

the complete error here http://pastebin.com/hyricyfu

questions: according understand error comes

<bean id="connectionrepository" factory-method="createconnectionrepository"        factory-bean="usersconnectionrepository" scope="request">     <constructor-arg value="#{request.userprincipal.name}" />     <aop:scoped-proxy proxy-target-class="false" /> </bean> 

error message : field or property 'name' cannot found on null

i need confirmation : a- have create in database user when user submit ? controller have extend ? if has example help

b- if wrong, what's happening , why getting error ?

yes, correct - problem configuration.

<bean id="connectionrepository" factory-method="createconnectionrepository"        factory-bean="usersconnectionrepository" scope="request">     <constructor-arg value="#{request.userprincipal.name}" />     <aop:scoped-proxy proxy-target-class="false" /> </bean> 

the above creates connection repository argument constructor request.userprincipal.name - work if user signed in (this trying instantiate per-request repository principal user - needs id repository tied to).

check docs handling social signin: http://docs.spring.io/spring-social/docs/1.0.3.release/reference/html/signin.html

you see there different approach altogether social sign-up (vs signed in users integrating social 3rd parties)


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -