Handling submission errors

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Handling submission errors

Jeremy Nix
I'm trying to figure out why I am unable to send back a error response
from a submission URL.  I have the following submission tag:

<xf:submission id="chmc_submit_model" mode="synchronous"
replace="instance" method="post"
         validate="true" relevant="false" ref="instance('data')"
resource="/test">
     <xf:action ev:observer="chmc_submit_model"
ev:event="xforms-submit-done">
         <xf:setvalue ref="instance('varData')/SubmitStatus"
value="'Save Successful...'" />
     </xf:action>
     <xf:action ev:observer="chmc_submit_model"
ev:event="xforms-submit-error">
         <xf:setvalue ref="instance('varData')/SubmitError"
value="event('response-body')"/>
         <xf:setvalue ref="instance('varData')/SubmitStatus"
value="'Error during save...'" />
         <xf:message ev:event="xforms-submit-error" level="modal">
             A submission error occurred:
             <xf:output select="xxf:instance('varData')/SubmitError"
mediatype="text/html"/>
         </xf:message>
     </xf:action>
</xf:submission>

The servlet is sending back an text/html response.  I'm attaching the
log file that I receive.  It looks like Orbeon has issues handling the
response.  The xforms-submit-error event fires, and the above
"submission error occurred" message is displayed, but the response body
is empty.  I'm assuming this is do to the stack trace from the log file.

Is this something that I am doing wrong in my error handling, or is this
a known bug in Orbeon?  I'm currently using Orbeon 4.0M19ish (building
from trunk).

Thanks for any help you can give,

--
_____________________________________________
Jeremy Nix
Senior Application Developer
Biomedical Informatics
Cincinnati Children's Hospital Medical Center
513-803-2764 / [hidden email]



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws

orbeon.log (85K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Handling submission errors

Hank Ratzesberger-3
Hi,

Well, It has been I while since I worked with this, so take my ideas
with a grain of salt...

Is /test a url that you handle in your page flow controller?

Indeed, Orbeon won't handle an html content-type response, and that
includes when your own service isn't caught and flows through the page
flow controller and becomes  a 404 error.

The url-generator will handle html and attempt to clean it up with tidy.

I used to do things like start with a service that returns any XML
with GET, so I could verify that it was there. then build it out.

You can configure logging to check what you are submitting and you can
use debug attributes on the pipeline as well.

http://wiki.orbeon.com/forms/doc/developer-guide/xforms-logging

Best,
Hank

On Thu, Feb 28, 2013 at 6:16 AM, Nix, Jeremy <[hidden email]> wrote:

> I'm trying to figure out why I am unable to send back a error response
> from a submission URL.  I have the following submission tag:
>
> <xf:submission id="chmc_submit_model" mode="synchronous"
> replace="instance" method="post"
>          validate="true" relevant="false" ref="instance('data')"
> resource="/test">
>      <xf:action ev:observer="chmc_submit_model"
> ev:event="xforms-submit-done">
>          <xf:setvalue ref="instance('varData')/SubmitStatus"
> value="'Save Successful...'" />
>      </xf:action>
>      <xf:action ev:observer="chmc_submit_model"
> ev:event="xforms-submit-error">
>          <xf:setvalue ref="instance('varData')/SubmitError"
> value="event('response-body')"/>
>          <xf:setvalue ref="instance('varData')/SubmitStatus"
> value="'Error during save...'" />
>          <xf:message ev:event="xforms-submit-error" level="modal">
>              A submission error occurred:
>              <xf:output select="xxf:instance('varData')/SubmitError"
> mediatype="text/html"/>
>          </xf:message>
>      </xf:action>
> </xf:submission>
>
> The servlet is sending back an text/html response.  I'm attaching the
> log file that I receive.  It looks like Orbeon has issues handling the
> response.  The xforms-submit-error event fires, and the above
> "submission error occurred" message is displayed, but the response body
> is empty.  I'm assuming this is do to the stack trace from the log file.
>
> Is this something that I am doing wrong in my error handling, or is this
> a known bug in Orbeon?  I'm currently using Orbeon 4.0M19ish (building
> from trunk).
>
> Thanks for any help you can give,
>
> --
> _____________________________________________
> Jeremy Nix
> Senior Application Developer
> Biomedical Informatics
> Cincinnati Children's Hospital Medical Center
> 513-803-2764 / [hidden email]
>
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>


--
Hank Ratzesberger
XMLWerks.com


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Handling submission errors

Jeremy Nix
Hank,

Thanks for the help.  I'm still not able to get it to work, but you did
give me a few more ideas of things to try.  I may be going about error
handling incorrectly.  My goal is to send back a response from the
service that causes a xforms-submit-error event to fire.  This is so
that I can handle the error response without replacing my instance
data.  My /test endpoint is a servlet. We're using the separate install,
so my java application communicates with orbeon via the
orbeon-xforms-filter.  I modified my servlet to pass back text/xml, just
for test purposes, and I changed my submission to look like the following:

<xf:submission id="chmc_submit_model" mode="synchronous"
replace="instance" method="post"
     validate="true" relevant="false"
     ref="instance('data')" resource="/test">
   <xf:action ev:observer="chmc_submit_model" ev:event="xforms-submit-done">
     <xf:message level="modal">
       Response:
       <xf:output value="event('response-body')" mediatype="text/html"/>
     </xf:message>
   </xf:action>
   <xf:action ev:observer="chmc_submit_model"
ev:event="xforms-submit-error">
     <xf:message ev:event="xforms-submit-error" level="modal">
       A submission error occurred:
       <xf:output value="event('response-body')" mediatype="text/html"/>
     </xf:message>
   </xf:action>
</xf:submission>

After which, I tested out, and the code hits the xforms-submit-done
message block.  I still do not get a response however.  In the orbeon
logs, I see the following:

2013-03-01 09:16:47,117 [ERROR] 'http-bio-8080-exec-1' XFormsServer:225
- xforms-submit-error - response {status code: "200"}
2013-03-01 09:16:47,117 [ERROR] 'http-bio-8080-exec-1' XFormsServer:225
- xforms-submit-error - response headers {content-type:
"text/xml;charset=ISO-8859-1", cache-control: "no-cache, no-store,
must-revalidate, max-age=0", expires: "Thu, 01 Jan 1970 00:00:00 GMT",
transfer-encoding: "chunked", server: "Apache-Coyote/1.1", date: "Fri,
01 Mar 2013 14:16:47 GMT", x-ua-compatible: "IE=9,IE=8", vary:
"Accept-Encoding", pragma: "no-cache"}
2013-03-01 09:16:47,140 [WARN] 'http-bio-8080-exec-1' XFormsServer:225 -
xforms-submit-error - error while reading response body. {throwable: "

I'm not sure why I'm getting this ERROR.  The Orbeon stack trace is the
same as before.  I capture a tshark trace of my response just to see if
there was something weird going on, and I'm drawing a blank.  I'm
attaching the tshark log that I captured.

_____________________________________________
Jeremy Nix
Senior Application Developer
Biomedical Informatics
Cincinnati Children's Hospital Medical Center
513-803-2764 / [hidden email]

On 02/28/2013 04:33 PM, Hank Ratzesberger wrote:

> Hi,
>
> Well, It has been I while since I worked with this, so take my ideas
> with a grain of salt...
>
> Is /test a url that you handle in your page flow controller?
>
> Indeed, Orbeon won't handle an html content-type response, and that
> includes when your own service isn't caught and flows through the page
> flow controller and becomes  a 404 error.
>
> The url-generator will handle html and attempt to clean it up with tidy.
>
> I used to do things like start with a service that returns any XML
> with GET, so I could verify that it was there. then build it out.
>
> You can configure logging to check what you are submitting and you can
> use debug attributes on the pipeline as well.
>
> http://wiki.orbeon.com/forms/doc/developer-guide/xforms-logging
>
> Best,
> Hank
>
> On Thu, Feb 28, 2013 at 6:16 AM, Nix, Jeremy <[hidden email]> wrote:
>> I'm trying to figure out why I am unable to send back a error response
>> from a submission URL.  I have the following submission tag:
>>
>> <xf:submission id="chmc_submit_model" mode="synchronous"
>> replace="instance" method="post"
>>           validate="true" relevant="false" ref="instance('data')"
>> resource="/test">
>>       <xf:action ev:observer="chmc_submit_model"
>> ev:event="xforms-submit-done">
>>           <xf:setvalue ref="instance('varData')/SubmitStatus"
>> value="'Save Successful...'" />
>>       </xf:action>
>>       <xf:action ev:observer="chmc_submit_model"
>> ev:event="xforms-submit-error">
>>           <xf:setvalue ref="instance('varData')/SubmitError"
>> value="event('response-body')"/>
>>           <xf:setvalue ref="instance('varData')/SubmitStatus"
>> value="'Error during save...'" />
>>           <xf:message ev:event="xforms-submit-error" level="modal">
>>               A submission error occurred:
>>               <xf:output select="xxf:instance('varData')/SubmitError"
>> mediatype="text/html"/>
>>           </xf:message>
>>       </xf:action>
>> </xf:submission>
>>
>> The servlet is sending back an text/html response.  I'm attaching the
>> log file that I receive.  It looks like Orbeon has issues handling the
>> response.  The xforms-submit-error event fires, and the above
>> "submission error occurred" message is displayed, but the response body
>> is empty.  I'm assuming this is do to the stack trace from the log file.
>>
>> Is this something that I am doing wrong in my error handling, or is this
>> a known bug in Orbeon?  I'm currently using Orbeon 4.0M19ish (building
>> from trunk).
>>
>> Thanks for any help you can give,
>>
>> --
>> _____________________________________________
>> Jeremy Nix
>> Senior Application Developer
>> Biomedical Informatics
>> Cincinnati Children's Hospital Medical Center
>> 513-803-2764 / [hidden email]
>>
>>
>>
>> --
>> You receive this message as a subscriber of the [hidden email] mailing list.
>> To unsubscribe: mailto:[hidden email]
>> For general help: mailto:[hidden email]?subject=help
>> OW2 mailing lists service home page: http://www.ow2.org/wws
>>
>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws

tshark.log (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Handling submission errors

Jeremy Nix
Looks like I missed another thread on this issue "xforms-submit-error -
error while reading response body: Stream closed".  I'm tried using
4.0M19 and 4.0RC1 (latest from GIT).  Bartek reported the issue with
4.0M19.  Maybe there is just a bug in the stream processing.

Based on the stacktrace, it would appear that something is going awry
somewhere in here:

private static FileItem prepareFileItemFromInputStream(InputStream
inputStream, int scope) {
     // Get FileItem
     final FileItem fileItem = prepareFileItem(scope);
     // Write to file
     OutputStream os = null;
     try {
         os = fileItem.getOutputStream();
         copyStream(inputStream, os);
     } catch (IOException e) {
         throw new OXFException(e); // this is where exception is being
re-thrown due to passed in inputStream being closed already.
     }

After tracing the processing flow, I think I see what's happening.  In
XFormsModelSubmission.java, normal result processing occurs on line 475:

submitDoneOrErrorRunnable = handleSubmissionResult(p, p2,
submissionResult, true);

Then, at line #500, post-submission code occurs (which handles the
xforms-submit-done and xforms-submit-error events):

submitDoneOrErrorRunnable.run();

The issue lies in a connectionresult inputstream being closed within the
handleSubmissionResult method call.

I'm not going to pretend to understand all of the processing model
that's going on here, but I thought I'd contribute to at least a basic
understanding of what's happening in the code. Orbeon Team, hope this helps.

_____________________________________________
Jeremy Nix
Senior Application Developer
Biomedical Informatics
Cincinnati Children's Hospital Medical Center
513-803-2764 / [hidden email]

On 03/01/2013 09:30 AM, Nix, Jeremy wrote:

> Hank,
>
> Thanks for the help.  I'm still not able to get it to work, but you did
> give me a few more ideas of things to try.  I may be going about error
> handling incorrectly.  My goal is to send back a response from the
> service that causes a xforms-submit-error event to fire.  This is so
> that I can handle the error response without replacing my instance
> data.  My /test endpoint is a servlet. We're using the separate install,
> so my java application communicates with orbeon via the
> orbeon-xforms-filter.  I modified my servlet to pass back text/xml, just
> for test purposes, and I changed my submission to look like the following:
>
> <xf:submission id="chmc_submit_model" mode="synchronous"
> replace="instance" method="post"
>       validate="true" relevant="false"
>       ref="instance('data')" resource="/test">
>     <xf:action ev:observer="chmc_submit_model" ev:event="xforms-submit-done">
>       <xf:message level="modal">
>         Response:
>         <xf:output value="event('response-body')" mediatype="text/html"/>
>       </xf:message>
>     </xf:action>
>     <xf:action ev:observer="chmc_submit_model"
> ev:event="xforms-submit-error">
>       <xf:message ev:event="xforms-submit-error" level="modal">
>         A submission error occurred:
>         <xf:output value="event('response-body')" mediatype="text/html"/>
>       </xf:message>
>     </xf:action>
> </xf:submission>
>
> After which, I tested out, and the code hits the xforms-submit-done
> message block.  I still do not get a response however.  In the orbeon
> logs, I see the following:
>
> 2013-03-01 09:16:47,117 [ERROR] 'http-bio-8080-exec-1' XFormsServer:225
> - xforms-submit-error - response {status code: "200"}
> 2013-03-01 09:16:47,117 [ERROR] 'http-bio-8080-exec-1' XFormsServer:225
> - xforms-submit-error - response headers {content-type:
> "text/xml;charset=ISO-8859-1", cache-control: "no-cache, no-store,
> must-revalidate, max-age=0", expires: "Thu, 01 Jan 1970 00:00:00 GMT",
> transfer-encoding: "chunked", server: "Apache-Coyote/1.1", date: "Fri,
> 01 Mar 2013 14:16:47 GMT", x-ua-compatible: "IE=9,IE=8", vary:
> "Accept-Encoding", pragma: "no-cache"}
> 2013-03-01 09:16:47,140 [WARN] 'http-bio-8080-exec-1' XFormsServer:225 -
> xforms-submit-error - error while reading response body. {throwable: "
>
> I'm not sure why I'm getting this ERROR.  The Orbeon stack trace is the
> same as before.  I capture a tshark trace of my response just to see if
> there was something weird going on, and I'm drawing a blank.  I'm
> attaching the tshark log that I captured.
>
> _____________________________________________
> Jeremy Nix
> Senior Application Developer
> Biomedical Informatics
> Cincinnati Children's Hospital Medical Center
> 513-803-2764 / [hidden email]
>
> On 02/28/2013 04:33 PM, Hank Ratzesberger wrote:
>> Hi,
>>
>> Well, It has been I while since I worked with this, so take my ideas
>> with a grain of salt...
>>
>> Is /test a url that you handle in your page flow controller?
>>
>> Indeed, Orbeon won't handle an html content-type response, and that
>> includes when your own service isn't caught and flows through the page
>> flow controller and becomes  a 404 error.
>>
>> The url-generator will handle html and attempt to clean it up with tidy.
>>
>> I used to do things like start with a service that returns any XML
>> with GET, so I could verify that it was there. then build it out.
>>
>> You can configure logging to check what you are submitting and you can
>> use debug attributes on the pipeline as well.
>>
>> http://wiki.orbeon.com/forms/doc/developer-guide/xforms-logging
>>
>> Best,
>> Hank
>>
>> On Thu, Feb 28, 2013 at 6:16 AM, Nix, Jeremy <[hidden email]> wrote:
>>> I'm trying to figure out why I am unable to send back a error response
>>> from a submission URL.  I have the following submission tag:
>>>
>>> <xf:submission id="chmc_submit_model" mode="synchronous"
>>> replace="instance" method="post"
>>>            validate="true" relevant="false" ref="instance('data')"
>>> resource="/test">
>>>        <xf:action ev:observer="chmc_submit_model"
>>> ev:event="xforms-submit-done">
>>>            <xf:setvalue ref="instance('varData')/SubmitStatus"
>>> value="'Save Successful...'" />
>>>        </xf:action>
>>>        <xf:action ev:observer="chmc_submit_model"
>>> ev:event="xforms-submit-error">
>>>            <xf:setvalue ref="instance('varData')/SubmitError"
>>> value="event('response-body')"/>
>>>            <xf:setvalue ref="instance('varData')/SubmitStatus"
>>> value="'Error during save...'" />
>>>            <xf:message ev:event="xforms-submit-error" level="modal">
>>>                A submission error occurred:
>>>                <xf:output select="xxf:instance('varData')/SubmitError"
>>> mediatype="text/html"/>
>>>            </xf:message>
>>>        </xf:action>
>>> </xf:submission>
>>>
>>> The servlet is sending back an text/html response.  I'm attaching the
>>> log file that I receive.  It looks like Orbeon has issues handling the
>>> response.  The xforms-submit-error event fires, and the above
>>> "submission error occurred" message is displayed, but the response body
>>> is empty.  I'm assuming this is do to the stack trace from the log file.
>>>
>>> Is this something that I am doing wrong in my error handling, or is this
>>> a known bug in Orbeon?  I'm currently using Orbeon 4.0M19ish (building
>>> from trunk).
>>>
>>> Thanks for any help you can give,
>>>
>>> --
>>> _____________________________________________
>>> Jeremy Nix
>>> Senior Application Developer
>>> Biomedical Informatics
>>> Cincinnati Children's Hospital Medical Center
>>> 513-803-2764 / [hidden email]
>>>
>>>
>>>
>>> --
>>> You receive this message as a subscriber of the [hidden email] mailing list.
>>> To unsubscribe: mailto:[hidden email]
>>> For general help: mailto:[hidden email]?subject=help
>>> OW2 mailing lists service home page: http://www.ow2.org/wws
>>>
>>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Handling submission errors

bgawel
Hi Jeremy,

I worked out the following solution to this problem:
Orbeon cannot parse a response-body but it can give you back response-headers - event('response-headers').
So your endpoint servlet can add a new header's field to an HTTP response with the response content.
Then you would need to retrieve a value of the field from event('response-headers') and display it to a user.

--
Regards,
 Bartek


Jeremy Nix wrote
Looks like I missed another thread on this issue "xforms-submit-error -
error while reading response body: Stream closed".  I'm tried using
4.0M19 and 4.0RC1 (latest from GIT).  Bartek reported the issue with
4.0M19.  Maybe there is just a bug in the stream processing.

Based on the stacktrace, it would appear that something is going awry
somewhere in here:

private static FileItem prepareFileItemFromInputStream(InputStream
inputStream, int scope) {
     // Get FileItem
     final FileItem fileItem = prepareFileItem(scope);
     // Write to file
     OutputStream os = null;
     try {
         os = fileItem.getOutputStream();
         copyStream(inputStream, os);
     } catch (IOException e) {
         throw new OXFException(e); // this is where exception is being
re-thrown due to passed in inputStream being closed already.
     }

After tracing the processing flow, I think I see what's happening.  In
XFormsModelSubmission.java, normal result processing occurs on line 475:

submitDoneOrErrorRunnable = handleSubmissionResult(p, p2,
submissionResult, true);

Then, at line #500, post-submission code occurs (which handles the
xforms-submit-done and xforms-submit-error events):

submitDoneOrErrorRunnable.run();

The issue lies in a connectionresult inputstream being closed within the
handleSubmissionResult method call.

I'm not going to pretend to understand all of the processing model
that's going on here, but I thought I'd contribute to at least a basic
understanding of what's happening in the code. Orbeon Team, hope this helps.

_____________________________________________
Jeremy Nix
Senior Application Developer
Biomedical Informatics
Cincinnati Children's Hospital Medical Center
513-803-2764 / [hidden email]

On 03/01/2013 09:30 AM, Nix, Jeremy wrote:
> Hank,
>
> Thanks for the help.  I'm still not able to get it to work, but you did
> give me a few more ideas of things to try.  I may be going about error
> handling incorrectly.  My goal is to send back a response from the
> service that causes a xforms-submit-error event to fire.  This is so
> that I can handle the error response without replacing my instance
> data.  My /test endpoint is a servlet. We're using the separate install,
> so my java application communicates with orbeon via the
> orbeon-xforms-filter.  I modified my servlet to pass back text/xml, just
> for test purposes, and I changed my submission to look like the following:
>
> <xf:submission id="chmc_submit_model" mode="synchronous"
> replace="instance" method="post"
>       validate="true" relevant="false"
>       ref="instance('data')" resource="/test">
>     <xf:action ev:observer="chmc_submit_model" ev:event="xforms-submit-done">
>       <xf:message level="modal">
>         Response:
>         <xf:output value="event('response-body')" mediatype="text/html"/>
>       </xf:message>
>     </xf:action>
>     <xf:action ev:observer="chmc_submit_model"
> ev:event="xforms-submit-error">
>       <xf:message ev:event="xforms-submit-error" level="modal">
>         A submission error occurred:
>         <xf:output value="event('response-body')" mediatype="text/html"/>
>       </xf:message>
>     </xf:action>
> </xf:submission>
>
> After which, I tested out, and the code hits the xforms-submit-done
> message block.  I still do not get a response however.  In the orbeon
> logs, I see the following:
>
> 2013-03-01 09:16:47,117 [ERROR] 'http-bio-8080-exec-1' XFormsServer:225
> - xforms-submit-error - response {status code: "200"}
> 2013-03-01 09:16:47,117 [ERROR] 'http-bio-8080-exec-1' XFormsServer:225
> - xforms-submit-error - response headers {content-type:
> "text/xml;charset=ISO-8859-1", cache-control: "no-cache, no-store,
> must-revalidate, max-age=0", expires: "Thu, 01 Jan 1970 00:00:00 GMT",
> transfer-encoding: "chunked", server: "Apache-Coyote/1.1", date: "Fri,
> 01 Mar 2013 14:16:47 GMT", x-ua-compatible: "IE=9,IE=8", vary:
> "Accept-Encoding", pragma: "no-cache"}
> 2013-03-01 09:16:47,140 [WARN] 'http-bio-8080-exec-1' XFormsServer:225 -
> xforms-submit-error - error while reading response body. {throwable: "
>
> I'm not sure why I'm getting this ERROR.  The Orbeon stack trace is the
> same as before.  I capture a tshark trace of my response just to see if
> there was something weird going on, and I'm drawing a blank.  I'm
> attaching the tshark log that I captured.
>
> _____________________________________________
> Jeremy Nix
> Senior Application Developer
> Biomedical Informatics
> Cincinnati Children's Hospital Medical Center
> 513-803-2764 / [hidden email]
>
> On 02/28/2013 04:33 PM, Hank Ratzesberger wrote:
>> Hi,
>>
>> Well, It has been I while since I worked with this, so take my ideas
>> with a grain of salt...
>>
>> Is /test a url that you handle in your page flow controller?
>>
>> Indeed, Orbeon won't handle an html content-type response, and that
>> includes when your own service isn't caught and flows through the page
>> flow controller and becomes  a 404 error.
>>
>> The url-generator will handle html and attempt to clean it up with tidy.
>>
>> I used to do things like start with a service that returns any XML
>> with GET, so I could verify that it was there. then build it out.
>>
>> You can configure logging to check what you are submitting and you can
>> use debug attributes on the pipeline as well.
>>
>> http://wiki.orbeon.com/forms/doc/developer-guide/xforms-logging
>>
>> Best,
>> Hank
>>
>> On Thu, Feb 28, 2013 at 6:16 AM, Nix, Jeremy <[hidden email]> wrote:
>>> I'm trying to figure out why I am unable to send back a error response
>>> from a submission URL.  I have the following submission tag:
>>>
>>> <xf:submission id="chmc_submit_model" mode="synchronous"
>>> replace="instance" method="post"
>>>            validate="true" relevant="false" ref="instance('data')"
>>> resource="/test">
>>>        <xf:action ev:observer="chmc_submit_model"
>>> ev:event="xforms-submit-done">
>>>            <xf:setvalue ref="instance('varData')/SubmitStatus"
>>> value="'Save Successful...'" />
>>>        </xf:action>
>>>        <xf:action ev:observer="chmc_submit_model"
>>> ev:event="xforms-submit-error">
>>>            <xf:setvalue ref="instance('varData')/SubmitError"
>>> value="event('response-body')"/>
>>>            <xf:setvalue ref="instance('varData')/SubmitStatus"
>>> value="'Error during save...'" />
>>>            <xf:message ev:event="xforms-submit-error" level="modal">
>>>                A submission error occurred:
>>>                <xf:output select="xxf:instance('varData')/SubmitError"
>>> mediatype="text/html"/>
>>>            </xf:message>
>>>        </xf:action>
>>> </xf:submission>
>>>
>>> The servlet is sending back an text/html response.  I'm attaching the
>>> log file that I receive.  It looks like Orbeon has issues handling the
>>> response.  The xforms-submit-error event fires, and the above
>>> "submission error occurred" message is displayed, but the response body
>>> is empty.  I'm assuming this is do to the stack trace from the log file.
>>>
>>> Is this something that I am doing wrong in my error handling, or is this
>>> a known bug in Orbeon?  I'm currently using Orbeon 4.0M19ish (building
>>> from trunk).
>>>
>>> Thanks for any help you can give,
>>>
>>> --
>>> _____________________________________________
>>> Jeremy Nix
>>> Senior Application Developer
>>> Biomedical Informatics
>>> Cincinnati Children's Hospital Medical Center
>>> 513-803-2764 / [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Handling submission errors

Alessandro  Vernet
Administrator
In reply to this post by Jeremy Nix
Hi Jeremy,

If you're asking why the submission fails, the answer is most likely: because the service returns text/html, while Orbeon Forms (and XForms) expects services to return application/xml. If the service says it returns text/html, but in fact the content is XML, you can do this to work around it:


Of course, if that is the case, and if at all possible, it is better to change the code of the service to return application/xml.

Alex


On Thu, Feb 28, 2013 at 6:16 AM, Nix, Jeremy <[hidden email]> wrote:
I'm trying to figure out why I am unable to send back a error response
from a submission URL.  I have the following submission tag:

<xf:submission id="chmc_submit_model" mode="synchronous"
replace="instance" method="post"
         validate="true" relevant="false" ref="instance('data')"
resource="/test">
     <xf:action ev:observer="chmc_submit_model"
ev:event="xforms-submit-done">
         <xf:setvalue ref="instance('varData')/SubmitStatus"
value="'Save Successful...'" />
     </xf:action>
     <xf:action ev:observer="chmc_submit_model"
ev:event="xforms-submit-error">
         <xf:setvalue ref="instance('varData')/SubmitError"
value="event('response-body')"/>
         <xf:setvalue ref="instance('varData')/SubmitStatus"
value="'Error during save...'" />
         <xf:message ev:event="xforms-submit-error" level="modal">
             A submission error occurred:
             <xf:output select="xxf:instance('varData')/SubmitError"
mediatype="text/html"/>
         </xf:message>
     </xf:action>
</xf:submission>

The servlet is sending back an text/html response.  I'm attaching the
log file that I receive.  It looks like Orbeon has issues handling the
response.  The xforms-submit-error event fires, and the above
"submission error occurred" message is displayed, but the response body
is empty.  I'm assuming this is do to the stack trace from the log file.

Is this something that I am doing wrong in my error handling, or is this
a known bug in Orbeon?  I'm currently using Orbeon 4.0M19ish (building
from trunk).

Thanks for any help you can give,

--
_____________________________________________
Jeremy Nix
Senior Application Developer
Biomedical Informatics
Cincinnati Children's Hospital Medical Center
<a href="tel:513-803-2764" value="+15138032764">513-803-2764 / [hidden email]



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws




--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Re: Handling submission errors

Jeremy Nix
Alex,

Actually, I was attempting to programmatically send back an error message to the page.  When I do this, I wanted to retain the existing instance data instead of doing the defined replacement.  I'm currently trying to do what Bartek had suggested, and using the response-headers event to send back a header that contains an error message that I could display to the user.  So far though, I'm not having much luck with that solution either.  So I've got a servlet that does the following:

response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
response.addHeader("ErrorMessage", errorMessage);
response.getWriter().write("Error");

In my page, I'm trying to parse the error message header using the following:

<xf:action ev:observer="chmc_submit_model" ev:event="xforms-submit-error">
  <xf:setvalue ref="instance('varData')/SubmitStatus" value="'Error during save...'" />
  <xf:message level="modal">
    A submission error occurred:
    <xf:output value="event('response-headers')[name = 'ErrorMessage']/value"/>
  </xf:message>
</xf:action>

I'm no longer getting the exception that I was getting while trying to access the response-body, but I'm not getting the header either.  I'm seeing the header being passed back in the response via tshark as well.  I'm going to do some code tracing today w/in Orbeon and see if I can figure out where things are breaking down for me.

If anyone sees anything I'm doing wrong, I'd be gracious to know.

Thanks,
_____________________________________________
Jeremy Nix
Senior Application Developer
Biomedical Informatics
Cincinnati Children's Hospital Medical Center
513-803-2764 / [hidden email]
On 03/05/2013 01:44 AM, Alessandro Vernet wrote:
Hi Jeremy,

If you're asking why the submission fails, the answer is most likely: because the service returns text/html, while Orbeon Forms (and XForms) expects services to return application/xml. If the service says it returns text/html, but in fact the content is XML, you can do this to work around it:


Of course, if that is the case, and if at all possible, it is better to change the code of the service to return application/xml.

Alex


On Thu, Feb 28, 2013 at 6:16 AM, Nix, Jeremy <[hidden email]> wrote:
I'm trying to figure out why I am unable to send back a error response
from a submission URL.  I have the following submission tag:

<xf:submission id="chmc_submit_model" mode="synchronous"
replace="instance" method="post"
         validate="true" relevant="false" ref="instance('data')"
resource="/test">
     <xf:action ev:observer="chmc_submit_model"
ev:event="xforms-submit-done">
         <xf:setvalue ref="instance('varData')/SubmitStatus"
value="'Save Successful...'" />
     </xf:action>
     <xf:action ev:observer="chmc_submit_model"
ev:event="xforms-submit-error">
         <xf:setvalue ref="instance('varData')/SubmitError"
value="event('response-body')"/>
         <xf:setvalue ref="instance('varData')/SubmitStatus"
value="'Error during save...'" />
         <xf:message ev:event="xforms-submit-error" level="modal">
             A submission error occurred:
             <xf:output select="xxf:instance('varData')/SubmitError"
mediatype="text/html"/>
         </xf:message>
     </xf:action>
</xf:submission>

The servlet is sending back an text/html response.  I'm attaching the
log file that I receive.  It looks like Orbeon has issues handling the
response.  The xforms-submit-error event fires, and the above
"submission error occurred" message is displayed, but the response body
is empty.  I'm assuming this is do to the stack trace from the log file.

Is this something that I am doing wrong in my error handling, or is this
a known bug in Orbeon?  I'm currently using Orbeon 4.0M19ish (building
from trunk).

Thanks for any help you can give,

--
_____________________________________________
Jeremy Nix
Senior Application Developer
Biomedical Informatics
Cincinnati Children's Hospital Medical Center
<a moz-do-not-send="true" href="tel:513-803-2764" value="&#43;15138032764">513-803-2764 / [hidden email]



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws




--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Handling submission errors

bgawel
In reply to this post by Alessandro Vernet
Hi Alex,

I'm having the same issue as Jeremy - http://orbeon-forms-ops-users.24843.n4.nabble.com/xforms-submit-error-error-while-reading-response-body-Stream-closed-td4656284.html

I changed the content type of response to application/xml (content-typeapplication/xml;charset=utf-8  - retrieved from event('response-headers'))
as you suggested but it did not help. Any other idea how to fix the problem?

--
Regards,
 Bartek

Alessandro Vernet wrote
Hi Jeremy,

If you're asking why the submission fails, the answer is most likely:
because the service returns text/html, while Orbeon Forms (and XForms)
expects services to return application/xml. If the service says it returns
text/html, but in fact the content is XML, you can do this to work around
it:

http://wiki.orbeon.com/forms/how-to/logic/call-service-incorrect-content-type

Of course, if that is the case, and if at all possible, it is better to
change the code of the service to return application/xml.

Alex


On Thu, Feb 28, 2013 at 6:16 AM, Nix, Jeremy <[hidden email]> wrote:

> I'm trying to figure out why I am unable to send back a error response
> from a submission URL.  I have the following submission tag:
>
> <xf:submission id="chmc_submit_model" mode="synchronous"
> replace="instance" method="post"
>          validate="true" relevant="false" ref="instance('data')"
> resource="/test">
>      <xf:action ev:observer="chmc_submit_model"
> ev:event="xforms-submit-done">
>          <xf:setvalue ref="instance('varData')/SubmitStatus"
> value="'Save Successful...'" />
>      </xf:action>
>      <xf:action ev:observer="chmc_submit_model"
> ev:event="xforms-submit-error">
>          <xf:setvalue ref="instance('varData')/SubmitError"
> value="event('response-body')"/>
>          <xf:setvalue ref="instance('varData')/SubmitStatus"
> value="'Error during save...'" />
>          <xf:message ev:event="xforms-submit-error" level="modal">
>              A submission error occurred:
>              <xf:output select="xxf:instance('varData')/SubmitError"
> mediatype="text/html"/>
>          </xf:message>
>      </xf:action>
> </xf:submission>
>
> The servlet is sending back an text/html response.  I'm attaching the
> log file that I receive.  It looks like Orbeon has issues handling the
> response.  The xforms-submit-error event fires, and the above
> "submission error occurred" message is displayed, but the response body
> is empty.  I'm assuming this is do to the stack trace from the log file.
>
> Is this something that I am doing wrong in my error handling, or is this
> a known bug in Orbeon?  I'm currently using Orbeon 4.0M19ish (building
> from trunk).
>
> Thanks for any help you can give,
>
> --
> _____________________________________________
> Jeremy Nix
> Senior Application Developer
> Biomedical Informatics
> Cincinnati Children's Hospital Medical Center
> 513-803-2764 / [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Re: Handling submission errors

bgawel
In reply to this post by Jeremy Nix
Hi Jeremy,

try something like this (assumption: your custom header's field 'ErrorMessage' is stored as the 6th one):

<xf:output value="substring-after(event('response-headers')[6], 'ErrorMessage')"/>


--
Regards,
 Bartek


Jeremy Nix wrote
Alex,

Actually, I was attempting to programmatically send back an error message to the page.  When I do this, I wanted to retain the existing instance data instead of doing the defined replacement.  I'm currently trying to do what Bartek had suggested, and using the response-headers event to send back a header that contains an error message that I could display to the user.  So far though, I'm not having much luck with that solution either.  So I've got a servlet that does the following:

response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
response.addHeader("ErrorMessage", errorMessage);
response.getWriter().write("Error");

In my page, I'm trying to parse the error message header using the following:

<xf:action ev:observer="chmc_submit_model" ev:event="xforms-submit-error">
  <xf:setvalue ref="instance('varData')/SubmitStatus" value="'Error during save...'" />
  <xf:message level="modal">
    A submission error occurred:
    <xf:output value="event('response-headers')[name = 'ErrorMessage']/value"/>
  </xf:message>
</xf:action>

I'm no longer getting the exception that I was getting while trying to access the response-body, but I'm not getting the header either.  I'm seeing the header being passed back in the response via tshark as well.  I'm going to do some code tracing today w/in Orbeon and see if I can figure out where things are breaking down for me.

If anyone sees anything I'm doing wrong, I'd be gracious to know.

Thanks,

_____________________________________________
Jeremy Nix
Senior Application Developer
Biomedical Informatics
Cincinnati Children's Hospital Medical Center
513-803-2764 / [hidden email]<mailto:[hidden email]>

On 03/05/2013 01:44 AM, Alessandro Vernet wrote:
Hi Jeremy,

If you're asking why the submission fails, the answer is most likely: because the service returns text/html, while Orbeon Forms (and XForms) expects services to return application/xml. If the service says it returns text/html, but in fact the content is XML, you can do this to work around it:

http://wiki.orbeon.com/forms/how-to/logic/call-service-incorrect-content-type

Of course, if that is the case, and if at all possible, it is better to change the code of the service to return application/xml.

Alex


On Thu, Feb 28, 2013 at 6:16 AM, Nix, Jeremy <[hidden email]<mailto:[hidden email]>> wrote:
I'm trying to figure out why I am unable to send back a error response
from a submission URL.  I have the following submission tag:

<xf:submission id="chmc_submit_model" mode="synchronous"
replace="instance" method="post"
         validate="true" relevant="false" ref="instance('data')"
resource="/test">
     <xf:action ev:observer="chmc_submit_model"
ev:event="xforms-submit-done">
         <xf:setvalue ref="instance('varData')/SubmitStatus"
value="'Save Successful...'" />
     </xf:action>
     <xf:action ev:observer="chmc_submit_model"
ev:event="xforms-submit-error">
         <xf:setvalue ref="instance('varData')/SubmitError"
value="event('response-body')"/>
         <xf:setvalue ref="instance('varData')/SubmitStatus"
value="'Error during save...'" />
         <xf:message ev:event="xforms-submit-error" level="modal">
             A submission error occurred:
             <xf:output select="xxf:instance('varData')/SubmitError"
mediatype="text/html"/>
         </xf:message>
     </xf:action>
</xf:submission>

The servlet is sending back an text/html response.  I'm attaching the
log file that I receive.  It looks like Orbeon has issues handling the
response.  The xforms-submit-error event fires, and the above
"submission error occurred" message is displayed, but the response body
is empty.  I'm assuming this is do to the stack trace from the log file.

Is this something that I am doing wrong in my error handling, or is this
a known bug in Orbeon?  I'm currently using Orbeon 4.0M19ish (building
from trunk).

Thanks for any help you can give,

--
_____________________________________________
Jeremy Nix
Senior Application Developer
Biomedical Informatics
Cincinnati Children's Hospital Medical Center
513-803-2764<tel:513-803-2764> / [hidden email]<mailto:[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Re: Handling submission errors

Alessandro  Vernet
Administrator
In reply to this post by Jeremy Nix
Hi Jeremy,

I am wondering if you could have been hitting the bug linked below, which Erik just fixed. Are you also getting this when using the "Development configuration" per the 2nd link below? If not, then you're most likely hitting that bug, and might want to try a nightly build.

https://github.com/orbeon/orbeon-forms/issues/863
http://wiki.orbeon.com/forms/doc/developer-guide/xforms-logging#TOC-Development-configuration

If it isn't that issue, could you create a minimal example that shows the problem? If you need a service that returns a 500, you can use http://xml-500.herokuapp.com/. It also returns an XML document, with Content-Type application/xml.

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Handling submission errors

Alessandro  Vernet
Administrator
In reply to this post by bgawel
Hi Bartek,

This really looks like it was caused by this bug: https://github.com/orbeon/orbeon-forms/issues/863

Could you try again with a nightly? (Both the CE and PE nightlies contain the fix now.) http://www.orbeon.com/download

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Re: Handling submission errors

Jeremy Nix
After downloading the most recent changes from 4.0.1 from trunk and
building, I still was unable to get the error message to work.  I've
tried many different permutations of this code over the last few weeks.  
This morning I was finally able to find a permutation that worked.  I
wanted to share this with the group so that everyone can benefit from
the knowledge.

Attached are my test files.  2 XForms (.xhtml) files, and a JSP page
that acts as my submission processor.  The XForms files submit to the
JSP file, and the JSP file returns back a 500 HTTP status code with an
error XML (or HTML) message.

If you look at the xforms files, you'll notice that the difference in
working and not working is where/how I was handling the
xforms-submit-error event.  When I tried nesting the tag w/in the
submission tag, I found that I was not able to access the response-body
from the event.  When I pulled event out of the submission tag, however,
I found that I was once again able to read the response-body coming from
the JSP page.

I'm not sure if there are specific reasons why one way works and the
other doesn't.  For now, I'm done investigating as I was able to get my
xforms page to once again display the error response coming from my
submission end point.

Hope this helps anyone else who ran into this issue.

_____________________________________________
Jeremy Nix
Senior Application Developer
Biomedical Informatics
Cincinnati Children's Hospital Medical Center
513-803-2764 / [hidden email]

On 03/07/2013 09:03 PM, Alessandro Vernet wrote:

> Hi Bartek,
>
> This really looks like it was caused by this bug:
> https://github.com/orbeon/orbeon-forms/issues/863
>
> Could you try again with a nightly? (Both the CE and PE nightlies contain
> the fix now.) http://www.orbeon.com/download
>
> Alex
>
>
>
> --
> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Handling-submission-errors-tp4656287p4656335.html
> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws

output_resp.jsp (688 bytes) Download Attachment
test_error_response.xhtml (2K) Download Attachment
test_error_response_broken.xhtml (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Handling submission errors

Erik Bruchez
Administrator
Jeremy,

Thanks for sharing. That doesn't seem right: maybe that's another bug!

-Erik

On Tue, Mar 19, 2013 at 8:32 AM, Nix, Jeremy <[hidden email]> wrote:

> After downloading the most recent changes from 4.0.1 from trunk and
> building, I still was unable to get the error message to work.  I've
> tried many different permutations of this code over the last few weeks.
> This morning I was finally able to find a permutation that worked.  I
> wanted to share this with the group so that everyone can benefit from
> the knowledge.
>
> Attached are my test files.  2 XForms (.xhtml) files, and a JSP page
> that acts as my submission processor.  The XForms files submit to the
> JSP file, and the JSP file returns back a 500 HTTP status code with an
> error XML (or HTML) message.
>
> If you look at the xforms files, you'll notice that the difference in
> working and not working is where/how I was handling the
> xforms-submit-error event.  When I tried nesting the tag w/in the
> submission tag, I found that I was not able to access the response-body
> from the event.  When I pulled event out of the submission tag, however,
> I found that I was once again able to read the response-body coming from
> the JSP page.
>
> I'm not sure if there are specific reasons why one way works and the
> other doesn't.  For now, I'm done investigating as I was able to get my
> xforms page to once again display the error response coming from my
> submission end point.
>
> Hope this helps anyone else who ran into this issue.
>
> _____________________________________________
> Jeremy Nix
> Senior Application Developer
> Biomedical Informatics
> Cincinnati Children's Hospital Medical Center
> 513-803-2764 / [hidden email]
>
> On 03/07/2013 09:03 PM, Alessandro Vernet wrote:
>> Hi Bartek,
>>
>> This really looks like it was caused by this bug:
>> https://github.com/orbeon/orbeon-forms/issues/863
>>
>> Could you try again with a nightly? (Both the CE and PE nightlies contain
>> the fix now.) http://www.orbeon.com/download
>>
>> Alex
>>
>>
>>
>> --
>> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Handling-submission-errors-tp4656287p4656335.html
>> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws