Cannot access file contained in a deployment as a regular file in JBoss EAP 5 (Virtual File System / VFS)
Issue
- A
FileNotFoundExceptionis 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.propertiesfile in a/configdirectory 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.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
