On 26 Nov 2010, at 11:05, Stefan Hagedorn wrote:

> Hi,
> 
> I am running my application that uses the Jackrabbit repository on a 
> Glassfish v3 application server. I am using jackrabbit-jca 2.1.0
> 
> In order to use jackrabbit ACLs I am doing
> 
> Session s = repo.login(...);
> UserManager umngr = ((JackrabbitSession) s).getUserManager();
> 
> But this cast is not possible and throws an exception:
> 
> java.lang.ClassCastException: org.apache.jackrabbit.jca.JCASessionHandle 
> cannot be cast to org.apache.jackrabbit.api.JackrabbitSession
> 
> 
> So, could anyone please tell me how to receive an JackrabbitSession object 
> (or any other way to get the user manager)?

Looks like JCA is putting a wrapper around the session, if JCASessionHandle 
does not have an exposed method to get the JackrabbitSession or the class 
definition that was used to create the JackrabbitSession is not available to 
the classloader you are working in then you might be able to do it with 
reflection. (IIRC Glassfish v3 is OSGi based, is JackrabbitSession exported 
from its bundle ?)

In Apache Sling (also OSGi based), AccessControlUtils in the server bundle does 
just this, although there isn't the added complexity of JCA.

HTH
Ian

> 
> Regards,
> Stefan

Reply via email to