GAE No forced path servlet for xxx.jsp

2019-07-26 16:15发布

This is my first post on stackoverflow. Learning how to use Google App Engine. The program works fine on my local machine but when I upload it online it fails to run. my hunch is some issue with web.xml

<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://java.sun.com/xml/ns/javaee"
 xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
 http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
 <servlet>
     <servlet-name>home-jsp</servlet-name>
     <jsp-file>/home.jsp</jsp-file>
 </servlet>
 <servlet-mapping>
     <servlet-name>home-jsp</servlet-name>
     <url-pattern>/home.jsp</url-pattern>
 </servlet-mapping>

 <servlet>
    <servlet-name>watch</servlet-name>
    <servlet-class>watch.WatchServlet</servlet-class>
 </servlet>
 <servlet-mapping>
     <servlet-name>watch</servlet-name>
    <url-pattern>/</url-pattern>
 </servlet-mapping>

 <servlet>
     <servlet-name> Prefs</servlet-name>
     <servlet-class>watch.PrefsServlet</servlet-class>
 </servlet>
 <servlet-mapping>
     <servlet-name>Prefs</servlet-name>
     <url-pattern>/prefs</url-pattern>
 </servlet-mapping>

 <security-constraint>
     <web-resource-collection>
         <web-resource-name>prefs</web-resource-name>
         <url-pattern>/prefs</url-pattern>
     </web-resource-collection>
     <auth-constraint>
         <role-name>*</role-name>
     </auth-constraint>
 </security-constraint>
</web-app>

Looking at the Log entry I see

    2013-10-27 13:46:54.348
Failed startup of context com.google.apphosting.utils.jetty.RuntimeAppEngineWebAppContext@7daf3e{/,/base/data/home/apps/s~fridoswatch/1.371221215746279551}
java.lang.IllegalStateException: No forced path servlet for /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:446)
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:435)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:442)
    at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:186)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:306)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:298)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:439)
    at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
    at java.lang.Thread.run(Thread.java:724)

and the critical error log says

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:446)
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:435)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:442)
    at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:186)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:306)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:298)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:439)
    at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
    at java.lang.Thread.run(Thread.java:724)

been banging my head against this for two days now. Any help with this would be awesome for my sanity.

1条回答
Melony?
2楼-- · 2019-07-26 16:46

You have both a servlet and a servlet-mapping for the URL /home.jsp in your web.xml. Remove one of them.

查看更多
登录 后发表回答