Cannot access file contained in a deployment as a regular file in JBoss EAP 5 (Virtual File System / VFS)
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 ajava.io.File
. So, consider atest.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.