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

  • SEARCH
  • Home
  • 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 7181695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:36:41+00:00 2026-05-28T17:36:41+00:00

I implemented a tree with an outputResource as content (see Downloading file from IceFaces

  • 0

I implemented a tree with an outputResource as “content” (see Downloading file from IceFaces tree).

However, when I try to download a file (I have only txt or csv files) I get the HTTP 500 Status error.

The tree structure is something like

  Root
  |-infoFiles
  | |-A.csv
  | |-B.csv
  |-validateFiles
  | |-C.txt
  | |-D.txt

And the exception once I click on the resource is

java.io.FileNotFoundException: C:\SRC\dataFiles\998\validateFiles (Access denied)
    java.io.FileInputStream.open(Native Method)
    java.io.FileInputStream.<init>(FileInputStream.java:138)
    java.io.FileInputStream.<init>(FileInputStream.java:97)
    mx.gob.sagarpa.utilidades.FileResource.open(FileResource.java:39)
    com.icesoft.faces.component.outputresource.RegisteredResource.open(OutputResource.java:474)
    com.icesoft.faces.context.ResourceRegistryLocator$DynamicResourceDispatcherAdapter$DynamicResourceAdapter.open(ResourceRegistryLocator.java:117)
    org.icefaces.impl.push.DynamicResourceDispatcher$ResourceServer.respond(DynamicResourceDispatcher.java:224)
    org.icefaces.impl.push.DynamicResourceDispatcher$ResourceServer.handleResourceRequest(DynamicResourceDispatcher.java:201)
    org.icefaces.impl.push.DynamicResourceDispatcher$Mapping.handleResourceRequest(DynamicResourceDispatcher.java:370)
    org.icefaces.impl.push.DynamicResourceDispatcher.handleResourceRequest(DynamicResourceDispatcher.java:89)
    org.icefaces.application.ResourceRegistry.handleResourceRequest(ResourceRegistry.java:75)
    org.icefaces.impl.application.WindowScopeManager.handleResourceRequest(WindowScopeManager.java:165)
    javax.faces.application.ResourceHandlerWrapper.handleResourceRequest(ResourceHandlerWrapper.java:125)
    javax.faces.application.ResourceHandlerWrapper.handleResourceRequest(ResourceHandlerWrapper.java:125)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:591)
    org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)

Sometimes it happens just with csv files and sometimes even with txt

Tree.xhtml

                <ice:tree id="tree"
                          value="#{treeBean.model}"
                          var="item"
                          hideRootNode="false"
                          hideNavigation="false"
                          >
                    <ice:treeNode>
                        <f:facet name="icon">
                            <ice:panelGroup style="display: inline">
                                <h:graphicImage value="#{item.userObject.icon}" />
                            </ice:panelGroup>
                        </f:facet>
                        <f:facet name="content">
                            <ice:panelGroup style="display: inline-block">
                                <ice:outputResource resource="#{item.userObject.resource}"
                                                    fileName="#{item.userObject.resource.filename}"
                                                    mimeType="#{item.userObject.resource.mimeType}"
                                                    />
                            </ice:panelGroup>
                        </f:facet>
                    </ice:treeNode>
                </ice:tree>

TreeBean.java

@ManagedBean
@ViewScoped
public class TreeBean implements Serializable {

private DefaultTreeModel model;
public final String openFolderImg = "./img/tree_folder_open.gif";
public final String closeFolderImg = "./img/tree_folder_close.gif";
public final String fileImg = "./img/tree_document.gif";
@ManagedProperty("#{userBean}")
private UserBean userBean;

@PostConstruct
public void init() {
    // create root node with its children expanded
    DefaultMutableTreeNode rootTreeNode = new DefaultMutableTreeNode();
    FileResourceUserObject rootObject = new FileResourceUserObject(rootTreeNode);
    rootObject.setText("Sistema de Rendición de Cuentas");
    rootObject.setExpanded(true);
    rootObject.setResource(new FileResource("Sistema de Rendición de Cuentas", null));
    rootObject.setBranchContractedIcon(openFolderImg);
    rootObject.setBranchExpandedIcon(closeFolderImg);
    rootTreeNode.setUserObject(rootObject);

    // model is accessed by the ice:tree component
    model = new DefaultTreeModel(rootTreeNode);
    File f = new File("./998/");
    createTree(f, rootTreeNode);
}

public DefaultTreeModel getModel() {
    return model;
}

public UserBean getUserBean() {
    return userBean;
}

public void setUserBean(UserBean userBean) {
    this.userBean = userBean;
}

private void createTree(File fileRoot, DefaultMutableTreeNode treeRoot) {
    File[] files = fileRoot.listFiles();
    DefaultMutableTreeNode branchNode;
    for (File f : files) {
        if (f.isDirectory()) {
            branchNode = new DefaultMutableTreeNode();
            FileResourceUserObject branchObject = new FileResourceUserObject(branchNode);
            branchObject.setExpanded(false);
            branchObject.setText(f.getName());
            branchObject.setResource(new FileResource(f.getName(), f.getAbsolutePath()));
            branchObject.setBranchContractedIcon(openFolderImg);
            branchObject.setBranchExpandedIcon(closeFolderImg);
            branchNode.setUserObject(branchObject);
            treeRoot.add(branchNode);
            createTree(f, branchNode);
        }
        if (f.isFile()) {
            branchNode = new DefaultMutableTreeNode();
            FileResourceUserObject branchObject = new FileResourceUserObject(branchNode);
            branchObject.setText(f.getName());
            branchObject.setResource(new FileResource(f.getName(), f.getAbsolutePath()));
            branchObject.setLeaf(true);
            branchObject.setLeafIcon(fileImg);
            branchNode.setUserObject(branchObject);
            treeRoot.add(branchNode);
        }
    }

    return;
}

}

FileResourceUserObject.java

public class FileResourceUserObject extends IceUserObject{

    private FileResource resource;

    public FileResourceUserObject(DefaultMutableTreeNode wrapper) {
        super(wrapper);
    }

    public FileResource getResource() {
        return resource;
    }

    public void setResource(FileResource resource) {
        this.resource = resource;
    }

}

FileResource.java

public class FileResource implements Resource{

    private String filename;
    private String fileAbsolutePath;
    private String mimeType;
    ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();

    public FileResource(String filename, String fileAbsolutePath) {
        this.filename = filename;
        this.fileAbsolutePath = fileAbsolutePath;
        this.mimeType = ec.getMimeType(filename);
    }

    @Override
    public String calculateDigest() {
        return filename;
    }

    @Override
    public InputStream open() throws IOException {
        return new FileInputStream(fileAbsolutePath);
    }

    @Override
    public Date lastModified() {
        return new Date();
    }

    @Override
    public void withOptions(Options optns) throws IOException {

    }

    public String getFileAbsolutePath() {
        return fileAbsolutePath;
    }

    public void setFileAbsolutePath(String fileAbsolutePath) {
        this.fileAbsolutePath = fileAbsolutePath;
    }

    public String getFilename() {
        return filename;
    }

    public void setFilename(String filename) {
        this.filename = filename;
    }

    public String getMimeType() {
        return mimeType;
    }

}

UPDATE

What I noticed was that when I get the 500 Status Error the FileNotFoundException is always pointing to the same path java.io.FileNotFoundException: C:\SRC\dataFiles\998\validateFiles (Access denied)
I’m starting to think that all my FileResources are pointing to the same path… why is this happening?

  • 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-05-28T17:36:42+00:00Added an answer on May 28, 2026 at 5:36 pm

    There was a report of a bug on the IceFaces page where it says that using multiple outputResource tags had a strange behavior. See this link http://jira.icefaces.org/browse/ICE-3667
    I think this was happening with I had the tree and many outputResource tags.

    Moreover, I also read that using the outputResource tag it creates an Object at render time (or something like that I’m very new to JSF and all the stuff related) and it was memory-cpu consuming and it was better to use a servlet to perform the download. See http://www.dantoomeysoftware.com/pencils-down/2009/09/08/dont-use-icefaces-resource-for-download-use-a-download-servlet/

    So it’s better to implement a servlet, you can find useful info in http://balusc.blogspot.com/2007/07/fileservlet.html and (if your are new to all this stuff) Custom download servlet

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

Sidebar

Related Questions

I have an own Tree object implemented in PHP. Say we have a tree
I have a Red Black tree implemented in c++ . It supports the functionality
We have a tree structure implemented using the DefaultMutableTreeNode specified in Java. Is there
I have implemented a binary heap as a tree, and tree node is as
I have implemented a binary search tree and I want to add more functionality
I have implemented an iterative algorithm, where each iteration involves a pre-order tree traversal
I have a Binary Search Tree that I'm making and I implemented the Insert
I have a working tree model derived from QAbstractItemModel and I wish to filter
I'm trying to implement tree algorithms in C. I have declared a extern struct
I would like to implement an B+ tree in Java and try to optimize

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.