TreeNode and DefaultTreeNode

Components, Ajax Framework, Utilities and More.
Post Reply
shanghanyu
Posts: 24
Joined: 19 Jul 2010, 20:40

24 Jun 2011, 17:54

Hi,

Im trying the treetable example from the user guide but Im getting an error, can anyone help thx a lot? :)
Im using jboss seam and primefaces 1.1. the back bean is like this:

@Name("documentsController")
public class DocumentsController {
private TreeNode root;
public DocumentsController() {
root = new DefaultTreeNode("root", null);
TreeNode documents = new DefaultTreeNode("Documents", root);
TreeNode pictures = new DefaultTreeNode("Pictures", root);
TreeNode music = new DefaultTreeNode("Music", root);
TreeNode work = new DefaultTreeNode("Work", documents);
TreeNode primefaces = new DefaultTreeNode("PrimeFaces", documents);
//Documents
TreeNode expenses = new DefaultTreeNode("document", "Expenses.doc", work);
TreeNode resume = new DefaultTreeNode("document", "Resume.doc", work);
TreeNode refdoc = new DefaultTreeNode("document", "RefDoc.pages", primefaces);
//Pictures
TreeNode barca = new DefaultTreeNode("picture", "barcelona.jpg", pictures);
TreeNode primelogo = new DefaultTreeNode("picture", "logo.jpg", pictures);
TreeNode optimus = new DefaultTreeNode("picture", "optimus.png", pictures);
//Music
TreeNode turkish = new DefaultTreeNode("Turkish", music);
}
public TreeNode getRoot() {
return root;
}
}


here is the error:
java.lang.ClassCastException: org.primefaces.model.DefaultTreeNode cannot be cast to org.primefaces.model.TreeNode
at org.primefaces.component.treetable.TreeTableRenderer.encodeRows(TreeTableRenderer.java:116)
at org.primefaces.component.treetable.TreeTableRenderer.encodeMarkup(TreeTableRenderer.java:71)
at org.primefaces.component.treetable.TreeTableRenderer.encodeEnd(TreeTableRenderer.java:35)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:861)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:937)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:148)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:930)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)

shanghanyu
Posts: 24
Joined: 19 Jul 2010, 20:40

27 Jun 2011, 15:00

Anybody has an idea on this?
I've been struggling on this for weeks, thanks.

shanghanyu
Posts: 24
Joined: 19 Jul 2010, 20:40

27 Jun 2011, 20:00

somebody, please give me a hint, thx.

kukeltje
Expert Member
Posts: 8400
Joined: 17 Jun 2010, 13:34
Location: Netherlands

28 Jun 2011, 13:47

a hint... hmm.... what about multiple versions in different classloaders?
Ronald van Kuijk
______________________________
PrimeFaces 5.2, PrimeFaces plus 0.0.2 | JbossWildfly 8.1| Mojarra 2.2.8
Fedora 21, Firefox 'most recent'
Read the forum posting rules
Beginners: https://jsf.zeef.com/bauke.scholtz

rdeoliveira
Posts: 61
Joined: 23 Jun 2011, 11:40

28 Jun 2011, 14:52

Have you first try with this example : http://www.primefaces.org/showcase/ui/tree.jsf

Does it works ?

And please put your code into the code markup (edit post)
JSF 2.0
Primefaces 3.0.M3
Tomcat 7.0
--
French user of primefaces

shanghanyu
Posts: 24
Joined: 19 Jul 2010, 20:40

28 Jun 2011, 15:44

Hi, rdeoliveira

No the tree is not working. I got the same problem. Im using primefaces2.2.1

Code: Select all

java.lang.ClassCastException: org.primefaces.model.DefaultTreeNode cannot be cast to org.primefaces.model.TreeNode
	at org.primefaces.component.tree.TreeRenderer.encodeScript(TreeRenderer.java:171)
	at org.primefaces.component.tree.TreeRenderer.encodeEnd(TreeRenderer.java:163)
	at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:861)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:937)
	at javax.faces.render.Renderer.encodeChildren(Renderer.java:148)
	at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:930)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
	at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
	at org.openfaces.ajax.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:64)
	at org.openfaces.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:413)
	at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
	at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
	at org.openfaces.ajax.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:64)
	at org.openfaces.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:413)
	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.openfaces.util.ResourceFilter.doFilter(ResourceFilter.java:99)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
	at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
	at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
	at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
	at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
	at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
	at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
	at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
	at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
	at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
	at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
	at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
	at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
	at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
	at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
	at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
	at java.lang.Thread.run(Unknown Source)

User avatar
Oleg
Expert Member
Posts: 3788
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

27 Sep 2011, 16:17

The thread is old, but sometimes I see the same exception in log files:

Code: Select all

INFO: java.lang.ClassCastException: [Lorg.primefaces.model.DefaultTreeNode; cannot be cast to org.primefaces.model.TreeNode
java.lang.ClassCastException: [Lorg.primefaces.model.DefaultTreeNode; cannot be cast to org.primefaces.model.TreeNode
	at org.primefaces.component.tree.Tree.processUpdates(Tree.java:322)
	at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:510)
	at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183)
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1589)
I use PF 2.2.1. Any ideas? It's really annoying because I don't see any issues with using of Tree.

P.S. buggy, buggy Tree. I had so many tree selection issues in PF 2.2.1 and now this ClassCastException.

User avatar
Oleg
Expert Member
Posts: 3788
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

28 Sep 2011, 18:05

I have found the issue!

We can write selectionMode="single" and define selection as an Array of DefaultTreeNode. But Tree.java in PrimeFaces has this check:

Code: Select all

            if(selectionMode.equals("single")) {
                if(previousSelection != null)
                    ((TreeNode) previousSelection).setSelected(false);
                if(selection != null)
                    ((TreeNode) selection).setSelected(true);
            }
Casting is always to TreeNode, not to array of TreeNode for single selection. The issue gone after I set single selection as a single DefaultTreeNode (not DefaultTreeNode[]).

Post Reply
  • Information
  • Who is online

    Users browsing this forum: Bing [Bot], Google [Bot] and 13 guests