Classloading issue

Poster Content
nk4um Moderator
Posts: 755
September 28, 2009 09:18H2 Update
An updated version of H2 with Version 1.1.119 (2009-09-26) is now available in the repository.

P.
nk4um Moderator
Posts: 755
September 26, 2009 18:01Update
Hi Chris,

Good work pushing this with the H2 team.  I''m just doing some testing and will then post an update to the h2 package.

P.
nk4um User
Posts: 156
September 26, 2009 17:25Fixed in new h2 version
Hi guys,

The fix to this is included in 1.1.119 of h2.

Cheers,

Chris
nk4um User
Posts: 156
September 11, 2009 19:14Thanks and update
Thanks for your help with this Tony. I have now added a comment and a patch to the issue tracker for h2 for this (http://code.google.com/p/h2database/issues/detail?id=112).

Cheers,

Chris
nk4um Moderator
Posts: 485
September 8, 2009 12:48Update
After discussing this with Chris offline, he created a patch which he has submitted back to H2, which causes it to use the context classloader for loading these custom classes. On the NetKernel accessor side, we have made a change to set a request scope classloader as the context classloader. This then enables H2 to resolve triggers from the application module(s) in the request scope.

(This change will be in preview 6.7)

Tony
nk4um User
Posts: 156
September 5, 2009 13:23Bit more digging
Hi Tony,

Thanks for the information. I''ve dug into this a bit more and it looks like H2 is using Class.forName(className) (org.h2.util.ClassUtils.loadUserClass() - which is in the stack trace). Reading the javadocs, suggests that this is using this.getClass().getClassLoader() which the stack trace suggests is using org.netkernel.layer0.util.SpaceClassLoader. Any ideas on where to go with this next?

Cheers,

Chris
nk4um Moderator
Posts: 485
September 4, 2009 19:53It needs a RequestScopeClassLoader
Hi Chris,

I suspect it might be tricky. All the H2 classes will be loaded with the classloader in the RDBMS module. H2 will then be using that class loader either because it is the context classloader for the thread (most likely) or because it is using getClass().getClassLoader(). Either way that classloader doesn''t know about your modules classloader.

If it is using the context classloader then it might be possible to patch the rdbms module to specify a request scope classloader for H2 to use. That way it could search for classes from in all modules in the request stack.
(org.netkernel.layer0.util.RequestScopeClassLoader)

Could you give this a try? If that sounds a bit hairy then I''ll try and have a look into it.

Tony
nk4um User
Posts: 156
September 4, 2009 18:01Classloading issue
Hi guys,

I''m using H2 as one of my database implementations, and am trying to add some Java triggers (http://www.h2database.com/html/features.html#user_defined_functions). However, the classloader isn''t able to find my class unless I remove the H2 jar file from the RDBMS module, and add it to mine (which isn''t a viable solution!).

Any ideas how I can work around this?

Cheers,

Chris