users@glassfish.java.net

Problem with redirection to error page. Dojo Framework + Glassfish +

From: <forums_at_java.net>
Date: Thu, 22 Sep 2011 08:19:20 -0500 (CDT)

 Hi,

Im using Glassfish Server 3.1, Netbeans 7.0.1, Dojo Framework as a client and
Jersey RESTFul Webservice with Json protocoll to comunicate with.

My Problem is, glassfish wont redirect Exceptions, i get to my error.jsp page
that i configure in web.xml file:

<code>

<?xml version="1.0" encoding="UTF-8"?>

<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

    <display-name>mp</display-name>

    <session-config>

        <session-timeout>

            30

        </session-timeout>

    </session-config>

    <welcome-file-list>

        <welcome-file>index.html</welcome-file>

        <welcome-file>index.htm</welcome-file>

        <welcome-file>index.jsp</welcome-file>

        <welcome-file>default.html</welcome-file>

        <welcome-file>default.htm</welcome-file>

        <welcome-file>default.jsp</welcome-file>

    </welcome-file-list>

    <servlet-mapping>

        <servlet-name>REST</servlet-name>

        <url-pattern>/resources/*</url-pattern>

    </servlet-mapping>

    <servlet>

        <servlet-name>REST</servlet-name>

       
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>

        <init-param>

           
<param-name>com.sun.jersey.api.wadl.config.WadlGeneratorConfig</param-name>

           
<param-value>de.fhg.iml.vlog.smartcm.configuration.extendedwadl.SmartCMWadlGeneratorConfig</param-value>

        </init-param>

        <init-param>

           
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>

            <param-value>true</param-value>

        </init-param>

        <init-param>

           
<param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>

           
<param-value>com.sun.jersey.server.linking.LinkFilter</param-value>

        </init-param>

        <init-param>

           
<param-name>com.sun.jersey.config.feature.DisableWADL</param-name>

            <param-value>true</param-value>

        </init-param>

        <load-on-startup>1</load-on-startup>

    </servlet>

    <error-page>

        <exception-type>java.lang.Throwable</exception-type>

        <location>/error.jsp</location>

    </error-page>

    <security-constraint>

        <display-name>Security Constraint</display-name>

        <web-resource-collection>

            <web-resource-name>protected</web-resource-name>

            <description/>

            <url-pattern>/*</url-pattern>

        </web-resource-collection>

        <auth-constraint>

            <description/>

            <role-name>Administrators</role-name>

            <role-name>Users</role-name>

        </auth-constraint>

    </security-constraint>

    <security-constraint>

        <display-name>AllAccess</display-name>

        <web-resource-collection>

            <web-resource-name>unprotected</web-resource-name>

            <description>for images</description>

            <url-pattern>/image/*</url-pattern>

            <http-method>GET</http-method>

        </web-resource-collection>

    </security-constraint>

    <login-config>

        <auth-method>FORM</auth-method>

        <realm-name>userauth</realm-name>

        <form-login-config>

            <form-login-page>/login.jsp</form-login-page>

            <form-error-page>/login.jsp?errors=true</form-error-page>

        </form-login-config>

    </login-config>

    <security-role>

        <description/>

        <role-name>Administrators</role-name>

    </security-role>

    <security-role>

        <description/>

        <role-name>Users</role-name>

    </security-role>

</web-app>

</code>

 

My error.jsp file is:

<code>

<%@ page isErrorPage="true"%>

<%@ page contentType="text/html;charset=utf-8" language="java" %>

Statuscode: <%= pageContext.getErrorData().getStatusCode()%>

<% System.out.println("");%>

Request-URI: <%= pageContext.getErrorData().getRequestURI()%>

<% System.out.println("");%>

Servletname: <%= pageContext.getErrorData().getServletName()%>

<% System.out.println("");%>

Exception: <%= pageContext.getException().getStackTrace()%>

</code>

 

When i got an Exception in my JavaBean (i made a test with
NullpointerException: eg. String d=null; sout(d.toString()); ), it will not
redirect to error.jsp, but if i type this page in the addressbar explicy, i
become a result. 

So why glassfish dont recognize (or dont catch) it? How can i configure this?

 

Thanks for help.


--
[Message sent by forum member 'maddos']
View Post: http://forums.java.net/node/845640