This is not a Storm issue but a Java one, and you should definitively use 'getResourceAsStream' since you file is not a file: it's included in a JAR hence the ! in the URL. A solution is to extract this resource in a temporary file then use it.
2014-08-04 13:33 GMT+02:00 Yaron Rosenbaum <ya...@whatson-social.com>: > Hi > > I'm trying to read resource files in one of my bolts. > The resource files reside under '/profiles' within my JAR (verified). > > I'm using com.google.common.io.Resources like this: > URL profilesUrl = Resources.getResource("profiles"); > The returned URL (.toString) equals : > jar:file:/Users/.../storm/target/storm-1.0-SNAPSHOT.jar!/profiles > > Same result with: > URL profilesPath = > Thread.currentThread().getContextClassLoader().getResource("profiles"); > > Note the exclamation point (!) after '.jar'. > This is of course a malformed URL, which results in a > MalformedUrlException when I try to use this URL to open a file (a folder > in my case). > > Searching through stackOverflow, I've seen cases where people recommended > using .getResourceAsStream for a file within a jar, but unfortunately the > library that I'm using requires the path string of the resource, and not a > stream. > > Obviously people are reading resource files while using Storm, so I must > be doing something wrong. > > Thank you > (Y) > >