The problem with Alfresco 2.1 is the result of an update made by Steve Ebersole to Hibernate 3 in November of 2006:
Author: steve.ebersole at jboss.com
Date: 2006-11-03 11:23:21 -0500 (Fri, 03 Nov 2006)
New Revision: 10715
The change added a new ConnectionWrapper interface and modified the BorrowedConnectionProxy class to include the new interface in its list of proxied interfaces. Unfortunately, this change breaks Russ Danner's JCR JNDI bridge since Hibernate attempts to load the ConnectionWrapper interface from the calling thread's ContextClassLoader. The interface, of course, is not accessible since it lives in the Hibernate jar within the classloader for the Alfresco web application.
One workaround for this issue is to remove the ConnectionWrapper class from the PROXY_INTERFACES array in BorrowedConnectionProxy. I have tested this solution on Tomcat by placing the modified class into the classes directory within the Alfresco WEB-INF directory to override the original hibernate class.
While the above solution works, it might cause issues if the ConnectionWrapper interface is being used somewhere within Alfresco to access the underlying JDBC connection. This impact of this change is not clear since I do not fully understand the reasoning behind Steve Ebersole's change.
Another possible solution might be to extract the ConnectionWrapper interface from the Hibernate jar and place it into a class loader visible across applications. I have not tested this solution but expect it would also work.
The final solution that comes to mind would be to swap out the Thread ContectClassloader before calling the Alfresco JCR interface. This seems like the better solution but I have not worked through the details of how this might be implemented.
David