You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Alan Hodgkinson <al...@softxs.ch> on 2002/09/03 21:36:46 UTC

Cocoon runtime error: 'Session is required'

Dear All,

I'm trying to implement session besed forms and have run into the 
following error:

ERROR   (2002-09-03) 18:56.26:764   [sitemap] (/tc/test-form.html)
HttpProcessor[8080][4]/PipelineNode: Error while processing pipeline at
jndi:/localhost/tc/sitemap.xmap:440:19
org.apache.cocoon.ProcessingException: Exception in
ServerPagesGenerator.generate(): java.lang.IllegalArgumentException:
CreateContext: Session is required
        at
org.apache.cocoon.generation.ServerPagesGenerator.generate(ServerPagesGenerator.java:281)
        at
org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.processXMLPipeline(AbstractProcessingPipeline.java:502)
        at
org.apache.cocoon.components.pipeline.impl.AbstractCachingProcessingPipeline.processXMLPipeline(AbstractCachingProcessingPipeline.java:204)
...

It seems that my xsp page (which is processed by the session
transformer)
is attempting to access session context without there being a session.
I was under the (perhaps incorrect) assumption that when you use the
session transformer that it creates a session if necessary. The session
documentation doesn't say very much on this issue.

Many thanks in advance for any tips (or pointers to relevant
docs/howtos).

My ultimate goal is to implement forms with validation, but I haven't
yet
studied all the XMLForms or Schematron stuff (any advice for which one
to
look at first or pointers to examples?).

Best wishes to all,

Alan Hodgkinson


P.S. Here are portions of the revelent files:

----- The pipeline from the sitemap

      <!-- Form Handler -->

      <map:match pattern="*-form.html">
        <map:generate type="serverpages" src="xsp/{1}-form.xsp"/>
        <map:transform type="session"/>
        <map:transform src="xsp/form2html.xslt"/>
        <map:transform src="xsp/simple-page2html.xsl"/>
        <map:serialize/>
      </map:match>


----- The XSP page that caused the error: user-form.xsp 
(Which is called with the url user-form.html)

<xsp:page
        language="java"
        create-session="yes"
        xmlns:xsp="http://apache.org/xsp"
        xmlns:session="http://cocoon.apache.org/session/1.0">

<page>
  <title>New User Entry</title>

  <!-- Question: is this needed? -->
  <session:createcontext name="userdata"/>

  <content>
    Enter information about the new user:
    <session:form name="userInfo">
      <session:action>user-info.html</session:action>
      <session:content>
        <table>
          <tr>
            <td>User ID</td>
            <td><session:inputxml
                    context="userdata" path="/user/userId"
                    name="userId" type="text"/>
            </td>
            ...
        </table>
        <!-- Question: coocon seems to need context & path, why? -->
        <session:inputxml
            context="userdata" path="/usr/submit" name="submit"
            type="submit" value="Create User"/>
      </session:content>
    </session:form>
  </content>
</page>
</xsp:page>

------

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


[SUMMARY] Re: Cocoon runtime error: 'Session is required'

Posted by Alan Hodgkinson <al...@softxs.ch>.
How to fix stacktrace with: 'Session is required'

I'm sending this short summary, which contains the dumb answer to 
a dumb question, so that:

- Other dummies know what to do when they make the same dumb mistake.
- One day when the trouble shooting guide is witten, this can be 
  part of it.

Alan Hodgkinson wrote:

> I'm trying to implement session based forms and have run into the
> following error:
> 
> ERROR   (2002-09-03) 18:56.26:764   [sitemap] (/tc/test-form.html)
> HttpProcessor[8080][4]/PipelineNode: Error while processing pipeline at
> jndi:/localhost/tc/sitemap.xmap:440:19
> org.apache.cocoon.ProcessingException: Exception in
> ServerPagesGenerator.generate(): java.lang.IllegalArgumentException:
> CreateContext: Session is required
> ..[snip]..
> 
> It seems that my xsp page (which is processed by the session transformer)
> is attempting to access session context without there being a session.
> I was under the (perhaps incorrect) assumption that when you use the
> session transformer that it creates a session if necessary. 

That is an incorrect assumption. The session must be explicitly created.

> The session documentation doesn't say very much on this issue.

Also wrong. Smacks self and repeats 'RTMF' 100 times! Look at:

http://localhost:8080/cocoon/documents/userdocs/actions/session-action.html

Where it states that you need to use the session action to create a 
session. Change the pipeline as follows:

>       <!-- Form Handler -->
> 
>       <map:match pattern="*-form.html">
>         <map:generate type="serverpages" src="xsp/{1}-form.xsp"/>
          <!-- The next line causes the session to be created -->
          <map:act type="session"/>
>         <map:transform type="session"/>
>         <map:transform src="xsp/form2html.xslt"/>
>         <map:transform src="xsp/simple-page2html.xsl"/>
>         <map:serialize/>
>       </map:match>

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>