You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Emond Papegaaij <e....@student.utwente.nl> on 2004/10/01 18:35:51 UTC
Empty request object
Hello,
When running our cocoon application on some systems, we run into a very
strange and hard to find problem. Our application uses cForms and a custom
flow engine to display these forms. In some cases, when the user submits the
form, the flow engine receives an empty request object. With empty I mean non
of the request parameters are present. I did not yet check for other
attributes. To make sure the error is not caused by our custom flow engine I
added this piece of debug code:
public class ThreadInterpreter extends AbstractInterpreter
implements Configurable, ContinuationsDisposer {
...
public void handleContinuation(String id, List params,
Redirector redirector) throws Exception {
Request r = ContextHelper.getRequest(avalonContext);
java.util.Enumeration enu = r.getParameterNames();
System.out.println("Request Parameters ("+r.hashCode()+
" interpreter 1):");
while (enu.hasMoreElements()) {
String name = (String) enu.nextElement();
System.out.println(name+": "+r.getParameter(name));
}
...
}
}
As you can see, this code is the first code to be executed when resuming a
continuation. It dumps all request parameters to the stdout. Most of the time
this produces the expected result, lots of parameters with values. However in
some rare occasions this does not produce any parameter at all. The
'handleContinuation' method is called directly from the sitemap in the same
way as with a normal javascript flow.
From what I can see some part of Cocoon or Tomcat is not thread safe and does
not fill the parameters of the request in time. It is very hard to reproduce
the problem and it seems to happen more on systems running Windows, than on
systems running Linux. Also the upgrade to jdk 1.5 increased the problem
significantly. Adding more debug code below this code sometimes makes the
problem go away, even before this extra code is executed.
Am I doing something wrong, or did I hit a serious bug in either Cocoon or
Tomcat?
Best regards,
Emond Papegaaij
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Empty request object
Posted by Emond Papegaaij <e....@student.utwente.nl>.
On Thursday 07 October 2004 01:42, Adam Walsh wrote:
> Emond Papegaaij wrote:
> >When running our cocoon application on some systems, we run into a very
> >strange and hard to find problem. Our application uses cForms and a custom
> >flow engine to display these forms. In some cases, when the user submits
> > the form, the flow engine receives an empty request object. With empty I
> > mean non of the request parameters are present.
>
> I've noticed the same problem Emond describes with empty request objects
> while using CForms and Flow in Cocoon 2.1.5. Does anyone have any
> thoughts on what could be causing this?
I've done some thorough debugging on both the Cocoon and Tomcat source. It
seems as Cocoon does not support multiple threads, even when these threads
are properly synced. So if you're starting a threads from within the flow,
I'd suggest to find another way to tackle your problem. This is one of the
things I've tried:
- Get some info from the current context and print it
- Start a thread
- Lock the first thread
- Get the same info from the context and print it
The info can be about anything, but the Request object will do. It turned out
that the results were not the same. Somehow the Request object is different
inside the second thread. Returning to the first thread gave the old Request
object again.
In our application the second thread is the flow. This flow is locked and
resumed on each sendPageAndWait. I've managed to work around this problem by
sending Expression objects from the flow to the main servlet thread. The main
servlet thread executes these Expressions and returns the result. I've added
this wrapper around all the communication points between the flow and Cocoon.
This made the problem dissappear. Of course this is not a very clean
solution, so we are thinking about implementing our own Java VM to run the
flow.
Emond Papegaaij
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Empty request object
Posted by Adam Walsh <aw...@contal.net.au>.
I've noticed the same problem Emond describes with empty request objects
while using CForms and Flow in Cocoon 2.1.5. Does anyone have any
thoughts on what could be causing this?
Adam
Emond Papegaaij wrote:
>Hello,
>
>When running our cocoon application on some systems, we run into a very
>strange and hard to find problem. Our application uses cForms and a custom
>flow engine to display these forms. In some cases, when the user submits the
>form, the flow engine receives an empty request object. With empty I mean non
>of the request parameters are present. I did not yet check for other
>attributes. To make sure the error is not caused by our custom flow engine I
>added this piece of debug code:
>
>public class ThreadInterpreter extends AbstractInterpreter
> implements Configurable, ContinuationsDisposer {
>
> ...
> public void handleContinuation(String id, List params,
> Redirector redirector) throws Exception {
> Request r = ContextHelper.getRequest(avalonContext);
> java.util.Enumeration enu = r.getParameterNames();
> System.out.println("Request Parameters ("+r.hashCode()+
> " interpreter 1):");
> while (enu.hasMoreElements()) {
> String name = (String) enu.nextElement();
> System.out.println(name+": "+r.getParameter(name));
> }
>
> ...
> }
>}
>
>As you can see, this code is the first code to be executed when resuming a
>continuation. It dumps all request parameters to the stdout. Most of the time
>this produces the expected result, lots of parameters with values. However in
>some rare occasions this does not produce any parameter at all. The
>'handleContinuation' method is called directly from the sitemap in the same
>way as with a normal javascript flow.
>
>>From what I can see some part of Cocoon or Tomcat is not thread safe and does
>not fill the parameters of the request in time. It is very hard to reproduce
>the problem and it seems to happen more on systems running Windows, than on
>systems running Linux. Also the upgrade to jdk 1.5 increased the problem
>significantly. Adding more debug code below this code sometimes makes the
>problem go away, even before this extra code is executed.
>
>Am I doing something wrong, or did I hit a serious bug in either Cocoon or
>Tomcat?
>
>Best regards,
>Emond Papegaaij
>
>---------------------------------------------------------------------
>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