GAE 500 server error
Asked Answered
A

8

14

I'm developing app on GAE, I test the website locally fine however, every time I tried to deploy it to the GAE it reports with Error: Server Error

The server encountered an error and could not complete your request.
Please try again in 30 seconds. 

I searched a lot in google, seems no answer could solve my question. When I look for the log in the GAE app, following is the major problem I found so far. Initially, I thought it's due to JDK8 but when I set JDK8 I can't even run the app locally!

    Uncaught exception from servlet
java.lang.UnsupportedClassVersionError: org/apache/jsp/index_jsp : Unsupported major.minor version 52.0
    at com.google.appengine.runtime.Request.process-aea5c804a9f29902(Request.java)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:795)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:360)
    at org.mortbay.util.Loader.loadClass(Loader.java:91)
    at org.mortbay.util.Loader.loadClass(Loader.java:71)
    at org.mortbay.jetty.servlet.Holder.doStart(Holder.java:73)
    at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:242)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:685)
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:437)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:444)
    at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:188)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:308)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:300)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:441)
    at java.lang.Thread.run(Thread.java:724)
Athlete answered 25/4, 2014 at 6:13 Comment(0)
G
17

This is the telltale: Unsupported major.minor version 52.0. This happens when you compile on higher version JDK (52 = java8) and then execute it on lower JRE version (GAE uses java7).

GAE does not yet support Java8, so you should compile under Java7.

Graze answered 25/4, 2014 at 6:21 Comment(8)
I did compile under java 7.Athlete
Better double check. version 52.0 means code was compiled under Java8: (see offset 6) en.wikipedia.org/wiki/Java_class_file#General_layoutGraze
I have the same problem, and even all settings indicate Java 7, the GAE deployment somehow compiles the JSP files using Java 8 if present in OSX. Also checked the generated files in tmp directory and all Java classes are correctly 51.0, but JSP classes are 52.0. Any further ideas?Mitran
Had exactly the same problem where all settings were set to Java 7 but eclipse used Java 8 for the JSP files. Only solution I found that works is removing Java 8 from my systemCalia
I had the exact same problem and I DON'T EVEN HAVE JDK8 IN MY MACHINE :) but I solved it after cleaning everything before the build+deploy, e.g., "mvn clean appengine:update"Fowling
It is correct that the compilation version is wrong, unfortunately app engine update compiles the JSP with Java 8 even if the mvn compiler settings are set Java 7. You'll need to set the JAVA_HOME variable to java 7 as stated in other answers.Odom
I solved the problem changing to Java 1.7 in Properties -> Project FacetsCyler
Same problem, I did all the steps: change JAVA_HOME to 7, maven is 3.3.9 and is pointing to Java 7 home, I have the plugin in maven that states to build with Java 7, I don't have any JSP, just one simple HttpServlet that print out "hello world". in the target folder, I checked the .class version and it says 51.0, but still, when I deploy from command line with mvn clean appengine:update (not from Eclipse) I have the same error. What am I doing wrong?Paedo
S
8

I had the same problem on Windows when Java 8 was installed.

I tried modifying the project/workspace settings but it didn't help me.

So, I created the following batch file as a workaround for GAE projects:

eclipse_gae.bat:

SET JAVA_HOME="C:\Program Files\Java\jdk1.7.0_55"
SET PATH="%JAVA_HOME%\bin"
START eclipse.exe
Saskatoon answered 23/7, 2014 at 2:3 Comment(2)
this is brilliant as it means you don't have to change the PATH permanently! Thanks!Fluorinate
Great, thanks! Used it with maven and had to set the java home without quotes. A shortcut is to use Progra~1 or Progra~2 (for x86) to avoid problems with spaces and parentheses as posted on superuser.Tiv
R
5

there is no need to fully remove Java 8 from MacOS. Just reconfigure Eclipse as shown here to force it to compile JSPs as Java 7: http://java.wildstartech.com/Java-Platform-Standard-Edition/mac-os-x-java-development/how-to-configure-eclipse-to-run-with-java-7-when-java-8-is-installed

Rojas answered 27/11, 2014 at 8:21 Comment(1)
You should cite and merely provide the link for further info. As is, if the link breaks or goes down, your post becomes useless.Prosthetics
F
4

Make sure, that the version of Project Properties -> Project Facets -> Java is set to 1.7 and not to 1.8.

This is also nicely explained in the plugin's documentation section 'Changing the JDK Compliance Level'

Furrier answered 24/10, 2015 at 13:20 Comment(1)
short and precise solution.Horseback
H
3

I ran into a similar issue now. My setup is OS X + JDKs 6, 7 and 8, and in my eclipse.ini I had:

-vm /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/bin/java

Apparently it will use that compiler no matter what you set in global/project preferences (I even removed JDK 8 from the Installed JRE list, no success).

Once I've changed that to use JDK 7 and redeployed my GAE app, it worked.

Helle answered 26/6, 2014 at 4:41 Comment(0)
J
2

You have to compile with Java 1.7. But if you have *.jsp files, you should also completely remove Java 1.8 from the system. If you use Mac, here is how you can do it.

Jonasjonathan answered 8/8, 2014 at 17:32 Comment(0)
C
2

If you are using gradle (e.g. Android Studio) on a mac, you can work around this problem by adding the following lines to the top of your gradlew script:

# Insist on java 7 JAVA_HOME=$(/usr/libexec/java_home -v 1.7)

Variations of this method should work on other platforms.

Christogram answered 7/1, 2015 at 15:34 Comment(0)
C
0

I'm sure this has been resolved, but here is the solution

GAE runs on java7 (as indicated by Mr. Knego) so maven must be compiling with java7. Do the following:

I prefer to do all this in the terminal

Edit bash profile:

touch ~/.bash_profile; open ~/.bash_profile

Set Java Home Directory

#set JAVA_HOME
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
export JAVA_HOME

# For Apache Maven Commands
export M2_HOME=/Users/your-username/your/path/to/maven/apache-maven-3.3.3
export PATH=$PATH:$M2_HOME/bin

Navigate to your project folder (with pom.xml) and reinstall a clean version of maven

mvn clean install

Navigate to EAR or WAR directory and deploy with a new runtime

mvn appengine:update

If you are using endpoints, you should update your endpoint libraries

Cachou answered 6/7, 2015 at 12:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.