[forge-dev] AeroGear: unable to load JPA classes
Ryan Bradley
rbradley at redhat.com
Fri Mar 2 10:43:28 EST 2012
On 03/02/2012 01:12 AM, Richard Kennard wrote:
> 5. Class loading: getClass().getResourceAsStream() works differently depending on which JAR the class was loaded from. So for example the
> getClass().getResourceAsStream() that lives inside metawidget.jar couldn't see the resources that were declared in my plugin.jar
Richard,
I've experienced this ClassLoader problem with my plugin as well. The
solution thus far has been to force the current thread to use of the
ScaffoldProvider's ClassLoader in the generateFromEntity() method. That
is, save the current thread's ClassLoader at the beginning of the
method, encapsulate the rest of the method in a try block (changing the
thread's class loader to that of the ScaffoldProvider), and add a
finally block which restores the original class loader.
The code can be found here:
https://github.com/forge/plugin-spring-mvc/blob/master/src/main/java/org/jboss/forge/scaffold/spring/SpringScaffold.java
Cheers,
Ryan
More information about the forge-dev
mailing list