我正在尝试将Struts 2框架用于我的Google App Engine项目。我已正确配置了struts框架,并在 struts-config.xml 文件中创建了一个操作:
<package name="myproj" namespace="/myproj" extends="struts-default">
<action name="login">
<result>/login.jsp</result>
</action>
我正试图通过http://localhost:8080/myproj/login.action访问上述操作。但是我没有按预期获得我的login.jsp页面。相反,我收到以下错误。
HTTP ERROR 500
Problem accessing /myproj/login.action. Reason:
java.lang.NoClassDefFoundError: javax.swing.tree.TreeNode is a restricted class. Please see the Google App Engine developer's guide for more details.
Caused by:
javax.servlet.ServletException: java.lang.NoClassDefFoundError: javax.swing.tree.TreeNode is a restricted class. Please see the Google App Engine developer's guide for more details.
at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
at org.apache.jasper.runtime.PageContextImpl.access$1100(PageContextImpl.java:64)
at org.apache.jasper.runtime.PageContextImpl$12.run(PageContextImpl.java:745)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:743)
at org.apache.jsp.getin_jsp._jspService(getin_jsp.java:102)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
at com.google.appengine.tools.development.PrivilegedJspServlet.access$101(PrivilegedJspServlet.java:23)
at com.google.appengine.tools.development.PrivilegedJspServlet$2.run(PrivilegedJspServlet.java:59)
at java.security.AccessController.doPrivileged(Native Method)
at com.google.appengine.tools.development.PrivilegedJspServlet.service(PrivilegedJspServlet.java:57)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
我是否需要配置一些东西来修复上述错误并使Struts 2框架在Google App Engine上运行?
答案 0 :(得分:2)
我在Appengine Groups发现了这个问题:http://groups.google.com/group/google-appengine-java/browse_thread/thread/dd84e44f604498c4
当然,您必须关注Will it play on GAE
中的链接答案 1 :(得分:2)
您可以关注我的博客教程http://whyjava.wordpress.com/2009/08/30/creating-struts2-application-on-google-app-engine-gae/,其中包含您需要的所有信息。
答案 2 :(得分:1)
在Struts 2.3.24中使用了最新版本的FreeMarker - 2.3.22,上述解决方案不再适用。相反,有一个专用的FreeMarker版本可以与AppEngine一起使用,可以添加到pom中,如下所示:
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>${struts2.version}</version>
<exclusions>
<exclusion>
<artifactId>freemarker</artifactId>
<groupId>org.freemarker</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker-gae</artifactId>
<version>2.3.22</version>
</dependency>