31

I have a problem with the deployment on Google app engine. The project runs fine on my PC but when I upload it, I get the following message:

Please enter code: Either the access code is invalid or the OAuth token is revoked.Details: invalid_grant

After that the browser opens a page where Google app engine asks for permission and, once I give it, provides a code to be copied in the application. But the input window doesn't work since it's stuck with the previous message.

I'm using NetBeans v8 with appengine-java-sdk v1.9, and got the same error with the example project

I alredy tried to delete the file .appcfg_oauth2_tokens_java but it didn't work.

Any help would be appreciated, thanks.

Appengine-web.xml

<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>fiery-plate-97015</application>
<version>1</version>
<threadsafe>true</threadsafe>
<system-properties>
    <property name="java.util.logging.config.file" value="WEB-   INF/logging.properties"/>
</system-properties>

Web.xml

<?xml version="1.0" encoding="utf-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
    <servlet-name>guestbook</servlet-name>
    <servlet-class>guestbook.GuestbookServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>guestbook</servlet-name>
    <url-pattern>/guestbook</url-pattern>
</servlet-mapping>

<servlet>
    <servlet-name>sign</servlet-name>
    <servlet-class>guestbook.SignGuestbookServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>sign</servlet-name>
    <url-pattern>/sign</url-pattern>
</servlet-mapping>

<welcome-file-list>
    <welcome-file>guestbook.jsp</welcome-file>
</welcome-file-list>

Situation update: i never used maven so i took me a while and a lot of errors to make it works. At the end i created a new project following step by step google instruction: https://cloud.google.com/appengine/docs/java/gettingstarted/creating. The project works fine on my pc and seems to deploy correctly but the i get a 500 server error when visiting the page. Meanwhile maven installation messed up with netbeans and, when deploying the first project, i get a exception before being asked for the code:

java.lang.RuntimeException: Cannot get the System Java Compiler. Please use a JDK, not a JRE.

i checked the system variables to point to jdk folder but the problem persists.

katter
  • 311
  • 3
  • 4
  • Do you have your app id in appengine-web.xml or whatever? – shieldstroy Jun 09 '15 at 21:03
  • hmmm... that's when you deploy from netbeans? Could you try uploading with maven of the app engine launcher maybe? – Patrice Jun 09 '15 at 22:54
  • @shieldstroy: the element was empty, i try to fill it with the app id and with project name but didn't work. I deploy it with netbeans (right click on the project -> deploy), i will try with maven. – katter Jun 10 '15 at 08:32
  • 1
    mind posting your appengine-web.xml and your web.xml? there are a couple of places where you should put your appID. If you don't have that, then it's normal you're getting such a message – Patrice Jun 10 '15 at 16:11
  • I can't help you for the netbeans thing, but the 500 you received from the maven project, you probably can go check your logs on console.developers.google.com and try to figure out what the error was :). In the meantime, seems like your appID is in the proper place. You do have enough credentials on the email that deploys this project I assume? – Patrice Jun 11 '15 at 14:37
  • first line of the log: Uncaught exception from servlet java.lang.UnsupportedClassVersionError: org/apache/jsp/guestbook_jsp : Unsupported major.minor version 52.0 I think i have enough credentials but i don't know how i couldn't, i have a normal gmail account – katter Jun 11 '15 at 15:16
  • i fixed the netbeans thing, now i'm stucked with the 500 error in both cases – katter Jun 12 '15 at 09:22

4 Answers4

72

When running mvn appengine:update and you get this:

"Either the access code is invalid or the OAuth token is revoked.Details: invalid_grant"

and then nothing, you need to delete

~/.appcfg_oauth2_tokens_java

On running the command again the browser will launch and ask you to login (to your google app engine account). After login you will get a code to paste into the command line...

Bastiaan Los
  • 721
  • 5
  • 3
1

Your <application>guestbook</applicaiton tag in your appengine-web.xml is incorrect, I believe. That should be your unique project ID at http://console.developers.google.com. You can create one there if you don't have one.

shieldstroy
  • 1,307
  • 1
  • 10
  • 24
  • I copy-past the code of my last attempt where i used project name, i already tried with project id, i'll edit the code above to avoid confusion, sorry. – katter Jun 10 '15 at 20:27
  • Hmm, have you setup a payment on your project? This might not be the issue but it's possible. – shieldstroy Jun 11 '15 at 14:32
  • @shieldstroy Why would billing stop a deployment? I could understand that billing could change the behavior of the project if it's using paid APIs, but deployment won't be influenced. – Patrice Jun 11 '15 at 14:36
  • I think for Compute Engine you have to have billing enabled just to deploy even if you plan on staying within the free quota. I don't know that it is the issue but enabling billing for your project might be worth trying. – shieldstroy Jun 11 '15 at 15:15
  • @Shieldstroy Unless you're talking deploying managed VM, this is irrelevant. Compute engine REQUIRES billing, but if you deploy an app engine project, there is no need for billing – Patrice Jun 12 '15 at 19:23
1

The 500 error from the Google App Engine is due to runtime error. If you check logs, and it seems you did already your getting the Unsupported major.minor version 52.0.

Google App Engine is still running on JDK 7 and you have uploaded a compiled version using JDK8. Please compile using JDK 7 and the problem will disappear.

0

About the first error

Please enter code: Either the access code is invalid or the OAuth token is revoked.Details: invalid_grant

It disappeared while trying to solve the other problems, i don't know what was the cause.

For the second

java.lang.RuntimeException: Cannot get the System Java Compiler. Please use a JDK, not a JRE.

I solved this by changing the value of environment variable PATH, putting jdk directory before anything else.

For the third:

Uncaught exception from servlet java.lang.UnsupportedClassVersionError: org/apache/jsp/guestbook_jsp : Unsupported major.minor version 52.0

The answer provided by Christopher Ebejer is correct. Now the examples work both with maven that with netbeans.

Many thanks.

katter
  • 311
  • 3
  • 4
  • Looking for solution of 'Either the access code is invalid or the OAuth token is revoked.Details: invalid_grant' from last 2 days – Shajeel Afzal Sep 08 '15 at 07:03