1

Web サイトで例を実行して、Java を使用して Google App Engine の使用法を学ぼうとしています。Linux で Eclipse Juno を IDE として使用しています。ローカル マシンで正常にホストされますが、App Engine にデプロイしようとすると、JSP ファイルのコンパイルに失敗します。
SignGuestbookServlet.java

    package com.guest.book;

import java.io.IOException;
import java.util.Date;
import java.util.logging.Logger;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;

public class SignGuestbookServlet extends HttpServlet {
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private static final Logger log = Logger.getLogger(SignGuestbookServlet.class.getName());

    public void doPost(HttpServletRequest req, HttpServletResponse resp)
                throws IOException {
        UserService userService = UserServiceFactory.getUserService();
        User user = userService.getCurrentUser();
        String guestbookName=req.getParameter("guestbookName")==null?"default":req.getParameter("guestbookName");
        Key guestbookKey=KeyFactory.createKey("Guestbook", guestbookName);
        String content = req.getParameter("content");
        Date date=new Date();
        Entity greeting = new Entity("Greeting",guestbookKey);
        greeting.setProperty("user", user);
        greeting.setProperty("content", content);
        greeting.setProperty("date", date);

        DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
        datastore.put(greeting);
        resp.sendRedirect("/guestbook.jsp?guestbookName="+guestbookName);
   }
}  

ゲストブック.jsp

<%@ page import="com.google.appengine.api.users.User" %>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.List" %>
<%@ page import="com.google.appengine.api.users.User" %>
<%@ page import="com.google.appengine.api.users.UserService" %>
<%@ page import="com.google.appengine.api.users.UserServiceFactory" %>
<%@ page import="com.google.appengine.api.datastore.DatastoreServiceFactory" %>
<%@ page import="com.google.appengine.api.datastore.DatastoreService" %>
<%@ page import="com.google.appengine.api.datastore.Query" %>
<%@ page import="com.google.appengine.api.datastore.Entity" %>
<%@ page import="com.google.appengine.api.datastore.FetchOptions" %>
<%@ page import="com.google.appengine.api.datastore.Key" %>
<%@ page import="com.google.appengine.api.datastore.KeyFactory" %><html>
    <head>
    <title>Guestbook</title>
  </head>

  <body>

<%
    String guestbookName= request.getParameter("guestbookName");
    if(guestbookName==null)
    {
        guestbookName="default";
    }
    pageContext.setAttribute("guestbookName", guestbookName);
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    if (user != null) {
      pageContext.setAttribute("user", user);
%>
<p>Hello, <%= user.getNickname() %>! (You can
<a href="<%= userService.createLogoutURL(request.getRequestURI()) %>">sign out</a>.)</p>
<%
    } else {
%>
<p>Hello!
<a href="<%= userService.createLoginURL(request.getRequestURI()) %>">Sign in</a>
to include your name with greetings you post.</p><br>
<%
    }
%>
<%
        DatastoreService datastore=DatastoreServiceFactory.getDatastoreService();
        Key guestbookKey = KeyFactory.createKey("Guestbook",guestbookName);
        Query query= new Query("Greeting",guestbookKey).addSort("date",Query.SortDirection.DESCENDING);
        List<Entity> greetings = datastore.prepare(query).asList(FetchOptions.Builder.withLimit(5));
        if(greetings.isEmpty())
        {%>
        <p> Guestbook <%= guestbookName %> has no messages.</p>
        <%
            }
        else
        {
        %>
        <p>Messages in Guestbook <%= guestbookName %>.</p><br>
        <%
            for(Entity greeting : greetings)
            {
                if(greeting.getProperty("user")==null){
        %>
            <p>An anonymous person wrote:</p>
        <%
            }
        else
        {
        %>
        <p><b><%= greeting.getProperty("user") %></b> wrote: </p>
        <% 
        }
        %>
        <blockquote><%= greeting.getProperty("content") %></blockquote>
        <%
            }
        }
        %>  
<form action="/sign" title="Dash" method="post">
    <div><textarea name="content" rows="3" cols="60"></textarea></div>
    <div><input type="submit" value="Post Greeting" /></div>
    <input type="hidden" name="guestbookName" value="<%= guestbookName %>"/>
  </form>
  </body>
</html>  

エラーログ

com.google.appengine.tools.admin.JspCompilationException: Failed to compile jsp files.
Exception in thread "main" java.lang.ExceptionInInitializerError
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:188)
    at org.apache.jasper.JspCompilationContext.createCompiler(JspCompilationContext.java:238)
    at org.apache.jasper.JspCompilationContext.createCompiler(JspCompilationContext.java:214)
    at org.apache.jasper.JspC.processFile(JspC.java:1181)
    at org.apache.jasper.JspC.execute(JspC.java:1341)
    at com.google.appengine.tools.development.LocalJspC.main(LocalJspC.java:40)
Caused by: java.lang.NullPointerException
    at com.google.appengine.tools.development.LocalJspC$LocalCompiler.<clinit>(LocalJspC.java:53)
    ... 7 more
Error while executing: /usr/lib/jvm/java-7-openjdk-amd64/bin/java -classpath /home/abdul/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.7.7.1/appengine-java-sdk-1.7.7.1/lib/impl/appengine-api-labs.jar:/home/abdul/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.7.7.1/appengine-java-sdk-1.7.7.1/lib/impl/google_sql.jar:/home/abdul/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.7.7.1/appengine-java-sdk-1.7.7.1/lib/impl/appengine-local-runtime.jar:/home/abdul/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.7.7.1/appengine-java-sdk-1.7.7.1/lib/impl/appengine-api.jar:/home/abdul/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.7.7.1/appengine-java-sdk-1.7.7.1/lib/impl/appengine-api-stubs.jar:/home/abdul/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.7.7.1/appengine-java-sdk-1.7.7.1/lib/shared/jsp/repackaged-appengine-ant-1.7.1.jar:/home/abdul/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.7.7.1/appengine-java-sdk-1.7.7.1/lib/shared/jsp/repackaged-appengine-tomcat-juli-6.0.29.jar:/home/abdul/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.7.7.1/appengine-java-sdk-1.7.7.1/lib/shared/jsp/repackaged-appengine-jasper-6.0.29.jar:/home/abdul/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.7.7.1/appengine-java-sdk-1.7.7.1/lib/shared/jsp/repackaged-appengine-jasper-el-6.0.29.jar:/home/abdul/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.7.7.1/appengine-java-sdk-1.7.7.1/lib/shared/jsp/repackaged-appengine-ant-launcher-1.7.1.jar:/home/abdul/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.7.7.1/appengine-java-sdk-1.7.7.1/lib/shared/jsp-api.jar:/home/abdul/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.7.7.1/appengine-java-sdk-1.7.7.1/lib/shared/appengine-local-runtime-shared.jar:/home/abdul/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.7.7.1/appengine-java-sdk-1.7.7.1/lib/shared/servlet-api.jar:/home/abdul/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.7.7.1/appengine-java-sdk-1.7.7.1/lib/shared/el-api.jar:/tmp/appcfg7995795059214651808.tmp/WEB-INF/classes:/tmp/1366711497850-0:/tmp/appcfg7995795059214651808.tmp/WEB-INF/lib/jdo-api-3.0.1.jar:/tmp/appcfg7995795059214651808.tmp/WEB-INF/lib/repackaged-appengine-jasper-jdt-6.0.29.jar:/tmp/appcfg7995795059214651808.tmp/WEB-INF/lib/appengine-api-labs.jar:/tmp/appcfg7995795059214651808.tmp/WEB-INF/lib/repackaged-appengine-jakarta-standard-1.1.2.jar:/tmp/appcfg7995795059214651808.tmp/WEB-INF/lib/jta-1.1.jar:/tmp/appcfg7995795059214651808.tmp/WEB-INF/lib/datanucleus-appengine-2.1.2.jar:/tmp/appcfg7995795059214651808.tmp/WEB-INF/lib/datanucleus-core-3.1.3.jar:/tmp/appcfg7995795059214651808.tmp/WEB-INF/lib/appengine-endpoints.jar:/tmp/appcfg7995795059214651808.tmp/WEB-INF/lib/appengine-jsr107cache-1.7.7.1.jar:/tmp/appcfg7995795059214651808.tmp/WEB-INF/lib/repackaged-appengine-ant-1.7.1.jar:/tmp/appcfg7995795059214651808.tmp/WEB-INF/lib/repackaged-appengine-tomcat-juli-6.0.29.jar:/tmp/appcfg7995795059214651808.tmp/WEB-INF/lib/repackaged-appengine-jakarta-jstl-1.1.2.jar:/tmp/appcfg7995795059214651808.tmp/WEB-INF/lib/datanucleus-api-jdo-3.1.3.jar:/tmp/appcfg7995795059214651808.tmp/WEB-INF/lib/repackaged-appengine-jasper-6.0.29.jar:/tmp/appcfg7995795059214651808.tmp/WEB-INF/lib/geronimo-jpa_2.0_spec-1.0.jar:/tmp/appcfg7995795059214651808.tmp/WEB-INF/lib/repackaged-appengine-jasper-el-6.0.29.jar:/tmp/appcfg7995795059214651808.tmp/WEB-INF/lib/repackaged-appengine-ant-launcher-1.7.1.jar:/tmp/appcfg7995795059214651808.tmp/WEB-INF/lib/asm-4.0.jar:/tmp/appcfg7995795059214651808.tmp/WEB-INF/lib/datanucleus-api-jpa-3.1.3.jar:/tmp/appcfg7995795059214651808.tmp/WEB-INF/lib/jsr107cache-1.1.jar: -Dcom.google.apphosting.runtime.use_java6=false com.google.appengine.tools.development.LocalJspC -uriroot /tmp/appcfg7995795059214651808.tmp -p org.apache.jsp -l -v -webinc /tmp/appcfg7995795059214651808.tmp/WEB-INF/generated_web.xml -d /tmp/1366711497850-0 -javaEncoding UTF-8 
4

0 に答える 0