Create Google App Engine Struts Java Application

System Requirements:

  1. Eclipse 3.5 (Galileo)
  2. Google Eclipse Plugin (http://code.google.com/appengine/docs/java/tools/eclipse.html);

Library Requirements:

  1. commons-fileupload-1.2.1.jar
  2. commons-io.1.3.2.jar
  3. commons-logging-1.0.4.jar
  4. freemarker-2.3.15.jar
  5. ognl-2.7.3.jar
  6. struts2-core-2.1.8.1.jar
  7. struts2-gae-0.1.jar
  8. xwork-core-2.1.6.jar

Start using Eclipse to create a simple Struts web application running within GAE

Step One: Create a new google web project

Open Eclipse -> New -> Web Application Project (Google)

Create a project name called strutssample

Step Two: Import Library

Step Three: Create Package

Under src folder create com.google.app.struts.action, com.google.app.struts.util, freemarker.core, these three package.

Step Four: Create a OgnlListener.class under com.google.app.struts.util

download here (change  .txt to .java)

Step Four: Edit web.xml

download here (change  .txt to .xml)

Step Five: Add TextBlock.java under freemarker.core

download here (change .txt to .java)

Step Six: Create a action java class called: Welcome.java under com.google.app.struts.action

download here (change .txt to .java)

Step Seven: Create struts.xml put it under src folder, same level with log4j.properties

download here (change .txt to .xml)

Step Eight: Create welcome.jsp put it under war/jsp

<html>

<head></head>

<body>

<p>Hello World!</p>

</body>

</html>

Step Nine: Now, start running the GAE

Step Ten: Test your application by clicking: http://localhost: <port number>/Welcome.action

Advertisements

6 Comments

  1. Hi, it doesn´t work. Could you help me?

    Uncaught exception from servlet
    java.lang.ExceptionInInitializerError
    at com.googleapp.struts.util.OgnlListener.contextInitialized(OgnlListener.java:21)
    at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
    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:191)
    at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:168)
    at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:123)
    at com.google.apphosting.runtime.JavaRuntime.handleRequest(JavaRuntime.java:261)
    at com.google.apphosting.base.RuntimePb$EvaluationRuntime$2.handleRequest(RuntimePb.java:8440)
    at com.google.net.rpc.impl.RpcUtil.runRpcInApplication(RpcUtil.java:454)
    at com.google.net.rpc.impl.Server$RpcTask.runInContext(Server.java:572)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:448)
    at com.google.tracing.TraceContext.runInContext(TraceContext.java:688)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:326)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:318)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:446)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:636)
    Caused by: java.lang.IllegalArgumentException: Javassist library is missing in classpath! Please add missed dependency!
    at ognl.OgnlRuntime.(OgnlRuntime.java:165)
    … 22 more
    Caused by: java.lang.ClassNotFoundException: javassist.ClassPool
    at com.google.appengine.runtime.Request.process-63e3730288c16afd(Request.java)
    at java.lang.Class.forName(Class.java:109)
    at ognl.OgnlRuntime.(OgnlRuntime.java:162)
    at com.googleapp.struts.util.OgnlListener.contextInitialized(OgnlListener.java:21)
    at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
    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)
    … 10 more

  2. Hi again,

    I have just enabled the sessions, in appengine-web.xml file. Now, i have a new exception:

    Uncaught exception from servlet
    java.lang.NoClassDefFoundError: Could not initialize class ognl.OgnlRuntime
    at com.googleapp.struts.util.OgnlListener.contextInitialized(OgnlListener.java:21)
    at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
    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:191)
    at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:168)
    at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:123)
    at com.google.apphosting.runtime.JavaRuntime.handleRequest(JavaRuntime.java:261)
    at com.google.apphosting.base.RuntimePb$EvaluationRuntime$2.handleRequest(RuntimePb.java:8440)
    at com.google.net.rpc.impl.RpcUtil.runRpcInApplication(RpcUtil.java:454)
    at com.google.net.rpc.impl.Server$RpcTask.runInContext(Server.java:572)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:448)
    at com.google.tracing.TraceContext.runInContext(TraceContext.java:688)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:326)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:318)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:446)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:636)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s