This content has been marked as final.
Show 1 reply
-
1. Re: JBoss AS 6 - load resource from WAR file
cybro Jul 24, 2013 6:57 AM (in response to cybro)Ok, it seems I've really been missing crucial understanding of how WAR files are structured, and supposed to work.
When a WAR is loaded by the classloader, only the WARs "/WEB-INF/classes" and "/WEB-INF/lib" are added to the loaders classpath, but NOT the root.
That is what made the difference between JBoss 4.2.x and 6.x - the older versions of JBoss (pre 5.x) didn't hold to that convention, and put the WARs root directory on the classpath.
So, to provide a quick fix, just add some double dots to your path and be happy: "path/file.txt" -> "../../path/file.txt"
You could also move the resources to your SRC directory, so they get moved to WEB-INF/classes, or modify your build process to get it from somewhere else.