cancel
Showing results for 
Search instead for 
Did you mean: 

Problem accessing JCR via JNDI in Alfresco 2.1

snavarrob
Champ in-the-making
Champ in-the-making
Hi,

I've followed the article http://issues.alfresco.com/browse/AR-1131 in order to access JCR via JNDI. It works in Alfresco 2.0, but when I've tried the same in Alfresco 2.1, it doesn't work. I've gotten the following error:

org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is java.lang.IllegalArgumentException: interface org.hibernate.jdbc.ConnectionWrapper is not visible from class loader
   org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:525)
   org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:349)
   org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:255)
   org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:102)
   org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
   org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
   $Proxy29.authenticate(Unknown Source)
   org.alfresco.jcr.repository.RepositoryImpl.login(RepositoryImpl.java:217)
   org.alfresco.jcr.repository.RepositoryImpl.login(RepositoryImpl.java:246)
…..

Anyone could help me?

Thanks and regards,
Saul
2 REPLIES 2

davidtaylor
Champ in-the-making
Champ in-the-making
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

daniel_robert
Champ in-the-making
Champ in-the-making
Has anyone done any further research into this matter?  We're using JCR through JNDI right now with version 2.0.1E, and we're stuck trying to upgrade to 2.1.2E until we can get around this problem.

I'm currently implementing one of Mr. Taylor's solutions:  I've removed the org/hibernate/jdbc/ConnectionWrapper.class file from hibernate-3.2.1.jar and added it to $CATALINA_HOME/common/classes/org/hibernate/jdbc, and it seems to be working.  This is fairly gross (for lack of a better description), and I worry about our ability to upgrade in the future.

What are other people doing for this?