You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Cindy Ballreich <ci...@ballreich.net> on 2001/02/23 22:46:44 UTC

ClassCastException

Can you stand another FP related question from me?

As in my previous postings, I'm working with the form capabilities
demonstrated in the "Simple Form Handling" example. Currently, I'm trying
to update the value of an attribute and I'm getting a ClassCastException
when I try to do this. When I try to edit the CDATA value of a node I don't
have any problems at all. It's the attributes that are giving me problems.
(I'm using cocoon 1.8, jakarta 3.1.1, and apache 1.3.14 on an NT4.0 system.)

This is what I'm trying to edit...

<item name="foo" cat_num="1234">
   ...other elements...
</item>

Here is a typical bit of XML to do the editing...

<input name="name" size="30" label="Name">
  <fp:if-post>
    <fp:write to="external-item" select="@name">
      <request:get-parameter name="name"/>
    </fp:write>
  </fp:if-post>
  <fp:read select="@name" from="external-item"/>
</input>

And here is the error message...

java.lang.ClassCastException: org.apache.xerces.dom.DeferredAttrNSImpl
        at
org.apache.cocoon.processor.xsp.library.fp.fpResource.writeAsTextNode(fpReso
urce.java:271)
        at
org.apache.cocoon.processor.xsp.library.fp.fpLibrary.handleWrite(fpLibrary.j
ava:139)
        at
_C_._Program_Files._Apache_Group._jakarta_tomcat._webapps._cocoon._servlets.
_catalog._catalog_edit.populateDocument(_catalog_edit.java:223)
        at
org.apache.cocoon.processor.xsp.XSPPage.getDocument(XSPPage.java:96)
        at
org.apache.cocoon.processor.xsp.XSPProcessor.process(XSPProcessor.java:494)
        at org.apache.cocoon.Engine.handle(Engine.java:359)
        at org.apache.cocoon.Cocoon.service(Cocoon.java:167)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
        at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
        at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
        at
org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection
(Ajp12ConnectionHandler.java:156)
        at
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338)
        at java.lang.Thread.run(Unknown Source)


Any help would be appreciated.
Cindy

Re: ClassCastException

Posted by Cindy Ballreich <ci...@ballreich.net>.
Hi Jeff,

Thanks for the response. It's greatly appreciated.

>
>From looking at the FP source (fpResource.java), it looks like your "select"
>statement isn't matching anything. FP then tries to typecast "null" into an
>Element, thus throwing a CCException. Are you sure "@name" contains
something?

Yes, the "@name" attribute does contain a value. It's being read by
"fp:read" and it displays in the input display on the html form. Using the
fragment below as an example, I have no trouble writing the value of
"quantity" but I can't update the value of "@name". I have no trouble
reading the value of either...

<item name="foo">
  <quantity>10</quantity>
</item>

It's very puzzling.

>
>You're also using a slightly old version of FP (the latest says it has
better error
>reporting).
>

At your suggestion I upgraded Cocoon to 1.8.2. (I also upgraded apache to
1.3.17) The error message is identical to the previous version except that
the FOP version number is now being displayed...
FOP_VERSION = FOP 0.15
FOP_VERSION_NO = 0.15

Are there any working examples of using FP to update an attribute value?

Thanks again!

Cindy


>
>--Jeff
>
>On Fri, Feb 23, 2001 at 01:46:44PM -0800, Cindy Ballreich wrote:
>> Can you stand another FP related question from me?
>> 
>> As in my previous postings, I'm working with the form capabilities
>> demonstrated in the "Simple Form Handling" example. Currently, I'm trying
>> to update the value of an attribute and I'm getting a ClassCastException
>> when I try to do this. When I try to edit the CDATA value of a node I don't
>> have any problems at all. It's the attributes that are giving me problems.
>> (I'm using cocoon 1.8, jakarta 3.1.1, and apache 1.3.14 on an NT4.0
system.)
>> 
>> This is what I'm trying to edit...
>> 
>> <item name="foo" cat_num="1234">
>>    ...other elements...
>> </item>
>> 
>> Here is a typical bit of XML to do the editing...
>> 
>> <input name="name" size="30" label="Name">
>>   <fp:if-post>
>>     <fp:write to="external-item" select="@name">
>>       <request:get-parameter name="name"/>
>>     </fp:write>
>>   </fp:if-post>
>>   <fp:read select="@name" from="external-item"/>
>> </input>
>> 
>> And here is the error message...
>> 
>> java.lang.ClassCastException: org.apache.xerces.dom.DeferredAttrNSImpl
>>         at
>>
org.apache.cocoon.processor.xsp.library.fp.fpResource.writeAsTextNode(fpReso
>> urce.java:271)
>>         at
>>
org.apache.cocoon.processor.xsp.library.fp.fpLibrary.handleWrite(fpLibrary.j
>> ava:139)
>>         at
>>
_C_._Program_Files._Apache_Group._jakarta_tomcat._webapps._cocoon._servlets.
>> _catalog._catalog_edit.populateDocument(_catalog_edit.java:223)
>>         at
>> org.apache.cocoon.processor.xsp.XSPPage.getDocument(XSPPage.java:96)
>>         at
>> org.apache.cocoon.processor.xsp.XSPProcessor.process(XSPProcessor.java:494)
>>         at org.apache.cocoon.Engine.handle(Engine.java:359)
>>         at org.apache.cocoon.Cocoon.service(Cocoon.java:167)
>>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
>>         at
>>
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
>>         at
>> org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
>>         at
>>
org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection
>> (Ajp12ConnectionHandler.java:156)
>>         at
>>
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338)
>>         at java.lang.Thread.run(Unknown Source)
>> 
>> 
>> Any help would be appreciated.
>> Cindy
>> 
>> ---------------------------------------------------------------------
>> Please check that your question has not already been answered in the
>> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>> 
>> To unsubscribe, e-mail: <co...@xml.apache.org>
>> For additional commands, e-mail: <co...@xml.apache.org>
>
>-- 
>
>---------------------------------------------------------------------
>Please check that your question has not already been answered in the
>FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
>To unsubscribe, e-mail: <co...@xml.apache.org>
>For additional commands, e-mail: <co...@xml.apache.org>
>
>

Re: ClassCastException

Posted by Jeff Turner <je...@socialchange.net.au>.
Hi,