I've been getting a NullPointerException using SunShine with both the demo
and a little custom test based on the material at
http://www.need-a-cake.com/stories/2002/02/28/usingTheSunriseComponents.html

I found a note to the mailing list from Keil, who seemed to be having the
exact same problem in May, but there were no replies to it.

I'm using
Java 1.4.0
Tomcat 4.0.4
Cocoon 2.0.3 (from source or the 1.4 binary build)

I'm speculating that the error is caused because the authentication
information is not getting stored to the session context after the user is
authed.

Here's some of the stack trace:
java.lang.NullPointerException
        at
org.apache.cocoon.sunshine.xml.XMLUtil.getNodesFromPath(XMLUtil.java:869)
        at
org.apache.cocoon.sunshine.xml.XMLUtil.getNodesFromPath(XMLUtil.java:871)
        at
org.apache.cocoon.sunshine.xml.XMLUtil.getNodesFromPath(XMLUtil.java:871)
        at
org.apache.cocoon.sunshine.xml.XMLUtil.getNodeListFromPath(XMLUtil.java:836)
        at
org.apache.cocoon.sunshine.context.SimpleSessionContext.getXML(SimpleSession
Context.java:173)
        at
org.apache.cocoon.sunshine.sunrise.SunRise.isAuthenticated(SunRise.java:691)
        at
org.apache.cocoon.sunshine.sunrise.SunRise.checkAuthentication(SunRise.java:
766)
        at
org.apache.cocoon.sunshine.sunrise.acting.AuthAction.act(AuthAction.java:122
)
        at
org.apache.cocoon.www.sitemap_xmap.matchN4004A5(F:\tomcat-4.0.4-win\work\Sta
ndalone\localhost\cocoon\cocoon-files\org/apache/cocoon/www\sitemap_xmap.jav
a:5363)
        at
org.apache.cocoon.www.sitemap_xmap.process(F:\tomcat-4.0.4-win\work\Standalo
ne\localhost\cocoon\cocoon-files\org/apache/cocoon/www\sitemap_xmap.java:333
0)
        at
org.apache.cocoon.www.sitemap_xmap.process(F:\tomcat-4.0.4-win\work\Standalo
ne\localhost\cocoon\cocoon-files\org/apache/cocoon/www\sitemap_xmap.java:310
0)

Now some sections from the sitemap, these were all copied nearly verbatim
from the above link. I switched target for redirect after a sucessful login
to ags-authuser in an effort to see if it was returning the proper info.
This doesn't seem to work though because it requires a name and password
parameter in the request. My understanding is that it should be able to get
this info from the session context after a successful login, but it clearly
isn't.

<!-- definition for the auth action -->
    <map:action name="sunRise-auth"
src="org.apache.cocoon.sunshine.sunrise.acting.AuthAction">
      <handlers>
        <handler name="ags-handler"
xmlns:map="http://apache.org/cocoon/sitemap/1.0";
xmlns:sunshine="http://sunshine.sundn.de/sunshine/1.0";>
             <redirect-to uri="cocoon://ags-loginpage"/>
             <authentication uri="cocoon:raw://ags-authuser" />
        </handler>
      </handlers>
    </map:action>

<!-- pipelines -->
   <map:match pattern="ags-loginpage">
              <map:generate src="loginpage.xml" />
              <map:transform src="loginpage.xsl" />
              <map:transform type="encodeURL" />
              <map:serialize />
   </map:match>

   <map:match pattern="ags-login">
      <map:act type="sunRise-login">
           <map:parameter name="handler" value="ags-handler"/>
           <map:parameter name="parameter_name" value="request:name"/>
           <map:parameter name="parameter_password"
value="request:password"/>
           <!-- If the authentication is successfull then this redirect will
be performed -->
           <map:redirect-to uri="ags-authuser"/>
      </map:act>
      <!-- authentication failed: -->
      <map:generate src="login-failed.xml"/>
      <map:transform src="login-failed.xsl"/>
      <map:serialize/>
   </map:match>

   <map:match pattern="ags-authuser">
            <map:generate src="ags-user.xml" />
            <map:transform src="ags-user.xsl">
               <map:parameter name="use-request-parameters" value="true" />
            </map:transform>
            <map:serialize type="xml"/>
   </map:match>

   <map:match pattern="ags-protected">
           <map:act type="sunRise-auth">
               <map:parameter name="handler" value="ags-handler"/>
               <map:generate src="temp.html"/>
           </map:act>
       <map:serialize />
   </map:match>

<!-- end of sitemap -->

I can get authentication information by handcrafting URLs to auth user. For
example ags-authuser?name=cocoon&password=cocoon gives me back the xml:
  <?xml version="1.0" encoding="UTF-8" ?>
- <authentication>
  <ID>cocoon</ID>
  <role>admin</role>
- <data>
  <name>cocoon</name>
  <role>admin</role>
  <ID>cocoon</ID>
  <user>cocoon</user>
  <title />
  <firstname />
  <lastname />
  <company />
  <street />
  <zipcode />
  <city />
  <country />
  <phone />
  <fax />
  <email />
  <bankid />
  <bankname />
  <accountid />
  </data>
  </authentication>

Which seems to be correct. However going to ags-protected and then logging
in causes the null pointer exception.

The reason I think the information is not being stored in the context is
because after going through the source along the stack trace I came across
this:
SunRise.java line 691:
                            DocumentFragment id = context.getXML("/" + name
+ "/authentication/ID");

name is the handler name. The ags-authuser pipeline is returning the proper
snippets as shown above, but then later when this call is made, the fragment
isn't available.

Any ideas of how I can fix this or get around it? Is something broken in
SunShine?

Dave


---------------------------------------------------------------------
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:     <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>

Reply via email to