HttpSession problem in Google App Engine/J
Posted
by Tahir Akram
on Stack Overflow
See other posts from Stack Overflow
or by Tahir Akram
Published on 2009-09-22T21:20:28Z
Indexed on
2010/04/24
16:53 UTC
Read the original article
Hit count: 340
I am writting a Twitter web app by using Twitter4J on GAE/J.
I am saving Twitter and Request Token objects in session so that to be used after call back.
I have two servlets. IndexServlet sets session and HomeServlet get from session (hits on call back by twitter oAuth).
If I comment out session handling lines in both servlets then call backs works fine.
Please suggest any workaround. I am sharing my code here.
IndexServlet.java
Twitter twitter = new Twitter();
twitter.setOAuthConsumer("<masked>", "<masked>");
RequestToken requestToken = null;
try {
requestToken = twitter.getOAuthRequestToken();
log.info("OAuth token has been taken");
} catch (TwitterException e) {
log.warning(e.toString());
}
HttpSession session = request.getSession();
if (session.getAttribute("twitter")==null){
session.setAttribute("twitter", twitter);
out.println("-----------------------------> session is set");
}
if (session.getAttribute("token")==null){
session.setAttribute("token", requestToken);
out.println("-----------------------------> session is set");
}
String authUrl = requestToken.getAuthorizationURL();
HomeServlet.java
HttpSession session = request.getSession();
twitter = (Twitter)session.getAttribute("twitter");
r = (RequestToken)session.getAttribute("token");
twitter.setOAuthAccessToken(r.getAccessToken());
twitter.updateStatus("Hello World!");
Exception
javax.servlet.ServletException: java.lang.ArrayStoreException: [Ljava.lang.String;
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:239)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
at org.mortbay.jetty.Server.handle(Server.java:313)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:830)
at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:139)
at com.google.apphosting.runtime.JavaRuntime.handleRequest(JavaRuntime.java:235)
at com.google.apphosting.base.RuntimePb$EvaluationRuntime$6.handleBlockingRequest(RuntimePb.java:4950)
at com.google.apphosting.base.RuntimePb$EvaluationRuntime$6.handleBlockingRequest(RuntimePb.java:4948)
at com.google.net.rpc.impl.BlockingApplicationHandler.handleRequest(BlockingApplicationHandler.java:24)
at com.google.net.rpc.impl.RpcUtil.runRpcInApplication(RpcUtil.java:359)
at com.google.net.rpc.impl.Server$2.run(Server.java:823)
at com.google.tracing.LocalTraceSpanRunnable.run(LocalTraceSpanRunnable.java:56)
© Stack Overflow or respective owner