Getting resource from plugin only works after restart


In my Jira-plugin I’m trying to load a resource. When the plugin is installed it doesn’t work, but after a restart of Jira everthing works fine. I have tried the following methods with various getClass-methods. All with the same result.

String resource = "/resource.tmp"; // Located in /src/resources
InputStream in = getClass().getClassLoader().getResourceAsStream(resource);

InputStream in = com.atlassian.core.util.ClassLoaderUtils.getResourceAsStream(resource, this.getClass());

InputStream in = ComponentAccessor.getPluginAccessor().getDynamicResourceAsStream(resource);

InputStream in = webwork.util.ClassLoaderUtils.getResourceAsStream(resource, MailSender.class);

I’m using Spring Scanner version 2.1.8