500 server error google+ API

1

I know this question must have been asked multiple times, but I don't get the error removed.

I have followed the tutorial "Getting Started with Google APIs (Java)" on YouTube.

The tutorial tells you that you need to install mercurial, maven and the Google+ API libraries. Done all of that.

I've added the Google+ API to the developers console and created a new API Key and inserted this one in the code.

enter image description here

enter image description here

This is the code:

  /*
   * Copyright (c) 2013 Google Inc.
   *
   * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
   * in compliance with the License. You may obtain a copy of the License at
   *
   * http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software distributed under the License
   * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
   * or implied. See the License for the specific language governing permissions and limitations under
   * the License.
   */

  package example;

  import com.google.api.client.extensions.appengine.http.UrlFetchTransport;
  import com.google.api.client.http.HttpTransport;
  import com.google.api.client.json.JsonFactory;
  import com.google.api.client.json.jackson2.JacksonFactory;
  import com.google.api.services.plus.Plus;
  import com.google.api.services.plus.PlusRequestInitializer;
  import com.google.api.services.plus.model.Activity;
  import com.google.api.services.plus.model.ActivityFeed;

  import java.io.IOException;
  import java.io.Writer;
  import java.util.List;

  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;

  /**
   * Sample Google+ servlet that does a search on public activities.
   *
   * @author Nick Miceli
   */
  public class PlusBasicServlet extends HttpServlet {

    /**
     * Enter your API key here from https://code.google.com/apis/console/?api=plus under "API Access".
     */
    private static final String API_KEY = "HEREISMYAPIKEY";

    private static final long serialVersionUID = 1;

    @Override
    public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {

        HttpTransport httpTransport = new UrlFetchTransport();
      JsonFactory jsonFactory = new JacksonFactory();

      System.out.println("Jsonfactory aangemaakt");
      Plus plus = new Plus.Builder(httpTransport, jsonFactory, null).setApplicationName("")
          .setGoogleClientRequestInitializer(new PlusRequestInitializer(API_KEY)).build();
      System.out.println("Plus aan gemaakt");
      ActivityFeed myActivityFeed = plus.activities().search("Google").execute();
      System.out.println("MyActivityFeed aangemaakt");
      List<Activity> myActivities = myActivityFeed.getItems();
      System.out.println("Lijst aangemaakt");
      resp.setContentType("text/html");
      resp.setStatus(200);
      Writer writer = resp.getWriter();
      writer.write("<ul>");
      for (Activity a : myActivities) {
        writer.write("<li>" + a.getTitle() + "</li>");
      }
      writer.write("</ul>");
    }

  }

Run as webapp:

jun 29, 2015 9:50:40 PM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
jun 29, 2015 9:50:42 PM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
INFO: Successfully processed C:\Users\Elvira\workspace\PlusBasic\war\WEB-INF/appengine-web.xml
jun 29, 2015 9:50:42 PM com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml
INFO: Successfully processed C:\Users\Elvira\workspace\PlusBasic\war\WEB-INF/web.xml
jun 29, 2015 9:50:42 PM com.google.appengine.tools.development.SystemPropertiesManager setSystemProperties
INFO: Overwriting system property key 'java.util.logging.config.file', value 'D:\eclipse\plugins\com.google.appengine.eclipse.sdkbundle_1.9.20\appengine-java-sdk-1.9.20\config\sdk\logging.properties' with value 'WEB-INF/logging.properties' from 'C:\Users\Elvira\workspace\PlusBasic\war\WEB-INF\appengine-web.xml'
jun 29, 2015 9:50:42 PM com.google.apphosting.utils.jetty.JettyLogger info
INFO: Logging to JettyLogger(null) via com.google.apphosting.utils.jetty.JettyLogger
jun 29, 2015 9:50:44 PM com.google.apphosting.utils.jetty.JettyLogger info
INFO: jetty-6.1.x
jun 29, 2015 9:50:45 PM com.google.apphosting.utils.jetty.JettyLogger info
INFO: Started SelectChannelConnector@127.0.0.1:8888
jun 29, 2015 9:50:45 PM com.google.appengine.tools.development.AbstractModule startup
INFO: Module instance default is running at http://localhost:8888/
jun 29, 2015 9:50:45 PM com.google.appengine.tools.development.AbstractModule startup
INFO: The admin console is running at http://localhost:8888/_ah/admin
jun 29, 2015 9:50:45 PM com.google.appengine.tools.development.DevAppServerImpl doStart
INFO: Dev App Server is now running
java
eclipse
google-app-engine
asked on Stack Overflow Jun 29, 2015 by Elvira • edited Nov 1, 2015 by pnuts

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0