{"action":"created","issue":{"url":"https://api.github.com/repos/spring-guides/gs-accessing-facebook/issues/15","labels_url":"https://api.github.com/repos/spring-guides/gs-accessing-facebook/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/spring-guides/gs-accessing-facebook/issues/15/comments","events_url":"https://api.github.com/repos/spring-guides/gs-accessing-facebook/issues/15/events","html_url":"https://github.com/spring-guides/gs-accessing-facebook/issues/15","id":93024804,"number":15,"title":"Null Pointer Exception When Running","user":{"login":"ahmadimt","id":10077189,"avatar_url":"https://avatars.githubusercontent.com/u/10077189?v=3","gravatar_id":"","url":"https://api.github.com/users/ahmadimt","html_url":"https://github.com/ahmadimt","followers_url":"https://api.github.com/users/ahmadimt/followers","following_url":"https://api.github.com/users/ahmadimt/following{/other_user}","gists_url":"https://api.github.com/users/ahmadimt/gists{/gist_id}","starred_url":"https://api.github.com/users/ahmadimt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahmadimt/subscriptions","organizations_url":"https://api.github.com/users/ahmadimt/orgs","repos_url":"https://api.github.com/users/ahmadimt/repos","events_url":"https://api.github.com/users/ahmadimt/events{/privacy}","received_events_url":"https://api.github.com/users/ahmadimt/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-07-04T16:08:38Z","updated_at":"2016-01-05T04:06:06Z","closed_at":null,"body":"Hi,\r\n\r\nI downloaded this project and I have put my acess key and secret key. When I am running the \"complete\" project with gradle bootRun, server starts normally. However, when I hit http://localhost:8080/, it throws NullPointerException. Below is the  the error:\r\n\r\njava.lang.NullPointerException: null\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat java.lang.reflect.Method.invoke(Method.java:497)\r\n\tat org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)\r\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)\r\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)\r\n\tat org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)\r\n\tat org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)\r\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)\r\n\tat org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)\r\n\tat com.sun.proxy.$Proxy40.isAuthorized(Unknown Source)\r\n\tat hello.HelloController.helloFacebook(HelloController.java:26)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat java.lang.reflect.Method.invoke(Method.java:497)\r\n\tat org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)\r\n\tat org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)\r\n\tat org.springframeworkrvlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)\r\n\tat org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:776)\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/spring-guides/gs-accessing-facebook/issues/comments/168890074","html_url":"https://github.com/spring-guides/gs-accessing-facebook/issues/15#issuecomment-168890074","issue_url":"https://api.github.com/repos/spring-guides/gs-accessing-facebook/issues/15","id":168890074,"user":{"login":"zulfyadhie","id":12469459,"avatar_url":"https://avatars.githubusercontent.com/u/12469459?v=3","gravatar_id":"","url":"https://api.github.com/users/zulfyadhie","html_url":"https://github.com/zulfyadhie","followers_url":"https://api.github.com/users/zulfyadhie/followers","following_url":"https://api.github.com/users/zulfyadhie/following{/other_user}","gists_url":"https://api.github.com/users/zulfyadhie/gists{/gist_id}","starred_url":"https://api.github.com/users/zulfyadhie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zulfyadhie/subscriptions","organizations_url":"https://api.github.com/users/zulfyadhie/orgs","repos_url":"https://api.github.com/users/zulfyadhie/repos","events_url":"https://api.github.com/users/zulfyadhie/events{/privacy}","received_events_url":"https://api.github.com/users/zulfyadhie/received_events","type":"User","site_admin":false},"created_at":"2016-01-05T04:06:06Z","updated_at":"2016-01-05T04:06:06Z","body":"I managed to solved this issue by following the link below\r\n\r\nhttp://stackoverflow.com/questions/31362619/spring-social-facebook-isauthorized-throws-nullpointerexception\r\n\r\nChange the HelloController.java from            \r\n```java\r\nif (!facebook.isAuthorized()) {\r\n   return \"redirect:/connect/facebook\";\r\n}\r\n```\r\n\r\nto\r\n```java\r\ntry {\r\n  if (!facebook.isAuthorized()) {\r\n      return \"redirect:/connect/facebook\";\r\n  }\r\n}catch (NullPointerException e){\r\n      return \"redirect:/connect/facebook\";\r\n}\r\n```"}}