开发者

Unhandled exception details in Glassfish

I would like to see the exception details when an unhandled exception thrown in Glassfish (In the web page, not logs).

This error page shows but there's no useful information. Is there an option to view more details of it when an exception thrown? (Like in asp.net if you make开发者_开发问答 debugmode true in web.config you can see the exception details)

HTTP Status 500 -

type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.NullPointerException note The full stack traces of the exception and its root causes are available in the Oracle GlassFish Server 3.1 logs.

Oracle GlassFish Server 3.1

Thanks


In general you should do things like that only in development environments as it publishes internal application details to the outside world (security issue). Nevertheless, you can define a generic exception jsp in your web.xml:

<web-app>
     <error-page>
         <exception-type>java.lang.Throwable</exception-type>
         <location>/WEB-INF/jsp/throwable.jsp</location>
    </error-page>
</web-app>

The throwable.jsp's page element must contain an isErrorPage attribute:

<%@ page isErrorPage="true" %>

This attribute defines the variable exception of type java.lang.Throwable, so you can examine your exception inside throwable.jsp:

<div style="font-family: monospace">
    <pre>
<% exception.printStackTrace(new java.io.PrintWriter(pageContext.getOut())); %>
    </pre>
</div>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜