You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Dan Adams <da...@ifactory.com> on 2005/12/20 17:53:32 UTC

custom exception page only in production

I found lots of great info on how to create a custom exception page, but
I'm wondering if anyone has a good way to make the custom error page
only appear in a production deploy and not in a testing deploy.

-- 
Dan Adams
Software Engineer
Interactive Factory


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: custom exception page only in production

Posted by Daniel M Garland <da...@titanemail.com>.
I just used my build script to copy a different .application file with 
the Custom Exception settings in. Simple solution.

Dan Adams wrote:
> I found lots of great info on how to create a custom exception page, but
> I'm wondering if anyone has a good way to make the custom error page
> only appear in a production deploy and not in a testing deploy.
> 

-- 
Dan Garland
------------------------
daniel.garland@titanemail.com
icq: 120963437
aim: dmgarland1767


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: custom exception page only in production

Posted by Pedro Abelleira Seco <pe...@usc.es>.
Thanks for sharing this. I hadn't thought about it. Good.

Pedro

El Mar, 20-12-2005 a las 14:07 -0500, Bryan Lewis escribió:
> Pedro Abelleira Seco wrote:
> 
> >That sounds well, but where do you store your properties file? I mean,
> >how do you switch from development properties file to production file?
> >
> >Pedro
> >  
> >
> I load it from the classpath with getResourceAsStream().  Each server
> has its own version of the properties file at tomcat/shared/classes. 
> Here's the guts of the code... I called it UserDefaults.java in memory
> of our old WebObjects apps. I don't doubt that a system property is the
> more java-proper way to do it.
> 
> 
>     private static final String userDefaultsFilename = "user.defaults";
>     private static Properties userDefaults;
> 
>     static {
>         loadUserDefaults();
>     }
> 
>     public static void loadUserDefaults()
>     {
>         userDefaults = new Properties();
>         try {
>             ClassLoader loader =
> Thread.currentThread().getContextClassLoader();
>             InputStream input =
> loader.getResourceAsStream(userDefaultsFilename);
> 
>             userDefaults.load(input);
>         }
>         catch (NullPointerException npe) {
>             System.out.println("No UserDefaults file found.);
>         }
>         catch (Exception ex) {
>             throw new ExceptionAdapter(ex);
>         }
>     }
> 
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: custom exception page only in production

Posted by Bryan Lewis <br...@maine.rr.com>.
Pedro Abelleira Seco wrote:

>That sounds well, but where do you store your properties file? I mean,
>how do you switch from development properties file to production file?
>
>Pedro
>  
>
I load it from the classpath with getResourceAsStream().  Each server
has its own version of the properties file at tomcat/shared/classes. 
Here's the guts of the code... I called it UserDefaults.java in memory
of our old WebObjects apps. I don't doubt that a system property is the
more java-proper way to do it.


    private static final String userDefaultsFilename = "user.defaults";
    private static Properties userDefaults;

    static {
        loadUserDefaults();
    }

    public static void loadUserDefaults()
    {
        userDefaults = new Properties();
        try {
            ClassLoader loader =
Thread.currentThread().getContextClassLoader();
            InputStream input =
loader.getResourceAsStream(userDefaultsFilename);

            userDefaults.load(input);
        }
        catch (NullPointerException npe) {
            System.out.println("No UserDefaults file found.);
        }
        catch (Exception ex) {
            throw new ExceptionAdapter(ex);
        }
    }






---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: custom exception page only in production

Posted by Pedro Abelleira Seco <pe...@usc.es>.
That sounds well, but where do you store your properties file? I mean,
how do you switch from development properties file to production file?

Pedro


El Mar, 20-12-2005 a las 12:11 -0500, Bryan Lewis escribió:
> Our custom Engine class overrode activateExceptionPage().  It checked a
> configuration property (read from a properties file on startup) to tell
> whether it was running on a production server.  If so, it presented a
> user-friendly error page and emailed the exception to us.  If not, it
> logged the exception and called super.activateExceptionPage() to present
> Tapestry's detailed exception page.
> 
> 
> Dan Adams wrote:
> 
> >I found lots of great info on how to create a custom exception page, but
> >I'm wondering if anyone has a good way to make the custom error page
> >only appear in a production deploy and not in a testing deploy.
> >
> >  
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: custom exception page only in production

Posted by Bryan Lewis <br...@maine.rr.com>.
Our custom Engine class overrode activateExceptionPage().  It checked a
configuration property (read from a properties file on startup) to tell
whether it was running on a production server.  If so, it presented a
user-friendly error page and emailed the exception to us.  If not, it
logged the exception and called super.activateExceptionPage() to present
Tapestry's detailed exception page.


Dan Adams wrote:

>I found lots of great info on how to create a custom exception page, but
>I'm wondering if anyone has a good way to make the custom error page
>only appear in a production deploy and not in a testing deploy.
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: custom exception page only in production

Posted by Pedro Abelleira Seco <pe...@usc.es>.
What we have is to put this code in our exception page

<span jwcid="@Conditional" condition="ognl:inDevel">
  <span jwcid="@ExceptionDisplay" exceptions="ognl:new
org.apache.tapestry.util.exception.ExceptionAnalyzer().analyze(exception)"/>
</span>

And we put this method in the java file


    public boolean getInDevel() {
        return (Boolean.getBoolean("sicus_devel"));
    }

As we use Tomcat (the included one in Netbeans) each developer sets the
enviroment variable

CATALINA_OPTS="-Dsicus_devel=true"

in his computer and is able to see the error report. In development we
don't have that variable so it doesn't appear.

Pedro

El Mar, 20-12-2005 a las 12:37 -0500, Dan Adams escribió:
> yeah, i know that hivemind has conditional contributions and thought
> about using that. the only thing I'm not sure of is how/where i would
> set the system properties.
> 
> On Tue, 2005-12-20 at 17:57 +0100, Pedro Abelleira Seco wrote:
> > What we have done is to conditionally include the exception trace and
> > tapestry error info on it, so developers can see it and final users only
> > a "Internal error" message. I don't know if that is what you are looking
> > for.
> > 
> > We used a JVM system property to do that.
> > 
> > Pedro
> > 
> > El Mar, 20-12-2005 a las 11:53 -0500, Dan Adams escribió:
> > > I found lots of great info on how to create a custom exception page, but
> > > I'm wondering if anyone has a good way to make the custom error page
> > > only appear in a production deploy and not in a testing deploy.
> > > 
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> > 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: custom exception page only in production

Posted by Dan Adams <da...@ifactory.com>.
yeah, i know that hivemind has conditional contributions and thought
about using that. the only thing I'm not sure of is how/where i would
set the system properties.

On Tue, 2005-12-20 at 17:57 +0100, Pedro Abelleira Seco wrote:
> What we have done is to conditionally include the exception trace and
> tapestry error info on it, so developers can see it and final users only
> a "Internal error" message. I don't know if that is what you are looking
> for.
> 
> We used a JVM system property to do that.
> 
> Pedro
> 
> El Mar, 20-12-2005 a las 11:53 -0500, Dan Adams escribió:
> > I found lots of great info on how to create a custom exception page, but
> > I'm wondering if anyone has a good way to make the custom error page
> > only appear in a production deploy and not in a testing deploy.
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
-- 
Dan Adams
Software Engineer
Interactive Factory


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: custom exception page only in production

Posted by Pedro Abelleira Seco <pe...@usc.es>.
What we have done is to conditionally include the exception trace and
tapestry error info on it, so developers can see it and final users only
a "Internal error" message. I don't know if that is what you are looking
for.

We used a JVM system property to do that.

Pedro

El Mar, 20-12-2005 a las 11:53 -0500, Dan Adams escribió:
> I found lots of great info on how to create a custom exception page, but
> I'm wondering if anyone has a good way to make the custom error page
> only appear in a production deploy and not in a testing deploy.
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org