Atomikos Forum

Atomikos essentials and OSGi

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
Peter Fischer Send private email
Wednesday, September 10, 2008
 
 
Hi,

Thanks for the feedback.

Actually, we had similar issues with customers. Therefore our upcoming 3.3.4 release will behave like this:

-first try to use the ThreadContext class loader
-the resort to the driver's class loader

Would that work for your case?

Thanks
Guy Pardon Send private email
Wednesday, September 10, 2008
 
 
Hello,

this should also work.

Thank you!

Peter
Peter Fischer Send private email
Friday, September 12, 2008
 
 
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
Peter Fischer Send private email
Wednesday, September 24, 2008
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics