我正在尝试在App Engine Google上部署一个小应用程序。该应用程序在localhost上运行良好并部署良好,但我在生产中有错误消息。 服务器遇到错误,无法完成您的请求。
错误
W 2014-04-05 10:12:02.177在java.lang.ClassLoade的com.google.appengine.runtime.Request.process-f5cd6230c17e8858(Request.java)上的EXCEPTION java.lang.IllegalArgumentException
E 2014-04-05 10:12:02.177 javax.servlet.ServletContext log:org.mortbay.jetty.servlet.Holder.doStart(Holder.java:79)atg的 W 2014-04-05 10:12:02.178上下文启动失败com.google.apphosting.utils.jetty.RuntimeAppEngineWebAppContext@ec911f {/,/ base / data / home / apps / s~pattheboldandjuju / 1.37489685 C 2014-04-05 10:12:02.180来自servlet的未捕获异常javax.servlet.UnavailableException:初始化失败。在com.google.apphosting.runtime.jetty.AppVersionHandlerMa 我的代码非常简单: 的web.xml guestbook.jsp GuestbookServlet.java 应用服务引擎-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>Guestbook</servlet-name>
<servlet-class>guestbook.GuestbookServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Guestbook</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>guestbook.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>ObjectifyFilter</filter-name>
<filter-class>com.googlecode.objectify.ObjectifyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ObjectifyFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page import="java.util.List" %>
<%@ page import="guestbook.Message" %>
<!DOCTYPE html>
<html>
<head>
<title>Livre d'or</title>
<meta charset="utf-8" />
</head>
<body>
<h1>Vous avez aimé mon site ? Dites-le dans le Datastore !</h1>
<form action="/post" method="post">
<p>
<label>Votre nom : <input type="text" name="name" /></label>
</p>
<p>
<label>Votre message :<br />
<textarea name="message" style="width: 200px; height: 100px;"></textarea></label>
</p>
<p>
<input type="submit" />
</p>
</form>
<h1>Ils ont aimé :</h1>
<%
List<Message> messages = (List<Message>) request.getAttribute("messages");
for (Message message : messages) {
%>
<p>
<strong><%= message.getName() %></strong> a écrit :<br /> <%= message.getMessage() %>
</p>
<%}%>
</body>
</html>
package guestbook;
import static com.googlecode.objectify.ObjectifyService.ofy;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.google.appengine.api.datastore.KeyFactory;
import com.googlecode.objectify.ObjectifyService;
@SuppressWarnings( "serial" )
public class GuestbookServlet extends HttpServlet {
// Enregistrement de la classe persistable auprès d'Objectify
static {
ObjectifyService.register( Message.class );
}
public void doGet( HttpServletRequest req, HttpServletResponse resp ) {
try {
// Requête Objectify
List<Message> messages = ofy().load().type( Message.class ).ancestor( KeyFactory.createKey( "LivreOr", "livreOr" ) ).order( "-date" ).limit( 5 ).list();
req.setAttribute( "messages", messages );
this.getServletContext().getRequestDispatcher( "/WEB-INF/guestbook.jsp" ).forward( req, resp );
} catch ( ServletException e ) {
e.printStackTrace();
} catch ( IOException e ) {
e.printStackTrace();
}
}
public void doPost( HttpServletRequest req, HttpServletResponse resp ) {
try {
// Création de l'objet
Message message = new Message( req.getParameter( "name" ), req.getParameter( "message" ) );
// Enregistrement de l'objet dans le Datastore avec Objectify
ofy().save().entity( message ).now();
resp.sendRedirect( "/" );
} catch ( IOException e ) {
e.printStackTrace();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>pattheboldandjuju</application>
<version>1</version>
<!--
Allows App Engine to send multiple requests to one instance in parallel:
-->
<threadsafe>true</threadsafe>
<!-- Configure java.util.logging -->
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
</system-properties>
<!--
HTTP Sessions are disabled by default. To enable HTTP sessions specify:
<sessions-enabled>true</sessions-enabled>
It's possible to reduce request latency by configuring your application to
asynchronously write HTTP session data to the datastore:
<async-session-persistence enabled="true" />
With this feature enabled, there is a very small chance your app will see
stale session data. For details, see
http://code.google.com/appengine/docs/java/config/appconfig.html#Enabling_Sessions
-->
</appengine-web-app>
答案 0 :(得分:0)
/WEB-INF
内的资源用于配置,不可公开查看,因此您无法将请求转发至/WEB-INF/guestbook.jsp
。
尝试将guestbook.jsp
移至公共可访问位置。