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, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content