Atomikos Forum |
|
Hello,
I try to use Atomikos essentials 3.3.3 in a spring-dm/OSGi environment, but I get no connection. As reason I found this exception: java.lang.IllegalArgumentException: interface com.atomikos.datasource.pool.Reapable is not visible from class loader when AtomikosConnectionProxy#newInstance is called from ConnectionPool#borrowConnection. ClassLoading in an OSGi-enviroment differs from the standard. So I played with the line "return (Reapable) Proxy.newProxyInstance(c.getClass().getClassLoader(), interfaceClasses , proxy); " and changed it into " try { return (Reapable) Proxy.newProxyInstance(c.getClass().getClassLoader(), interfaceClasses , proxy); } catch (Exception ex) { return (Reapable) Proxy.newProxyInstance(AtomikosConnectionProxy.class.getClassLoader(), interfaceClasses , proxy); } " With this change everything works fine in my OSGi-environment. Is is possible to integrate my change into the next release? regards Peter
Hello,
I tried version 3.3.4, but I still get the same Exception. Is is possible not to use Thread.currentThread().getContextClassLoader()? I tought that it should work without testing it, but it is wrong. Sorry! :( try { return (Reapable) Proxy.newProxyInstance(AtomikosConnectionProxy.class.getClassLoader(), interfaceClasses , proxy); } catch (Exception ex) { return (Reapable) Proxy.newProxyInstance(c.getClass().getClassLoader(), interfaceClasses , proxy); } Works fine for me. The reason is that the contextClassloader is not the OSGi-Classloader that had not loaded the AtomikosConnectionProxy.class. regards, Peter |