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)
i3wangyi
  • 2,279
  • 3
  • 15
  • 12

8 Answers8

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.

Peter Knego
  • 79,991
  • 11
  • 123
  • 154
  • 1
    I did compile under java 7. – i3wangyi Apr 25 '14 at 06:28
  • Better double check. `version 52.0` means code was compiled under Java8: (see offset 6) http://en.wikipedia.org/wiki/Java_class_file#General_layout – Peter Knego Apr 25 '14 at 07:54
  • 3
    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? – eeq May 26 '14 at 20:33
  • 3
    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 system – JaapH Jun 09 '14 at 03:22
  • 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" – the_marcelo_r Dec 24 '14 at 00:49
  • 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. – Scott Boring May 29 '15 at 05:16
  • I solved the problem changing to Java 1.7 in Properties -> Project Facets – kike Jul 27 '15 at 11:13
  • 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? – Giuseppe Adaldo Sep 08 '16 at 10:09
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
craigrs84
  • 3,048
  • 1
  • 27
  • 34
  • this is brilliant as it means you don't have to change the PATH permanently! Thanks! – tomgeraghty3 Nov 25 '14 at 22:24
  • 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](http://superuser.com/a/606124). – oliverdm Dec 19 '14 at 19:28
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

icordoba
  • 1,834
  • 2
  • 33
  • 60
  • You should cite and merely provide the link for further info. As is, if the link breaks or goes down, your post becomes useless. – scenia Jun 18 '15 at 18:21
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'

Ridcully
  • 23,362
  • 7
  • 71
  • 86
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.

Miloš Ranđelović
  • 444
  • 1
  • 5
  • 13
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.

Community
  • 1
  • 1
Denis Kutlubaev
  • 15,320
  • 6
  • 84
  • 70
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.

Tad
  • 4,668
  • 34
  • 35
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

PSchuette
  • 4,463
  • 3
  • 19
  • 21