NullPointerException at org.agorava.cdi.InCookieProducer.getRepoId(InCookieProducer.java:57)

17 views
Skip to first unread message

f@b.e

unread,
May 4, 2016, 5:55:51 AM5/4/16
to Agorava Dev
Hello,

trying to access a facebook user profile from our wildfly backend, but the actual facebook token is acquired on the client side on android or ios. So android/ios asks user for permission and sends the token to the backend for the backend to continue some work with it. Strange is that the method works for ios when it is called the second time, when we test the endpoint with postman it works always, any help would be great. (Also tried several different approaches with OAuthLifeCycleService with same error but different stack trace...)

Here code sample:


@Inject

private OAuthLifeCycleService lifeCycleService;

@Inject

@Facebook

@Current

private OAuthSession socialSession;


@POST

public String createEnduser(String token) {

Token t = new Token(token, "");

socialSession.setAccessToken(t);

lifeCycleService.endDance();

UserProfile profile = socialSession.getUserProfile();

//... store user id and so on ...

return profile.getId();

}


exception we get:


java.lang.NullPointerException

        at org.agorava.cdi.InCookieProducer.getRepoId(InCookieProducer.java:57)

        at org.agorava.cdi.InCookieProducer.getCurrentRepository(InCookieProducer.java:75)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

        at java.lang.reflect.Method.invoke(Method.java:497)

        at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:88)

        at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:78)

        at org.jboss.weld.injection.producer.ProducerMethodProducer.produce(ProducerMethodProducer.java:95)

        at org.jboss.weld.injection.producer.AbstractMemberProducer.produce(AbstractMemberProducer.java:167)

        at org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:183)

        at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:96)

        at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:101)

        at org.jboss.weld.bean.ContextualInstanceStrategy$CachingContextualInstanceStrategy.get(ContextualInstanceStrategy.java:178)

        at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)

        at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:99)

        at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:99)

        at org.jboss.weld.proxies.Identifiable$Iterable$Repository$Serializable$UserSessionRepository$979762330$Proxy$_$$_WeldClientProxy.getCurrent(Unknown Source)

        at org.agorava.cdi.InApplicationProducer.resolveSession(InApplicationProducer.java:83)

        at org.agorava.cdi.InRequestProducer.resolveSession(InRequestProducer.java:73)

        at org.agorava.cdi.InCookieProducer.resolveSession(InCookieProducer.java:87)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

        at java.lang.reflect.Method.invoke(Method.java:497)

        at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:88)

Werner Keil

unread,
May 4, 2016, 9:15:53 AM5/4/16
to Agorava Dev
Hi,

Thanks for your interest and message.

>token is acquired on the client side on android or ios. 
I am not aware of Wildfly running on android or ios. We have not tested it against Mobile browsers as of now, though it should work for most of them.
The Facebook connector has a far more severe problem (though that only kicks-in once the token had already been exchanged) due to a Facebook bug still requesting a seemingly deprecated Facebook method.

How did you get the API key and secret from Facebook?

Regards,
Werner

f@b.e

unread,
May 4, 2016, 9:46:43 AM5/4/16
to Agorava Dev
Sorry for the confusion, there is no wildfly on android nor on ios for now :), there are native applications for each platform one, and they use the standard facebook sdk to get the long living access token. There is now webbrowser involved anywhere. After ios/android native app gets the token it calls on our wildfly backend a json rest service which than tries to validate the token from the backend side (server sided). This is important because the business logic requires the backend to daily check every registered facebook user for their friend list without the interaction of the native ios/android applications (there will be no session nor request).

We solved the first part of the issue, when android/ios calls the webservice and set/accept the cookie than the nullpointer exception wont happen. But god knows what will happen when an async worker thread without request scope goes for the users friend list :)

Werner Keil

unread,
May 5, 2016, 12:33:59 PM5/5/16
to Agorava Dev
Could you point us to the solution or implementation you used please?
Assuming it's open source the Github or other repo would be great, allowing to try it out and see the problem.

Cheers,
Werner

f@b.e

unread,
May 9, 2016, 8:55:00 AM5/9/16
to Agorava Dev
Sorry it is a closed source for now, I could create a small working project for demonstration perhaps.

Werner Keil

unread,
Jun 8, 2016, 12:26:03 PM6/8/16
to Agorava Dev
If you can we'd be happy to have a look.
Reply all
Reply to author
Forward
0 new messages