Hi Lincoln,
the class doing the loading is from a third party framework.
I use the framework via Maven dependency.
The class which should be loaded is a class of my plugin project.
And yes, its all packed in the plugin jar file.
I think the author of the 3rd party framework uses Class.forName(), because forName() should be accessed in a static way.
One more thing:
If I'm using the Forge Beta5, everything works, but I get a warning when installing my plugin via forge source-plugin (***WARNING*** Could not resolve dependency [some-jar:jar::${some.version}])
If I'm using a Forge snapshot version, I don't get the warning, but the class is not found.
I took a look at the dependencies folder for my plugin, for Forge Beta5 the "not-resolved"-dependencies are not in the dependencies folder. (But the plugin works, strange enough. Maybe because of the Maven shade?)
For Forge snapshot version all dependencies are in the dependencies folder. (But the class searched with Class.forName() is not found)
Some extra information:
At the moment, I'm using the Maven shade plugin to shade my dependencies.
If this is too confusing for you, I'll upload my source code, so you may have a look.
Best regards
Max
---
One thing that you must take into account is the fact that Forge uses a
modular ClassLoading environment called JBoss Modules. This means that
classes are isolated from each other.
The classpath of a typical java application if flat, where every class is
visible to every other class because there is only a single classloader.
That is not the case in Forge. In fact, classes have limited or no
visibility to many classloaders. This allows us to support multiple version
of the same class for use in many different plugins.
I need more information about your project. Is the class you are loading in
the same JAR as the class which is doing the loading? (Your plugin.) Also,
may I recommend instead using
`this.getClass().forName(...)`
>
Which says, "Start looking from the classloader of `this`," and anything
else that is in that classloader's hierarchy of visibility.
~Lincoln
Am 20.01.2012 17:49, schrieb Max Schwaab:
Hey there,
I try to get my plugin working and now I have the problem that
my plugin can't find one of its classes when I try to invoke the
default command.
The plugin does some stuff an finally a
Class.forName("org.hibersap.forge.plugin.FunctionModuleSearch")
Do you have any hints why Class.forName() can't find the class?
The message is
***ERROR*** [generate-sap-entities] Cannot find class
org.hibersap.forge.plugin.FunctionModuleSearch in classpath
The funny thing about this is, with Forge Beta 5 everything is
working fine, with the latest Forge snapshot I miss my class :\
This is all within the same Maven JAR plugin project. I'm using
a framework which is using the Class.forName() method. So
there's no way out of this :)
Must be something to do with the latest changes since Beta 5 is
published.
Thanks for your help,
best regards,
Max