0

I am getting the following error when running a basic servlet on Eclipse Kepler (Windows 7) with GAE SDK 1.9.3 and Java 7:

java.lang.NoClassDefFoundError: javax.servlet.http.HttpServlet is a restricted class.
Please see the Google App Engine developer's guide for more details.

To reproduce:

  1. install Java 7 SDK
  2. install Kepler
  3. install the GAE Eclipse plugin
  4. create a GAE web project
  5. implement the init method of a basic servlet and set load-on-startup to 1 in web.xml
  6. then run the web application

I tried on 2 machines and I got the same error.

Max Leske
  • 5,007
  • 6
  • 42
  • 54
  • Could you provide the code for step 5? – Max Leske Apr 28 '14 at 20:14
  • Just override the init(ServletConfig config) in the servlet and System out something. The method will be called at startup if load-on-startup is set to 1. – user3582739 Apr 28 '14 at 20:30
  • Update: I am getting the same kind of error if I use an incorrect url. For example: http://localhost:8888/abc: Problem accessing /abc. Reason: javax.servlet.FilterChain is a restricted class. Please see the Google App Engine developer's guide for more details. Caused by: java.lang.NoClassDefFoundError: javax.servlet.FilterChain is a restricted class. I don't understand why this restricted class error. – user3582739 Apr 29 '14 at 00:42

2 Answers2

0

Create a servlet by extending HttpServlet, then Override doPost() and doGet() methods in your servlets. For example:

public class FileServlet extends HttpServlet {

    @Override
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          // do something
    }
Andrei Volgin
  • 40,755
  • 6
  • 49
  • 58
0

Well, I found what was wrong and it was my mistake. Sorry. When I installed Java 7, I specified a different directory for the JDK and the JRE, which is fine, except that I gave the same location twice and the files got mixed up. My GAE issue was a side effect.