Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Updated ERXServletAdaptor Source


Henrique created a class called ERXServletAdaptor and it is submitted as a pending project wonder patch as we speak (or as I type, as the case may be). I could not get the code in that patch to run as is, so I have changed it just a bit. Here is my version of the class that works for me. Something very similar to this may soon be bundled with project wonder, but for now, you can just toss this class into your project's Sources folder:

No Formatcode
package er.extensions.jspservlet;

import java.lang.reflect.Method;
import java.util.HashMap;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.UnavailableException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.PageContext;

import org.apache.log4j.Logger;

import com.webobjects.jspservlet.WOServletAdaptor;

import er.extensions.appserver.ERXApplication;

 * This class is just a wrapper around <code>WOServletAdaptor</code>.
 * <code>ERXServletAdaptor</code> must be used to make Wonder applications
 * compliant with WAR deployment.
 * <p>
 * This class is responsible to invoke the
 * {@link ERXApplication#setup(String[])} method before the application
 * initialization.
 * @see WOServletAdaptor
 * @author <a href="">Henrique Prange</a>
public class ERXServletAdaptor extends WOServletAdaptor {

	 * Overrides the <code>_appliationInit</code> and invoke the
	 * {@link ERXApplication#setup(String[])} method before the application
	 * initialization.
	 * @see WOServletAdaptor#_applicationInit(ServletContext)
	 * @param servletContext
	 *            The servlet context to get the application class
	 * @throws UnavailableException
	 *             If something wrong happens while trying to invoke the
	 *             application setup method.
	static void invokeApplicationSetupMethod(ServletContext servletContext) throws UnavailableException {
		ClassLoader classLoader = WOServletAdaptor.class.getClassLoader();

		try {
			String applicationClassName = servletContext.getInitParameter("WOApplicationClass");

			if (applicationClassName == null || "".equals(applicationClassName)) {
				throw new UnavailableException("WOApplicationClass must be defined. Verify your web.xml configuration.");

			Class applicationClass = classLoader.loadClass(applicationClassName);

			Method method = applicationClass.getMethod("setup", new Class[] { String[].class });

			method.invoke(null, new Object[] { new String[0] });
		catch (Exception e) {

			throw new UnavailableException("Error initializing ERXServletAdaptor: " + e.getMessage());

	public ERXServletAdaptor() throws ServletException {

	public void init() throws ServletException {