AnsweredAssumed Answered

How to use JCR  from other WAR? (hibernate lazy init)

Question asked by skoptelov on Nov 27, 2005
Latest reply on Dec 6, 2005 by jack
My use case is that I have JBoss installation with Alfresco WAR (from JBoss bundle)  and my EAR (EJB3 beans + WAR). I need to access Alfresco's JCR repository from my web application.

Alfresco's bundled Hibernate is incompatible with JBoss EJB3 deployer one's so I have to isolate Alfresco WAR classloader from UCL. The main problem is that repository impementation is hibernate-backed and hibernate uses lazy loading - tries to load objects (nodes and their properties) on client (my webapp) side.

Question is - how should I get reference to javax.jcr.Repository instance so that all   real work will be done in Alfresco WAR classes without trying to use my webapp classes?

I tried the following:
1. Simply put repository to JNDI and access it. Doesn't work because of  ClassCastExceptions - uses hibernate classes from my webapp classloader which are different from Alfresco's ones.
2. Put ejb3 deployer libs as shared (myserver/lib) and remove hibernate-related jars from alfresco so we'll both use same jars. Doesn't work because now I have to put ALL alfresco jars as shared for jboss server and I really don't want it.
3. Export Spring JCR.Repository bean through RMI. Doesn't work because of

Caused by: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.alfresco.jcr.util.JCRProxyFactory$SessionContextInvocationHandler

Outcomes