This is just a vague guess, but as far as I *think* that class name
isn't the only thing Java uses to compare two classes when casting. So
if you have defined your TreeNode class in more than once place, it's
possible that the class you're passing it and the class Tapestry is
trying to use were loaded by different classloaders from different
places. When you define it in the Tapestry page class I guess it only
uses the one class file so it works fine. Check how many TreeNode.class
files you have on your classpath, in jars or locally.
Carl
Jorge Merlino wrote:
Hi,
I'm trying use the tapestry tree component found in http://wiki.apache.org/tapestry/Tapestry5TreeComponent
but I'm stuck with a very strange exception which is this:
java.lang.ClassCastException: uy.com.ipcontact.webjastconf.components.TreeNode
cannot be cast to uy.com.ipcontact.webjastconf.components.TreeNode
Java is trying to cast an object to its same class and failing to do so! This works if I create the TreeNode object
in the tapestry page class but does not If I create the TreeNode objects in another class and return them to
the page class via a procedure return value.
Here is some more context for the exception if it helps.
Caused by: org.apache.tapestry5.ioc.internal.util.TapestryException: Failure
reading parameter 'source' of component Index:tree_0:
uy.com.ipcontact.webjastconf.components.TreeNo
de cannot be cast to uy.com.ipcontact.webjastconf.components.TreeNode [at
context:Index.tml, line 3, column 73]
at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.invoke(ComponentPageElementImpl.java:932)
at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.access$200(ComponentPageElementImpl.java:50)
at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$13.render(ComponentPageElementImpl.java:499)
at
org.apache.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:72)
... 64 more
Caused by: org.apache.tapestry5.ioc.internal.util.TapestryException: Failure
reading parameter 'source' of component Index:tree_0:
uy.com.ipcontact.webjastconf.components.TreeNo
de cannot be cast to uy.com.ipcontact.webjastconf.components.TreeNode [at
context:Index.tml, line 3, column 73]
at
org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.readParameter(InternalComponentResourcesImpl.java:290)
at
org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.readParameter(InternalComponentResourcesImpl.java:315)
at
uy.com.ipcontact.webjastconf.components.Tree._$read_parameter_source(Tree.java)
at uy.com.ipcontact.webjastconf.components.Tree.setupRender(Tree.java:55)
at uy.com.ipcontact.webjastconf.components.Tree.setupRender(Tree.java)
at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$13$1.run(ComponentPageElementImpl.java:495)
at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.invoke(ComponentPageElementImpl.java:917)
... 67 more
Caused by: org.apache.tapestry5.ioc.internal.util.TapestryException:
uy.com.ipcontact.webjastconf.components.TreeNode cannot be cast to
uy.com.ipcontact.webjastconf.components.T
reeNode [at context:Index.tml, line 3, column 73]
at org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:57)
at
org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.readParameter(InternalComponentResourcesImpl.java:284)
... 73 more
Caused by: java.lang.ClassCastException:
uy.com.ipcontact.webjastconf.components.TreeNode cannot be cast to
uy.com.ipcontact.webjastconf.components.TreeNode
at uy.com.ipcontact.webjastconf.pages.Index.getTreeNodes(Index.java:46)
at $PropertyConduit_11fc8c4abe7.get($PropertyConduit_11fc8c4abe7.java)
at org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:53)
... 74 more
Thank you for your time
Best regards
Jorge
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org