Prefix it with a forward slash to denote the root of the classpath:
getResourceAsStream("/my_filename.txt")
Alternatively, you can use the serlvetContext.getResourceAsStream(..)
which looks for resources relative to the context root. So classes would be /WEB-INF/classes
.