Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8822519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:07:33+00:00 2026-06-14T06:07:33+00:00

I have a project using JSF primefaces and EJB managed Beans with hibernate storage.

  • 0

I have a project using JSF primefaces and EJB managed Beans with hibernate storage.
http://www.primefaces.org/showcase/ui/treeAjax.jsf

Question: I keep on getting a out of memory or stack overflow errors can you see a problem with my recursion?

@ManagedBean(name = "categoryController")
@RequestScoped
public class CategoryController implements Serializable {
    ...

    @EJB
    private CategoryFacade ejbFacade;
    private TreeNode root;

    public TreeNode getRoot() {
        return root;
    }

    @PostConstruct
    public void init() {
        root = new DefaultTreeNode("Root", null);
        System.out.print("Facade value=" + getFacade());
        Category categoryRoot = getFacade().find(new Integer(1));
        getSubcategories(categoryRoot, root);

    }

    private void getSubcategories(Category categoryRoot, TreeNode root) {
        List<Category> list = getFacade().findByNamedQuery("Category.findByPCatid", "pcatid", categoryRoot);
        Iterator<Category> it = list.iterator();
        while (it.hasNext()) {
            Category subcategory = it.next();
            TreeNode nextNode = new DefaultTreeNode(subcategory.getUcatid(), root);
            getSubcategories(subcategory, nextNode);

        }

    }

    ...
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:07:34+00:00Added an answer on June 14, 2026 at 6:07 am

    The problem is that your recursion is in an infinite loop on your root element.
    try adding this:

    if (!subcategory.getCatid().equals(new Integer(1))) {
         getSubcategories(subcategory, nextNode);
    }
    

    You can also look up the Primefaces event listeners to generate the tree on demand.
    http://www.primefaces.org/showcase/ui/treeEvents.jsf

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made a jsf project and have the following example from http://docs.openlayers.org/library/introduction.html but as
I am using JSF + PrimeFaces in my project. I have prepared a Maven
So I have imported a project to netbeans. I am using jsf and xhtml
I am working on project in JSF, using Tomcat 7. The application will have
I am doing a project where I am using JSF 2.0 & Primefaces UI
We have faces-config.xml in JSF 1.0 where we entry about managed-beans, dependencies & navigations
I'm working on a JSF 2.0 project using Mojarra, PrimeFaces and Tomcat 6.x, but
I have a problem with following tutorial: http://www.mkyong.com/jsf2/jsf-2-internationalization-example/ In faces-context file you have to
I am using JSF 2.0 and PrimeFaces. I have a selectOneMenu and a selectManyCheckbox.
i am using integration of jsf hibernate spring primfaces in my project. i want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.