App Engine, JSP "No forced path servlet for /WEB-INF/home.jsp"

17 views
Skip to first unread message

valaki via StackOverflow

unread,
Apr 27, 2013, 12:38:38 PM4/27/13
to google-appengin...@googlegroups.com

I have a GAE/J program (with JSP) which runs perfectly on dev server but when I deploy it to App Engine it returns with this:

Error: Server Error

The server encountered an error and could not complete your request. If the problem persists, please report your problem and mention this error message and the query that caused it.

I use Ecplise to deploy my program. My environment and settings:

Win 7 x64

Eclipse Version: Juno Service Release 2 Build id: 20130225-0426

JRE System Library [jdk1.7.0_21]

App Engine SDK 1.7.7

In the App Engine admin console log shows one "Warning":

Failed startup of context com.google.apphosting.utils.jetty.RuntimeAppEngineWebAppContext@1c24a0b{/,/base/data/home/apps/s~4562545625ab/1.366972147789894265}
java.lang.IllegalStateException: No forced path servlet for /WEB-INF/home.jsp
    at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:679)
    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.apphosting.runtime.jetty.AppVersionHandlerMap.createHandler(AppVersionHandlerMap.java:219)
    at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:194)
    at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:134)
    at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:438)
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:480)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:487)
    at com.google.tracing.TraceContext.runInContext(TraceContext.java:774)
    at com.google.tracing.TraceContext$DoInTraceContext.runInContext(TraceContext.java:751)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:342)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:334)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:484)
    at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
    at java.lang.Thread.run(Thread.java:722)

and one "Critical":

Uncaught exception from servlet
javax.servlet.UnavailableException: Initialization failed.
    at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.createHandler(AppVersionHandlerMap.java:228)
    at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:194)
    at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:134)
    at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:438)
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:480)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:487)
    at com.google.tracing.TraceContext.runInContext(TraceContext.java:774)
    at com.google.tracing.TraceContext$DoInTraceContext.runInContext(TraceContext.java:751)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:342)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:334)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:484)
    at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
    at java.lang.Thread.run(Thread.java:722)

The web.xml is the following:

    <static-files>
        <include path="/stylesheets/main.css" />
    </static-files>

    <servlet>
        <servlet-name>home-jsp</servlet-name>
        <jsp-file>/WEB-INF/home.jsp</jsp-file>
    </servlet>
    <servlet-mapping>
        <servlet-name>home-jsp</servlet-name>
        <url-pattern>/WEB-INF/home.jsp</url-pattern>
    </servlet-mapping>  

    <servlet>
        <servlet-name>Home</servlet-name>
        <servlet-class>com.test.HomeServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Home</servlet-name>
        <url-pattern>/index/</url-pattern>
    </servlet-mapping>

Do you have any idea what can be the problem?



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/16254473/app-engine-jsp-no-forced-path-servlet-for-web-inf-home-jsp

Jerome Ansia via StackOverflow

unread,
Apr 27, 2013, 12:43:38 PM4/27/13
to google-appengin...@googlegroups.com

Your URL pattern is wrong it should /home.html for example. You shouldn't have web-inf in your URL pattern



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/16254473/app-engine-jsp-no-forced-path-servlet-for-web-inf-home-jsp/16254541#16254541

BalusC via StackOverflow

unread,
Apr 27, 2013, 1:48:40 PM4/27/13
to google-appengin...@googlegroups.com

The /WEB-INF folder is along with /META-INF folder not supposed to be publicly accessible as they may contain sensitive configuration files and include/tag/template files which shouldn't be requested individually. The average servletcontainer has a builtin access restriction on those folders, which explains why you couldn't access the JSP page this way even though you explicitly remapped it in the web.xml.

If the JSP file in question is after all supposed to be publicly accessible anyway, then placing it in /WEB-INF folder makes simply no sense. Just move the JSP file physically outside that folder and get rid of the whole <servlet> and <servlet-mapping> entries. This way you must be able to access the JSP by simply /home.jsp instead of /WEB-INF/home.jsp.

An alternative, especially if you require some preprocessing business logic, such as loading some data from DB which should be presented in the JSP, would be to create a servlet which is mapped on an URL pattern of e.g. /home and forwards to the JSP file in question in its doGet() method. See also the 2nd Hello World example somewhere halfway in our servlets wiki page.



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/16254473/app-engine-jsp-no-forced-path-servlet-for-web-inf-home-jsp/16255123#16255123
Reply all
Reply to author
Forward
0 new messages