You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Stefan Hagedorn <na...@gmx.de> on 2010/11/26 12:05:45 UTC

Get JackrabbitSession with Jackrabbit-JCA on Glassfish

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)?

Regards,
Stefan

Re: Get JackrabbitSession with Jackrabbit-JCA on Glassfish

Posted by Ian Boston <ie...@tfd.co.uk>.
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