We have a Scala web application using Finagle, where we try to read some files from the classpath. It works in the unit test environment, but when assembled and run from Intellij Idea we get a nullpointer exception because it can't read the file. I tried different versions
val s = Thread.currentThread().getContextClassLoader.getResourceAsStream("env.txt")
val parent = Thread.currentThread().getContextClassLoader.getParent()
val s2 = parent.getResourceAsStream("env.txt")
val s3 = this.getClass.getResourceAsStream("env.txt")
val s4 = ClassLoader.getSystemResourceAsStream("env.txt")
It all fails with a nullpointer exception, which I interpret it can't find the files on the classpath.
To start the assembled jar I run:
java -classpath temp-conf -jar project-app/target/scala-2.12/cea-app.jar
Someone has a clue?