Results 1 to 5 of 5

Thread: Nullpointer exception in extractAccountId

  1. #1
    Join Date
    Mar 2011
    Posts
    13

    Default Nullpointer exception in extractAccountId

    Hi,
    I am trying to use M2 social to connect to Facebook and I get this error after I click "connect to facebook".

    java.lang.NullPointerException
    org.springframework.social.web.connect.DefaultAcco untIdExtractor.extractAccountId(DefaultAccountIdEx tractor.java:28)
    org.springframework.social.web.connect.ConnectCont roller.connect(ConnectController.java:112)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    org.springframework.web.bind.annotation.support.Ha ndlerMethodInvoker.invokeHandlerMethod(HandlerMeth odInvoker.java:176)
    org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerAdapter.invokeHandlerMethod(An notationMethodHandlerAdapter.java:426)
    org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerAdapter.handle(AnnotationMetho dHandlerAdapter.java:414)
    org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:790)
    org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:719)
    org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:644)
    org.springframework.web.servlet.FrameworkServlet.d oGet(FrameworkServlet.java:549)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:722)

    I am not able to find any information on how to set this AccountId. Can someone shed some light on this?.

    thanks

  2. #2
    Join Date
    Mar 2011
    Location
    Dornbirn, Austria
    Posts
    17

    Default

    The DefaultAccountIdExtractor extracts the java.security.Principal of the current request. Depending on your environment, you may have to implement your own AccountIdExtractor and set it in ConnectController. Alternatively, simply make sure that or userPrinciple is always set.

  3. #3
    Join Date
    Mar 2011
    Posts
    13

    Default thanks. Do you have an example code

    thanks for your help. Just wondering if any sample code you can point me to. I suppose I should be looking at something related to JAAS. Right?

  4. #4
    Join Date
    Mar 2011
    Location
    Dornbirn, Austria
    Posts
    17

    Default

    If you don't use JAAS, don't start now. It's pretty simple to get some custom AccountIdExtractor to work, e.g. one that finds a User object stored as session property.

    By the way, you should decide what you're going to use as accountId. Typically, you could either use a User's numeric id or the username (given that it won't change). I'm using the DB primary key which is the numeric id and that's what I'd recommend too.

  5. #5
    Join Date
    Mar 2011
    Posts
    13

    Default thanks a lot.

    I will try this.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •