GAE getting started in Java, Eclipse Indigo - can't compile as 1.6

血红的双手。 提交于 2019-12-30 05:24:07

问题


I feel like I keep going in circles with this one. I followed the Getting Started guide for Google App Engine (https://developers.google.com/appengine/docs/java/gettingstarted/) in Eclipse and everything went relatively well until I uploaded it to the App Engine.

I was getting 500 errors so I checked the logs and found this: "guestbook/SignGuestbookServlet : Unsupported major.minor version 51.0]"

I then search for this problem (on stackoverflow, of course) and found this solution: Google App Engine and Java Version?

So I set the compliance level to 1.6 and then at the bottom of the dialog I get the warning that "When selecting 1.6 compliance, make sure to have a compatible JRE installed and activated (currently 1.7)".

I happy click OK, and it prompts for a rebuild. After the rebuild I then get this new error: "Java compiler level does not match the version of the installed Java project facet."

Not having knowingly used any facets in the project I do a search for some help (again on stackoverflow) and find this: "Faceted Project Prblem (Java Version Mismatch)" error message

Unfortunately it is not even close to being helpful because I am not used Maven, and when I bring up the properties of the project there is no Project Properties -> Project Facets panel for me to change a version on.

So it seems that I am stuck with something that either cannot be compiled in Eclipse or cannot be deployed to App Engine. I know that I am probably missing something obvious here but I can't quite put my finger on it.

UPDATE: I have uninstalled all JREs and JDKs, and reinstalled only jdk1.6.0_32. The problem continues exactly the same.


回答1:


I had the same problem. I was able to resolve by using the Navigator view and editing the .settings/org.eclipse.wst.common.project.facet.core.xml, changing to:

<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
  <installed facet="java" version="1.6"/>
</faceted-project>

After this change, the error went away and I could successfully run the GWT project in DevMode using jre1.7 but java 1.6 compliance level.

It really seems there should be a way to edit this java facet via project configuration, but I couldn't find it in Juno.




回答2:


The answer, at least in my case, seems to be that if your Eclipse default compiler level is set to 1.7 when you create the Web Application then you can't switch it down to 1.6 successfully.

Example 1: Using JRE 1.6

  1. In eclipse set Preferences->Java->Installed JREs to jdk 1.6.0_32
  2. Set Preferences->Java->Compiler to compliance level 1.6
  3. Use google plugin to create "New Web Application"
  4. Run it locally - success
  5. Deploy to app engine, run remotely - success

Example 2: Using JRE 1.7

  1. In eclipse set Preferences->Java->Installed JREs to jdk 1.7.0_04
  2. Set Preferences->Java->Compiler to compliance level 1.7
  3. Use google plugin to create "New Web Application"
  4. Run it locally - success
  5. Upload to app engine - failure (Unsupported major.minor version 51.0)
  6. In eclipse set Preferences->Java->Compiler to compliance level 1.6 - failure (won't compile locally (Java compiler level does not match the version of the installed Java project facet).

Solution:

Before using the google plugin to create the Web Application, switch the JRE and compiler level to 1.6 (as seen in example 1).

If your project already exists, then hopefully you haven't got too far with it and can create it again.




回答3:


After fighting this issue for a few hours, deleting my nocache.js in the war folder was the final piece of the puzzle.

Contrary to the answer above, I was able to succesfully downgrade to compliance level 1.6 after creating the application in 1.7



来源:https://stackoverflow.com/questions/10694648/gae-getting-started-in-java-eclipse-indigo-cant-compile-as-1-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!