Cannot access file contained in a deployment as a regular file in JBoss EAP 5 (Virtual File System / VFS)

Solution Verified - Updated -

Issue

  • A FileNotFoundException is thrown when trying to read a file from an archive. After finding the file location via the classloader, an attempt is made to open it as a java.io.File. So, consider a test.properties file in a /config directory in a war. The following will not work to load the properties:
URL configFilesBaseURL = Thread.currentThread().getContextClassLoader().getResource("/config");
String configFilesBaseLocation = configFilesBaseURL.getFile();
File configProp = new File(configFilesBaseLocation + "test.properties");
Properties props = new Properties();
if (configProp != null) {
    props.load(new FileInputStream(configProp));
}
  • Jboss EAP 4.3 to 5.1 issues with properties loading.

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 5.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.