调用projectListRequest.execute()方法时出现NoSuchMethodError错误

时间:2012-11-29 12:02:48

标签: google-bigquery

我正在尝试使用JSP Servlets开发一个简单的BigQuery App。我正在遵循https://developers.google.com/bigquery/docs/authorization

上给出的示例

在早期阶段,没有调用doGet方法,因此我重写了Service方法。代码看起来像这样

public class BigQueryWebServerAuthDemo extends AbstractAuthorizationCodeServlet {

 protected void service(HttpServletRequest req, HttpServletResponse resp)
          throws IOException, ServletException {
     System.out.println(" Start service ");
     doGet(req, resp);
 }

  @Override

  public void doGet(HttpServletRequest request, HttpServletResponse response)
  throws IOException {

   System.out.println(" Start doGet ");

   doPost(request, response);
     }

  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws IOException {
  System.out.println(" Start doPost "); 

response.setContentType("text/html");

PrintWriter writer = response.getWriter();

System.out.println(" Begin loadbigquery() ");

Bigquery bigquery = CredentialUtils.loadbigquery();

System.out.println(" end loadbigquery() ");

Bigquery.Projects.List projectListRequest = bigquery.projects().list();
ProjectList projectList = projectListRequest.execute();

if (projectList.getProjects() != null) {

  java.util.List<Projects> projects = projectList.getProjects();
  writer.println("<h3>BigQuery project list:</h3>");

  for (ProjectList.Projects project : projects) {
    writer.printf("%s<br />", project.getProjectReference().getProjectId());
  }

}
System.out.println(" End doPost "); 
 }

      @Override
     protected AuthorizationCodeFlow initializeFlow() throws ServletException, IOException {

    System.out.println(" inside BigQueryWebServerAuthDemo ---  initializeFlow() "); 

     return CredentialUtils.newFlow();
    }

   @Override
  protected String getRedirectUri(HttpServletRequest request) throws ServletException, IOException {

    System.out.println(" inside BigQueryWebServerAuthDemo --- getRedirectUri() "); 

   return CredentialUtils.getRedirectUri(request);
   }

   @Override
   protected String getUserId(HttpServletRequest request) throws ServletException,               IOException {

    System.out.println(" inside BigQueryWebServerAuthDemo --- getUserId "); 

       return request.getParameter("userId");  
      }

}

我有一个JSP页面,我从中获取参数“userId”。现在我得到了 虽然Eclipse编译器没有显示任何错误,但是execute()方法[projectListRequest.execute()]上的NoSuchMethodError。

下面是我的web.xml配置信息

     <servlet>
       <servlet-name>oauth2callback</servlet-name>
       <servlet-class>main.BigQueryWebServerAuthCallBack</servlet-class>
     </servlet>

    <servlet-mapping>
      <servlet-name>oauth2callback</servlet-name>
      <url-pattern>/oauth2callback</url-pattern>
    </servlet-mapping>

    <servlet>
       <servlet-name>ServletBigQuery</servlet-name>
       <servlet-class>main.BigQueryWebServerAuthDemo</servlet-class>
    </servlet>

    <servlet-mapping>
      <servlet-name>ServletBigQuery</servlet-name>
      <url-pattern>/ServletBigQuery</url-pattern>
    </servlet-mapping>

我还有2个类CredentialUtils和BigQueryWebServerAuthCallBack,如上面提到的教程中所示。

我实际上是Java新手。我想摆脱NoSuchMethodError错误。任何帮助将不胜感激。

0 个答案:

没有答案