I'm trying to run a test that uses a resource in sbt. The test depends on a util that loads a resource via ClassLoader.getSystemResourceAsStream(...)
, which results unexpectedly in null
. If I run the same test in Intellij or via bazel, the test succeeds. I additionally performed a test by creating a main class to list all resources according to the ResourceList
example given in an answer to this question, and this confirmed that that file and many others were inaccessible at runtime.
These resources are not contained in the resources
directories that sbt usually uses; they are contained in a jar file that is included in the lib
directory. The sources in my project built by sbt depend heavily on this jar, and compilation is successful, so it appears the issue may be specific to resources. One thing I noticed is that the resource can be loaded if I use a ClassLoader
object and call getResourceAsStream
instead of using the static method ClassLoader.getSystemResourceAsStream
.
Does anyone know how to resolve this issue (short of copying out all resources from the jar file in lib
)?