26

When I try to run the auto generated code in my google web app project using GAE I get the following error:

Mar 19, 2014 5:21:28 PM com.google.appengine.tools.development.agent.AppEngineDevAgent premain
SEVERE: Unable to load the App Engine dev agent. Security restrictions will not be completely emulated.
java.lang.RuntimeException: Unexpected exception during cast.
at com.google.apphosting.utils.clearcast.ClearCast$CasterImpl.cast(ClearCast.java:385)
at com.google.apphosting.utils.clearcast.ClearCast.staticCast(ClearCast.java:252)
at com.google.apphosting.utils.clearcast.ClearCast.staticCast(ClearCast.java:263)
at com.google.appengine.tools.development.agent.AppEngineDevAgent.premain(AppEngineDevAgent.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(Unknown Source)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(Unknown Source)
Caused by: java.lang.IllegalAccessException: Class com.google.apphosting.utils.clearcast.ClearCast$CasterImpl can not access a member of class com.google.appengine.tools.development.agent.$Proxy0 with modifiers "public"
at sun.reflect.Reflection.ensureMemberAccess(Unknown Source)
at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(Unknown Source)
at java.lang.reflect.AccessibleObject.checkAccess(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.google.apphosting.utils.clearcast.ClearCast$CasterImpl.cast(ClearCast.java:383)
... 9 more

Does anyone have any clue how to fix this?

Code:

@SuppressWarnings("serial")
public class Lab7Servlet extends HttpServlet {
    public void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws IOException {
    resp.setContentType("text/plain");
    resp.getWriter().println("Hello, world");
    }
}
Cœur
  • 37,241
  • 25
  • 195
  • 267
Green_qaue
  • 3,561
  • 11
  • 47
  • 89

3 Answers3

33

iQue,

I encountered exactly the same problem, and I discovered that my eclipse was using JRE 8 (version 1.8). I didn't intend this, and when I changed it to 1.7, this solved the problem.

Edit: Window -> Preferences -> Java -> Installed JREs. Checked jre7 to make it default.

Relevant note: The App Engine installation instructions say to use 1.7 (but don't say you can't use 1.8): https://developers.google.com/appengine/docs/java/gettingstarted/installing

klooth
  • 515
  • 4
  • 6
  • I concur, it's because of Java 1.8. – Dominykas Mostauskis Aug 19 '14 at 17:27
  • Did you have 1.7 on your system or did you have to downgrade somehow? Java won't simply allow me to install 1.7 in parallel. It seems like I have to delete 1.8 first. – DannyA Sep 02 '14 at 13:09
  • @DannyA no, no, no! You just need to right click on your project, choose Properties. Then find in the left list Java compiler and set compiler compliance level to 1.7. It will ask if you want to rebuild your project, you need to click yes otherwise changes won't be applied. – Tw1sty Oct 31 '14 at 15:41
  • Im was getting this error with 1.8.0_45 intelliJ, i updated the maven dependency to App Engine Dev 1.9.21 but the run configuration of the example app (provided by google) was pointing to 1.9.0, it works when i updated it to point to 1.9.21. – jsky Jun 05 '15 at 03:15
0

Have you checked to see if App Engine SDK is present on your project?

GWT error

If not, go to Window -> Preferences -> Google -> App Engine and add it.

Cléssio Mendes
  • 996
  • 1
  • 9
  • 25
0

In my case in addition to what is mentioned in Kevin answer, I also had to modify the value of java to 1.7 in run configurations.

enter image description here

user2983041
  • 1,761
  • 4
  • 19
  • 31