[forge-users] Plugin Problems when using Class.forName()

Lincoln Baxter, III lincolnbaxter at gmail.com
Fri Jan 20 12:12:09 EST 2012


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

On Fri, Jan 20, 2012 at 11:49 AM, Max Schwaab <max.schwaab at akquinet.de>wrote:

>  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
>
> _______________________________________________
> forge-users mailing list
> forge-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/forge-users
>
>


-- 
Lincoln Baxter, III
http://ocpsoft.com
http://scrumshark.com
"Keep it Simple"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/forge-users/attachments/20120120/e43e9db8/attachment.html 


More information about the forge-users mailing list