ianlee-dev / facebook-java-api

Automatically exported from code.google.com/p/facebook-java-api
0 stars 0 forks source link

Webapp Helper issuing ClassCast Exception #191

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Download version 2.1.0 and set it up on your webserver
2. Use the Webapp Helper with newInstanceJson
3. Use the requireLogin with the servlet path as next URL

What is the expected output? What do you see instead?

Expected output is:
* when user first comes to the seite, a redirect is issued to login to 
facebook
* redirects back to the servlet, with auth_token key in URL, which gets 
translated to a sessionKey

I get instead:
java.lang.ClassCastException: java.lang.String cannot be cast to 
org.json.JSONObject
...
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to 
org.json.JSONObject
    at 
com.google.code.facebookapi.FacebookJsonRestClient.auth_getSession(Facebook
JsonRestClient.java:275)
    at 
com.google.code.facebookapi.FacebookWebappHelper.doGetSession(FacebookWebap
pHelper.java:192)
    ... 27 more

What version of the product are you using? On what operating system?
2.1.0 on Windows, using Google App Engine for Java (Jetty)

Please provide any additional information below.

Servlet code:

public class AuthenticationServlet extends HttpServlet {

    public void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws IOException {
        FacebookWebappHelper helper = 
FacebookWebappHelper.newInstanceJson(req,
                resp, Constants.API_KEY, Constants.SECRET);
            helper.requireLogin(req.getServletPath());
    }
}

Issue also described here by someone else: 
http://forum.developers.facebook.com/viewtopic.php?pid=137895

Original issue reported on code.google.com by joschaf...@gmx.de on 11 Apr 2009 at 2:05

GoogleCodeExporter commented 8 years ago
by the way: using the newInstanceXml or newInstanceJaxb in 2.1.0 results in an 
error 
about the premature end of the XML body.
Using it with 3.0.0, JSON also falls back to Jaxb and results in the same error

Original comment by joschaf...@gmx.de on 11 Apr 2009 at 2:06

GoogleCodeExporter commented 8 years ago
Please let us know if you were able to solve it. I have been scratching my head 
over
it for long. Yes, json fails with classcastException, xml fails with premature 
e-o-f. 

Not sure what to do ! Sigh !

Original comment by anupambh...@gmail.com on 23 Apr 2009 at 4:50