Changed JSF interceptors to fail fast and show problem report to users, fixed test in showcase,

ensured that config errors will show problem report when using filter dispatcher
WW-1424 
WW-1349


git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@441881 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Donald J. Brown
2006-09-10 00:18:08 +00:00
parent c2bc1441b6
commit 6a2a22f659
4 changed files with 23 additions and 6 deletions
@@ -1,3 +1,5 @@
package org.apache.struts2.showcase.tutorial;
import junit.framework.TestCase;
/**
@@ -555,7 +555,7 @@ public class Dispatcher {
* @param code the HttpServletResponse error code (see {@link javax.servlet.http.HttpServletResponse} for possible error codes).
* @param e the Exception that is reported.
*/
private void sendError(HttpServletRequest request, HttpServletResponse response,
public void sendError(HttpServletRequest request, HttpServletResponse response,
ServletContext ctx, int code, Exception e) {
if (devMode) {
response.setContentType("text/html");
@@ -613,8 +613,12 @@ public class Dispatcher {
/** Simple accessor for a static method */
public class Locator {
public Location getLocation(Throwable t) {
return LocationUtils.getLocation(t);
public Location getLocation(Object obj) {
Location loc = LocationUtils.getLocation(obj);
if (loc == null) {
return Location.UNKNOWN;
}
return loc;
}
}
@@ -49,8 +49,10 @@ import org.apache.struts2.dispatcher.mapper.ActionMapper;
import org.apache.struts2.dispatcher.mapper.ActionMapperFactory;
import org.apache.struts2.dispatcher.mapper.ActionMapping;
import com.opensymphony.module.sitemesh.RequestConstants;
import com.opensymphony.util.ClassLoaderUtil;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.XWorkException;
/**
* Master filter for Struts that handles four distinct
@@ -214,8 +216,16 @@ public class FilterDispatcher implements Filter, StrutsStatics {
Dispatcher.setInstance(du);
}
ActionMapper mapper = ActionMapperFactory.getMapper();
ActionMapping mapping = mapper.getMapping(request, du.getConfigurationManager().getConfiguration());
ActionMapper mapper = null;
ActionMapping mapping = null;
try {
mapper = ActionMapperFactory.getMapper();
mapping = mapper.getMapping(request, du.getConfigurationManager().getConfiguration());
} catch (Exception ex) {
du.sendError(request, response, servletContext, response.SC_INTERNAL_SERVER_ERROR, ex);
ActionContextCleanUp.cleanUp(req);
return;
}
if (mapping == null) {
// there is no action in this request, should we look for a static resource?
@@ -229,7 +229,8 @@ public class FacesSetupInterceptor extends FacesSupport implements Interceptor {
}
}
} else {
log.error("Unable to initialize jsf interceptors probably due missing JSF implementation libraries");
throw new StrutsException("Unable to initialize jsf interceptors probably due missing JSF implementation libraries",
invocation.getProxy().getConfig());
}
return invocation.invoke();
}