This is resolved -- at least this is a formula that works:

Tomcat.addServlet(context, "error_jspx", new error_jspx());
context.addServletMapping("/error.jspx", "error_jspx");

while this doesn't:

Tomcat.addServlet(context, "error_jspx", new
error_jspx()).addMapping("/error.jspx");


On Wed, Oct 10, 2012 at 8:06 PM, Sean Owen <sro...@apache.org> wrote:
> Hello all,
>
> I'm looking for any ideas on the following issue:
> https://issues.apache.org/bugzilla/show_bug.cgi?id=53958
>
> On Tomcat 7.0.32, using embedded Tomcat, I'm seeing a
> NullPointerException when using a custom error page. The page itself
> is fine and loads if accessed directly. Triggering an error like a 404
> results in an NPE during handling of the error page, like:
>
> Oct 10, 2012 7:47:29 PM org.apache.catalina.core.StandardHostValve custom
> SEVERE: Exception Processing ErrorPage[errorCode=404, location=/error.jspx]
> java.lang.NullPointerException
>         at 
> org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:456)
>         at 
> org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:327)
>         at 
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:193)
>         at 
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
>         at 
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
> ...
>
> Mark's tried to reproduce it and can't, even with the exact same test
> case I'm running, copied in the issue there (and copied below).
>
> I'm wondering if anyone sees an error in the configuration, or can
> imagine what the issue may be from the additional details in the
> issue. Or, even has time to try out the test case locally.
>
> Best regards and thanks for any ideas.
>
> Sean
>
>
> import java.io.File;
>
> import org.apache.catalina.Context;
> import org.apache.catalina.Lifecycle;
> import org.apache.catalina.LifecycleEvent;
> import org.apache.catalina.LifecycleListener;
> import org.apache.catalina.Server;
> import org.apache.catalina.connector.Connector;
> import org.apache.catalina.core.JasperListener;
> import org.apache.catalina.deploy.ErrorPage;
> import org.apache.catalina.startup.Tomcat;
>
> public class Test {
>
>   public static void main(String[] args) throws Exception {
>
>     Tomcat tomcat = new Tomcat();
>
>     Connector connector = new
> Connector("org.apache.coyote.http11.Http11NioProtocol");
>     connector.setPort(8080);
>     connector.setSecure(false);
>     connector.setScheme("http");
>
>     File tmpDir = new File(System.getProperty("java.io.tmpdir"));
>
>     tomcat.setBaseDir(tmpDir.getAbsolutePath());
>     tomcat.setConnector(connector);
>     tomcat.getService().addConnector(connector);
>
>     File contextPath = new File(tmpDir, "context");
>     contextPath.mkdirs();
>     Context context = tomcat.addContext("", contextPath.getAbsolutePath());
>     context.setWebappVersion("3.0");
>
>     ErrorPage errorPage = new ErrorPage();
>     errorPage.setErrorCode(404);
>     errorPage.setLocation("/error.jspx");
>     context.addErrorPage(errorPage);
>
>     Server server = tomcat.getServer();
>     LifecycleListener jasperListener = new JasperListener();
>     server.addLifecycleListener(jasperListener);
>     jasperListener.lifecycleEvent(new LifecycleEvent(server,
> Lifecycle.BEFORE_INIT_EVENT, null));
>
>     Tomcat.addServlet(context, "error_jspx", new
> error_jspx()).addMapping("/error.jspx");
>
>     tomcat.start();
>
>     server.await();
>   }
>
> }

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to