Announcement Announcement Module
Collapse
No announcement yet.
Nullpointer exception in extractAccountId Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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?

      Comment


      • #4
        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.

        Comment


        • #5
          thanks a lot.

          I will try this.

          Comment

          Working...
          X