0

I'm trying to use getResourceAsStream to load a java keystore albeit unsuccessfully. I'm not sure why it fails, but I'm loading it inside Play! 2.0 from a subfolder inside a typical folder.

Here's the folder structure and keystore location:

play root >> app >> subfolder1 >> keystore

And the location of the file I'm loading it from:

play root >> app >> subfolder1 >> scala.class

And how I am loading it inside scala.class:

getClass().getResourceAsStream("/keystore")

Any ideas as to what's going wrong?

crockpotveggies
  • 12,682
  • 12
  • 70
  • 140

1 Answers1

6

By prefacing the path with / you're asking for a keystore at the root of the package hierarchy. Try either of the following:

getClass.getResourceAsStream("/app/subfolder1/keystore")
getClass.getResourceAsStream("keystore")

See the Java documentation for more detail on how to specify resource paths.

Travis Brown
  • 138,631
  • 12
  • 375
  • 680
  • That did the trick, thanks! After some further fiddling I got it to also work by using `/keystore` and placing the keystore file in the conf folder (for those who need a Play 2.0 specific answer) – crockpotveggies Apr 16 '12 at 23:18