Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 377073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:39:39+00:00 2026-05-12T14:39:39+00:00

I am writting a Twitter web app by using Twitter4J on GAE/J. I am

  • 0

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)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:39:40+00:00Added an answer on May 12, 2026 at 2:39 pm

    If setting sessions to true in appengine doesn’t work then get the token and tokenSecret from the requestToken

    Twitter twitter = new Twitter();
    twitter.setOAuthConsumer(consumerKey,consumerSecret);
    RequestToken requestToken = twitter.getOAuthRequestToken();
    
    String token = requestToken.getToken();
    String tokenSecret = requestToken.getTokenSecret();
    
    HttpSession session = request.getSession();
    session.setAttribute("token",token);
    session.setAttribute("tokenSecret",tokenSecret);
    

    In your HomeServlet retrieve the token and tokenSecret from the session:

    Twitter twitter = new Twitter();
    twitter.setOAuthConsumer(consumerKey,consumerSecret);
    AccessToken accessToken =
       twitter.getOAuthAccessToken(token, tokenSecret);
    twitter.setOAuthAccessToken(accessToken);
    

    I also tried storing twitter and requestToken objects before but it didn’t work out for me. But this code I just showed you did. I have a tutorial posted here btw: http://jeungun.wordpress.com/2009/09/03/quick-and-dirty-twitter4j-oauth-for-web-apps/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a web app that will use twitter as its primary log on
I am writing a web app that needs Twitter user's profile photos only. I
I'm writing an app that will feature SSO via Twitter. So far, using the
I am writing a twitter app using jtwitter - and its running inside a
I'm looking for some advice on best practice when writing a web app that
I implemented twitter posting button on my web site using twitter codeigniter library .)
I'm writing a twitter bot using tweepy that will search for mentions to it
I'm writing a little web utility that posts status updates to Twitter and/or Facebook.
Imagine you're writing a web app that will have 1 million users (they all
I´m writing an program that uses twitter. I want that my app shows an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.