Have you thought about re-creating the logic in FatalErrorServlet in a Struts 2 Action? That would be the optimal solution. I don't think you are going to get an *Action*Context unless you are in an *Action*. If it has worked in the past, it's probably an unintended side effect.
If you can't refactor to an action, then just refactor your servlet to not use Struts objects. -Wes On Wed, Dec 9, 2009 at 10:28 AM, strutsdev43 <nagmi...@gmail.com> wrote: > > Hi > > Can someone please help with the issue that I am seeing with Struts 2.1.8.1. > > I have a page index.jsp which is protected by role "role1". when the user > tries to access index.jsp, if the user is not authorized, the user is > forwarded to a FatalErrorServlet. > > I have configured in web.xml to forward it to a FatalErrorServlet, which > takes care of displaying a login freemarker template. > > FatalErrorServlet is trying to access the ActionContext using > ActionContext.getContext(), but it is returning null. > > I have StrutsPrepareFilter, Sitemesh PageFilter, StrutsExecuteFilter > configured in my web.xml, but looks like when the request gets forwarded to > the FatalErrorServlet, it doesn't go through these filters. > > I tried setting the <dispatcher> element for these filters to REQUEST, > FORWARD, IINCLUDE but nothing works. > > I am using Struts 2.1.8.1, app server is weblogic 10.0mp1. > > my web.xml contents > <?xml version="1.0" encoding="ISO-8859-1"?> > > <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee > http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> > > > <filter> > <filter-name>struts-prepare</filter-name> > > <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter</filter-class> > </filter> > > <filter> > <filter-name>sitemesh</filter-name> > > <filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class> > </filter> > > <filter> > <filter-name>struts-execute</filter-name> > > <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter</filter-class> > </filter> > > <filter-mapping> > <filter-name>struts-prepare</filter-name> > <url-pattern>/*</url-pattern> > <dispatcher>REQUEST</dispatcher> > <dispatcher>FORWARD</dispatcher> > <dispatcher>INCLUDE</dispatcher> > </filter-mapping> > <filter-mapping> > <filter-name>sitemesh</filter-name> > <url-pattern>/*</url-pattern> > <dispatcher>REQUEST</dispatcher> > <dispatcher>FORWARD</dispatcher> > <dispatcher>INCLUDE</dispatcher> > </filter-mapping> > <filter-mapping> > <filter-name>struts-execute</filter-name> > <url-pattern>/*</url-pattern> > <dispatcher>REQUEST</dispatcher> > <dispatcher>FORWARD</dispatcher> > <dispatcher>INCLUDE</dispatcher> > </filter-mapping> > > <servlet> > <servlet-name>FatalErrorServlet</servlet-name> > <servlet-class>com.sample.FatalErrorServlet</servlet-class> > </servlet> > > <servlet-mapping> > <servlet-name>FatalErrorServlet</servlet-name> > <url-pattern>*.fatal</url-pattern> > </servlet-mapping> > > <!-- The Welcome File List --> > <welcome-file-list> > <welcome-file>index.jsp</welcome-file> > </welcome-file-list> > > <!-- Error Pages --> > <error-page> > <error-code>500</error-code> > <location>/500.fatal</location> > </error-page> > > <error-page> > <error-code>400</error-code> > <location>/400.fatal</location> > </error-page> > > <error-page> > <error-code>401</error-code> > <location>/401.fatal</location> > </error-page> > > <error-page> > <error-code>403</error-code> > <location>/403.fatal</location> > </error-page> > > <error-page> > <error-code>404</error-code> > <location>/404.fatal</location> > </error-page> > > <!--HOME PAGE--> > <security-constraint> > <web-resource-collection> > <web-resource-name>CommonPages</web-resource-name> > <url-pattern>/index.jsp</url-pattern> > <http-method>GET</http-method> > <http-method>POST</http-method> > </web-resource-collection> > <auth-constraint> > <description>These are the roles who have access</description> > <role-name>role1</role-name> > </auth-constraint> > <user-data-constraint> > <description>This is how the user data must be > transmitted</description> > <transport-guarantee>NONE</transport-guarantee> > </user-data-constraint> > </security-constraint> > <!--HOME PAGE--> > > <security-role> > <role-name>role1</role-name> > </security-role> > </web-app> > > -- > View this message in context: > http://old.nabble.com/ActionContext.getContext%28%29-is-returning-null-tp26712068p26712068.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > -- Wes Wannemacher Head Engineer, WanTii, Inc. Need Training? Struts, Spring, Maven, Tomcat... Ask me for a quote! --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org