Search code examples
javaresourcesjarfantom

Why can't Fantom find the resource in a jar?


I've recently gotten started using Fantom. I've got a jar file that contains a resource (svg image, in this case). I can use the classes from the jar just fine, but the resource won't load: Thread.currentThread().getContextClassLoader().getResourceAsStream("name") returns null. When I use this exact same jar in a Java-only context, it can find the resource just fine.

Any suggestions on how to debug or even solve this issue would be much appreciated.


Solution

  • The wrong part is Thread.currentThread().getContextClassLoader()

    Java: AnyClassFromJar.class.getClassLoader() works

    Fantom: Class.forName("AnyClassFromJar").getClassLoader() should work