https://bz.apache.org/bugzilla/show_bug.cgi?id=58581
Bug ID: 58581
Summary: StandardHostValve#custom throws NPE if custom error
page is incorrectly configured
Product: Tomcat 9
Version: unspecified
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P2
Component: Catalina
Assignee: [email protected]
Reporter: [email protected]
Created attachment 33255
--> https://bz.apache.org/bugzilla/attachment.cgi?id=33255&action=edit
proposed fix to avoid NPE
Minimal files to reproduce this issue:
1) create a directory named test and deploy it under webapps
test
├── WEB-INF
│ └── web.xml
├── error.html
└── test.html
the web.xml is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0">
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/test.html</url-pattern>
</servlet-mapping>
<error-page>
<error-code>404</error-code>
<location>/error.html</location>
</error-page>
</web-app>
2 ) start tomcat and visit http://localhost:8080/test/abc.html
The exception is thrown as follows:
04-Nov-2015 22:24:04.984 SEVERE [http-nio-8080-exec-1]
org.apache.catalina.core.StandardHostValve.custom Exception Processing
ErrorPage[errorCode=404, location=/error.html]
java.lang.NullPointerException
at
org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:391)
at
org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:257)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:361)
at
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1057)
at
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:75)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:737)
at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1531)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
The exception is not user-friendly, and somehow misleading. From the stack
trace, user is likely to consider it as a tomcat bug.
The solution might be adding url-pattern /error.html to the default servlet, or
just change the url-pattern to match all the html resources.
My suggestion is to avoid such NPE and tell user what to do.
I have attached a proposed fix against trunk.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]