com.google.apphosting.api.ApiProxy $ CallNotFoundException:无法进行API调用urlfetch

时间:2017-04-02 07:21:10

标签: java spring-mvc twitter4j

最近我开始了twitter4j练习,

ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(true)    
      .setOAuthConsumerKey("***")
      .setOAuthConsumerSecret("***")
      .setOAuthAccessToken("***")
      .setOAuthAccessTokenSecret("***")
      .setHttpConnectionTimeout(100000);
    TwitterFactory tf = new TwitterFactory(cb.build());

    Twitter twitter = tf.getInstance();//TwitterFactory.getSingleton();
    List<Status> statuses;
    try {
        statuses = twitter.getUserTimeline();
        model.put("twitterlist", statuses);
        System.out.println("Showing home timeline.");
        for (Status status : statuses) {
            System.out.println(status.getUser().getName() + ":" +
                               status.getText());
        }
    } catch (TwitterException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        model.put("twitterlist", null);
    }

我收到以下错误

  

com.google.apphosting.api.ApiProxy $ CallNotFoundException:无法在既不是原始请求线程也不是ThreadManager创建的线程的线程中调用API调用urlfetch.Fetch       com.google.apphosting.api.ApiProxy $ CallNotFoundException.foreignThread(ApiProxy.java:792)       com.google.apphosting.api.ApiProxy $ 1.get(ApiProxy.java:175)       com.google.apphosting.api.ApiProxy $ 1.get(ApiProxy.java:172)       com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:89)       twitter4j.AppEngineHttpResponseImpl.ensureResponseEvaluated(AppEngineHttpResponseImpl.java:117)       twitter4j.AppEngineHttpResponseImpl.asJSONArray(AppEngineHttpResponseImpl.java:85)       twitter4j.StatusJSONImpl.createStatusList(StatusJSONImpl.java:465)       twitter4j.LazyJSONImplFactory $ 1.createActualResponseList(LazyJSONImplFactory.java:54)       twitter4j.LazyResponseList.getTarget(LazyResponseList.java:37)       twitter4j.LazyResponseList.iterator(LazyResponseList.java:74)       com.controller.front.FrontController.defaulthomepage(FrontController.java:345)       com.controller.front.FrontController.homePage(FrontController.java:373)       sun.reflect.NativeMethodAccessorImpl.invoke0(原生方法)       sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)       sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)       java.lang.reflect.Method.invoke(Method.java:498)       org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)       org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)       org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)       org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)       org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689)       org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)       org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)       org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)       org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)       org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)       javax.servlet.http.HttpServlet.service(HttpServlet.java:622)       org.springfram

0 个答案:

没有答案