You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Nicole Erbe <ni...@gmail.com> on 2005/06/01 13:10:08 UTC

Exception handling in sitemap

Hi everyone,

I'm trying to handle the following error with an exception selector in
cocoon sitemap.

I get the following error:

Exception in ServerPagesGenerator.generate()

org.apache.cocoon.ProcessingException: Exception in
ServerPagesGenerator.generate(): java.lang.NullPointerException

cause: java.lang.NullPointerException

I get this exception if a request with an invalid date stamp (i.e.
30.02.2004) is passed through a postgresql database and the returned
value is simply "null".
The easiest way might be to show the user of the related application
an error page (i.e. "invalid input values"). So I don't have to change
every concerning xsp and java file (belonging to a system which get's
test data and delivers xml/pdf etc.). This could be done via exception
handling in the cocoon sitemap as far as I got the functionality
right.

In the sitemap I added the following selector:

<map:selectors default="browser">
     <map:selector name="exception"
src="org.apache.cocoon.selection.ExceptionSelector">
            <exception class="java.lang.NullPointerException"
name="invalidInput" />
            <exception class="org.apache.cocoon.ProcessingException"
name="geterror" />
     </map:selector>
</map:selectors>

pipline:

<map:handle-errors>
                            <map:select type="exception">
                                <map:when test="invalidInput">
                                    <map:generate src="notifying"/>
                                    <map:serialize type="xml"/>
                                </map:when>
                                <map:when test="geterror">
                                    <map:generate src="notifying"/>
                                    <map:serialize type="xml"/>
                                </map:when>
                            </map:select>
                        </map:handle-errors>
-------------------------------------------------------------------------------

I know that I have to give the appropriate information to get the
right error page. But the exception handling itself doesn't work. I
still get the cocoon error page "an error occurred" and  not what's
defined in <map:handle-errors>.

Is there anyone who can help me please. Sorry in case I made an
absolute stupid mistake because I'm a cocoon newbie.

Thanks a lot
Nicole

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Exception handling in sitemap

Posted by lionel crine <cr...@4dconcept.fr>.
On Fri, 10 Jun 2005 19:26:18 +0200, Geert Josten wrote
> A more general remark perhaps:
> 
>  From experience I have learned that Cocoon takes the error-handler 
> of the pipeline in which the HTTP request is handled. When calling 
> internal pipes (cocoon:), these don't use the error-handler of there 
> own pipeline, but the outer one. Quite annoying sometimes. It forced 
> me to do a new HTTP request to make sure that the internal request 
> was handled with its own error-handler, on occasion.
> 
well I'm a little bit lost but,

>From what I've seen, an XSP calling a (cocoon:/) pipeline can not get the
error from it so the handle error can not catch it --> confirming what you
said(if I understand well).


Moreover, in our project we wrote some XSP doing some reqest to ORACLE.
In order to get the exceptions (invalid datasource, ...), I've simply
surrounded the <esql:connection> tag with a (try ;catch (Exception)).


Lionel



> Not sure whether it is relevant, but you never know.
> 
> Cheers,
> Geert
> 
> Lionel Crine wrote:
> 
> > Did you throw the errors in the xsp ?
> > 
> > The handle error can not catch it if you don't throw it.
> > Lionel
> > 
> > Nicole Erbe wrote:
> > 
> >> Hi everyone,
> >>
> >> I'm trying to handle the following error with an exception selector in
> >> cocoon sitemap.
> >>
> >> I get the following error:
> >>
> >> Exception in ServerPagesGenerator.generate()
> >>
> >> org.apache.cocoon.ProcessingException: Exception in
> >> ServerPagesGenerator.generate(): java.lang.NullPointerException
> >>
> >> cause: java.lang.NullPointerException
> >>
> >> I get this exception if a request with an invalid date stamp (i.e.
> >> 30.02.2004) is passed through a postgresql database and the returned
> >> value is simply "null".
> >> The easiest way might be to show the user of the related application
> >> an error page (i.e. "invalid input values"). So I don't have to change
> >> every concerning xsp and java file (belonging to a system which get's
> >> test data and delivers xml/pdf etc.). This could be done via exception
> >> handling in the cocoon sitemap as far as I got the functionality
> >> right.
> >>
> >> In the sitemap I added the following selector:
> >>
> >> <map:selectors default="browser">
> >>     <map:selector name="exception"
> >> src="org.apache.cocoon.selection.ExceptionSelector">
> >>            <exception class="java.lang.NullPointerException"
> >> name="invalidInput" />
> >>            <exception class="org.apache.cocoon.ProcessingException"
> >> name="geterror" />
> >>     </map:selector>
> >> </map:selectors>
> >>
> >> pipline:
> >>
> >> <map:handle-errors>
> >>                            <map:select type="exception">
> >>                                <map:when test="invalidInput">
> >>                                    <map:generate src="notifying"/>
> >>                                    <map:serialize type="xml"/>
> >>                                </map:when>
> >>                                <map:when test="geterror">
> >>                                    <map:generate src="notifying"/>
> >>                                    <map:serialize type="xml"/>
> >>                                </map:when>
> >>                            </map:select>
> >>                        </map:handle-errors>
> >>
------------------------------------------------------------------------------- 
> >>
> >>
> >> I know that I have to give the appropriate information to get the
> >> right error page. But the exception handling itself doesn't work. I
> >> still get the cocoon error page "an error occurred" and  not what's
> >> defined in <map:handle-errors>.
> >>
> >> Is there anyone who can help me please. Sorry in case I made an
> >> absolute stupid mistake because I'm a cocoon newbie.
> >>
> >> Thanks a lot
> >> Nicole
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> >> For additional commands, e-mail: users-help@cocoon.apache.org
> >>
> >>  
> >>
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail: users-help@cocoon.apache.org
> 
> -- 
> =====================================
> NB: het Daidalos kantoor is sinds 22 april
> jl. gevestigd op een nieuw adres:
> 
> Daidalos BV
> Hoekeindsehof 1 - 4
> 2665 JZ Bleiswijk
> tel: +31 (0)10 850 12 00
> fax: +31 (0)10 850 11 99
> 
> Bovenstaand adres is tevens het postadres.
> ======================
> Geert.Josten@Daidalos.nl
> IT-consultant at Daidalos BV
> 
> http://www.daidalos.nl/
> 
> GPG: 1024D/12DEBB50
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Exception handling in sitemap

Posted by Geert Josten <Ge...@daidalos.nl>.
A more general remark perhaps:

 From experience I have learned that Cocoon takes the error-handler of the pipeline in which the 
HTTP request is handled. When calling internal pipes (cocoon:), these don't use the error-handler of 
there own pipeline, but the outer one. Quite annoying sometimes. It forced me to do a new HTTP 
request to make sure that the internal request was handled with its own error-handler, on occasion.

Not sure whether it is relevant, but you never know.

Cheers,
Geert

Lionel Crine wrote:

> Did you throw the errors in the xsp ?
> 
> The handle error can not catch it if you don't throw it.
> Lionel
> 
> Nicole Erbe wrote:
> 
>> Hi everyone,
>>
>> I'm trying to handle the following error with an exception selector in
>> cocoon sitemap.
>>
>> I get the following error:
>>
>> Exception in ServerPagesGenerator.generate()
>>
>> org.apache.cocoon.ProcessingException: Exception in
>> ServerPagesGenerator.generate(): java.lang.NullPointerException
>>
>> cause: java.lang.NullPointerException
>>
>> I get this exception if a request with an invalid date stamp (i.e.
>> 30.02.2004) is passed through a postgresql database and the returned
>> value is simply "null".
>> The easiest way might be to show the user of the related application
>> an error page (i.e. "invalid input values"). So I don't have to change
>> every concerning xsp and java file (belonging to a system which get's
>> test data and delivers xml/pdf etc.). This could be done via exception
>> handling in the cocoon sitemap as far as I got the functionality
>> right.
>>
>> In the sitemap I added the following selector:
>>
>> <map:selectors default="browser">
>>     <map:selector name="exception"
>> src="org.apache.cocoon.selection.ExceptionSelector">
>>            <exception class="java.lang.NullPointerException"
>> name="invalidInput" />
>>            <exception class="org.apache.cocoon.ProcessingException"
>> name="geterror" />
>>     </map:selector>
>> </map:selectors>
>>
>> pipline:
>>
>> <map:handle-errors>
>>                            <map:select type="exception">
>>                                <map:when test="invalidInput">
>>                                    <map:generate src="notifying"/>
>>                                    <map:serialize type="xml"/>
>>                                </map:when>
>>                                <map:when test="geterror">
>>                                    <map:generate src="notifying"/>
>>                                    <map:serialize type="xml"/>
>>                                </map:when>
>>                            </map:select>
>>                        </map:handle-errors>
>> ------------------------------------------------------------------------------- 
>>
>>
>> I know that I have to give the appropriate information to get the
>> right error page. But the exception handling itself doesn't work. I
>> still get the cocoon error page "an error occurred" and  not what's
>> defined in <map:handle-errors>.
>>
>> Is there anyone who can help me please. Sorry in case I made an
>> absolute stupid mistake because I'm a cocoon newbie.
>>
>> Thanks a lot
>> Nicole
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>  
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org

-- 
=====================================
NB: het Daidalos kantoor is sinds 22 april
jl. gevestigd op een nieuw adres:

Daidalos BV
Hoekeindsehof 1 - 4
2665 JZ Bleiswijk
tel: +31 (0)10 850 12 00
fax: +31 (0)10 850 11 99

Bovenstaand adres is tevens het postadres.
======================
Geert.Josten@Daidalos.nl
IT-consultant at Daidalos BV

http://www.daidalos.nl/

GPG: 1024D/12DEBB50

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Exception handling in sitemap

Posted by Lionel Crine <cr...@4dconcept.fr>.
Did you throw the errors in the xsp ?

The handle error can not catch it if you don't throw it.
Lionel

Nicole Erbe wrote:

>Hi everyone,
>
>I'm trying to handle the following error with an exception selector in
>cocoon sitemap.
>
>I get the following error:
>
>Exception in ServerPagesGenerator.generate()
>
>org.apache.cocoon.ProcessingException: Exception in
>ServerPagesGenerator.generate(): java.lang.NullPointerException
>
>cause: java.lang.NullPointerException
>
>I get this exception if a request with an invalid date stamp (i.e.
>30.02.2004) is passed through a postgresql database and the returned
>value is simply "null".
>The easiest way might be to show the user of the related application
>an error page (i.e. "invalid input values"). So I don't have to change
>every concerning xsp and java file (belonging to a system which get's
>test data and delivers xml/pdf etc.). This could be done via exception
>handling in the cocoon sitemap as far as I got the functionality
>right.
>
>In the sitemap I added the following selector:
>
><map:selectors default="browser">
>     <map:selector name="exception"
>src="org.apache.cocoon.selection.ExceptionSelector">
>            <exception class="java.lang.NullPointerException"
>name="invalidInput" />
>            <exception class="org.apache.cocoon.ProcessingException"
>name="geterror" />
>     </map:selector>
></map:selectors>
>
>pipline:
>
><map:handle-errors>
>                            <map:select type="exception">
>                                <map:when test="invalidInput">
>                                    <map:generate src="notifying"/>
>                                    <map:serialize type="xml"/>
>                                </map:when>
>                                <map:when test="geterror">
>                                    <map:generate src="notifying"/>
>                                    <map:serialize type="xml"/>
>                                </map:when>
>                            </map:select>
>                        </map:handle-errors>
>-------------------------------------------------------------------------------
>
>I know that I have to give the appropriate information to get the
>right error page. But the exception handling itself doesn't work. I
>still get the cocoon error page "an error occurred" and  not what's
>defined in <map:handle-errors>.
>
>Is there anyone who can help me please. Sorry in case I made an
>absolute stupid mistake because I'm a cocoon newbie.
>
>Thanks a lot
>Nicole
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>  
>

-- 
Lionel CRINE
Ingénieur Systèmes documentaires
Société : 4DConcept
22 rue Etienne de Jouy 78353 JOUY EN JOSAS
Tel : 01.34.58.70.70 Fax : 01.39.46.06.90