4 Replies Latest reply on May 26, 2010 12:12 PM by Nick Belaevski

    Cast exception using UITre/HtmlTree

    Ralf Heese Newbie

      We took http://livedemo.exadel.com/richfaces-demo/richfaces/tree.jsf to as an template to implement a category tree. Everything worked well until we tried to access the selected node of the tree. First we run into the following error:

      WARN [lifecycle] /admin/categories.xhtml @36,71 nodeSelectListener="#{categoryManager.processSelection}": javax.ejb.EJBTransactionRolledbackException: java.lang.NoClassDefFoundError: org/richfaces/component/UITree

      So we moved the libraries richfaces-*.jar into the classpath of JBoss. Afterwards we got the following error:

      WARN [lifecycle] /admin/categories.xhtml @36,71 nodeSelectListener="#{categoryManager.processSelection}": javax.ejb.EJBTransactionRolledbackException: org.richfaces.component.html.HtmlTree cannot be cast to org.richfaces.component.UITree

      Note, that HtmlTree is a subclass of UITree. We also tried using Java 1.5 and 1.6, and we upgraded Seam to 2.0.0CR2. However, we could solve our problem. Does anyone know a solution?

      Here are some more information:
      - We are using jboss-4.2.1.GA

      The implementation goes as follows (xhtml and java files):
       <h3>Gerade ausgewählt (AJAX-Tree)</h3>
       <h:outputText escape="false"
       value="Selected Node: #{categoryManager.treeCat}" id="selectedNode" />
       <rich:tree style="width:300px"
       reRender="selectedNode" ajaxSubmitSelection="true"
       switchType="ajax" value="#{categoryManager.treeNode}" var="item">

      public class CategoryManager implements ICategoryManager {
       private List<Category> categoryList;
       @Out(required = false)
       private Category selectedCategory;
       @PersistenceContext(type = PersistenceContextType.EXTENDED)
       private EntityManager em;
       private TreeNode rootNode = null;
       private Category treeCat = null;
       public void findCategories() {
       categoryList = em.createQuery(
       "from Category cat where cat.parent is null order by cat.name")
       public void update() {
       @Begin(join = true)
       public void select() {
       public void delete() {
       selectedCategory = null;
       public void destroy() {
       private void addNodes(Category rootNode, TreeNode node,
       List<Category> catList) {
       int counter = 1;
       for (Category cat : catList) {
       if ((rootNode == null && cat.getParent() == null)
       || ((rootNode != null && cat.getParent() != null) && (cat
       .getParent().equals(rootNode)))) {
       TreeNodeImpl nodeImpl = new TreeNodeImpl();
       node.addChild(new Integer(counter), nodeImpl);
       // TODO: testen, ob's mit einkommentiertem Befehl eine
       // concurrentModificationException gibt
       // catList.remove(cat);
       addNodes(cat, nodeImpl, catList);
       private void loadTree() {
       rootNode = new TreeNodeImpl();
       List<Category> objects = em.createQuery("from Category")
       addNodes(null, rootNode, objects);
       public TreeNode getTreeNode() {
       if (rootNode == null) {
       return rootNode;
       public void processSelection(NodeSelectedEvent event) {
       UITree tree = (UITree)event.getComponent();
       treeCat = (Category) tree.getRowData();
       public Category getTreeCat() {
       return treeCat;
       public void setTreeCat(Category treeCat) {
       this.treeCat = treeCat;