[hibernate-dev] Connection proxy error

Steve Ebersole steve.ebersole at jboss.com
Mon Nov 6 08:11:46 EST 2006


Context classloader can be null...

-----Original Message-----
From: hibernate-dev-bounces at lists.jboss.org
[mailto:hibernate-dev-bounces at lists.jboss.org] On Behalf Of Max Rydahl
Andersen
Sent: Monday, November 06, 2006 5:54 AM
To: hibernate-dev at lists.jboss.org
Subject: [hibernate-dev] Connection proxy error

Hi Steve,

After updating from svn I get the following in alot of tests:

java.lang.IllegalArgumentException: interface  
org.hibernate.jdbc.ConnectionWrapper is not visible from class loader
	at java.lang.reflect.Proxy.getProxyClass(Proxy.java:331)
	at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:552)
	at  
org.hibernate.jdbc.BorrowedConnectionProxy.generateProxy(BorrowedConnect
ionProxy.java:56)
	at  
org.hibernate.jdbc.ConnectionManager.borrowConnection(ConnectionManager.
java:163)
	at
org.hibernate.jdbc.JDBCContext.borrowConnection(JDBCContext.java:111)
	at
org.hibernate.impl.SessionImpl.connection(SessionImpl.java:359)
	at  
org.hibernate.test.connections.AggressiveReleaseTest.testBorrowedConnect
ions(AggressiveReleaseTest.java:210)

I fixed it by changing:

public static Connection generateProxy(ConnectionManager  
connectionManager) {
		BorrowedConnectionProxy handler = new  
BorrowedConnectionProxy( connectionManager );
		return ( Connection ) Proxy.newProxyInstance(
		        Connection.class.getClassLoader(),
		        PROXY_INTERFACES,
		        handler
		);
	}

to

public static Connection generateProxy(ConnectionManager  
connectionManager) {
		BorrowedConnectionProxy handler = new  
BorrowedConnectionProxy( connectionManager );
		return ( Connection ) Proxy.newProxyInstance(
	
Thread.currentThread().getContextClassLoader(),
		        PROXY_INTERFACES,
		        handler
		);
	}

Connection.class is always loaded via the boot/system clasloader so I  
don't get how using its classloader
when generating the proxy would ever work ?

-- 
--
Max Rydahl Andersen
callto://max.rydahl.andersen

Hibernate
max at hibernate.org
http://hibernate.org

JBoss a division of Red Hat
max.andersen at jboss.com

_______________________________________________
hibernate-dev mailing list
hibernate-dev at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev




More information about the hibernate-dev mailing list