[hibernate-dev] Connection proxy error

Max Rydahl Andersen max.andersen at jboss.com
Mon Nov 6 06:54:04 EST 2006


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(BorrowedConnectionProxy.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.testBorrowedConnections(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




More information about the hibernate-dev mailing list