Struts 2 ONGL issue on Google App Engine

GAE(Google App Engine) is a very high security environment, which google limits you in everything. In order to setup your struts 2 on GAE properly, you will need to change the OgnlRuntime security manager.

This is the error you will get on browser

HTTP ERROR: 404

result 'null' not found
RequestURI=/

And on your log

Jul 20, 2009 3:37:20 AM com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
SEVERE: Unable to set parameter [location] in result of type [org.apache.struts2.dispatcher.ServletDispatcherResult]
Caught OgnlException while setting property 'location' on type 'org.apache.struts2.dispatcher.ServletDispatcherResult'. - Class: ognl.OgnlRuntime
File: OgnlRuntime.java
Method: invokeMethod
Line: 508 - ognl/OgnlRuntime.java:508:-1
at com.opensymphony.xwork2.ognl.OgnlUtil.internalSetProperty(OgnlUtil.java:392)
at com.opensymphony.xwork2.ognl.OgnlUtil.setProperty(OgnlUtil.java:143)
at com.opensymphony.xwork2.ognl.OgnlReflectionProvider.setProperty(OgnlReflectionProvider.java:91)
...
...

What you have to do to fix this problem is to add a listener to set the security manager to null.

Listener:

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import ognl.OgnlRuntime;

public class ONGLFixListener implements ServletContextListener, HttpSessionListener, HttpSessionAttributeListener {

public ONGLFixListener() {
}

public void contextInitialized(ServletContextEvent servletContextEvent) {
OgnlRuntime.setSecurityManager(null);
}

//Empty methods that do nothing for the interfaces


web.xml


com.example.ONGLFixListener



This should fix the problem. =D

Comments (0)

Post a Comment