powered by Jive Software

PluginClassLoader failing to resolve class resources


#1

Trying to write a plugin for open fire. While I was able to get the plugin up and running using the how to guides, it appears that a java class resource file that i need is not able to be resolved at run time. I’ve tried everything i can think of to try and resolve the resource file to no avail.
Thread.currentThread().getContextClassLoader().getResources(…)
MyClass.class.getClassLoader().getResources(…)
MyClass.class.getClassLoader().getParent().getResources(…)
ClassLoader.getSystemClassLoader().getResources(…)

I think there may be something out of the ordinary with the PluginClassLoader.

Within my plugin jar. I have something like this
lib/myOpenfireplugin.jar
lib/myjarWithResources.jar

So resolving java classes in myjarWithResources works just fine, but loading configuration files, etc as class resources does not. Am i missing something?


#2

The plugin class loader is fine; it’s more likely that your resource is in the wrong location. I’d expect something like

myOpenfireplugin/lib/myOpenfireplugin.jar
myOpenfireplugin/lib/myjarWithResources.jar
myOpenfireplugin/classes/myProperties.properties

#3

My resources are here:

myOpenfireplugin/lib/myjarWithResources.jar/com/mycompany/config.properties

And a class within that jar is failing to load the resource file within the same jar. This same configuration works everywhere else, including osgi containers. So it is not the “wrong” location. The classloader is broken