Hello!

I've run into a problem in getting a Session for Jackrabbit.
My environment:
Jackrabbit 1.5.4, JBoss 4.2.3.GA (jdk6), Mac OS x 10.5.6, MySql, Seam 2.1.1.GA
This is an EAR deployment.

I followed the steps in the Wiki for getting Jackrabbit running (http://wiki.apache.org/jackrabbit/JackrabbitOnJBoss ), and it appears to be working. I can also connect via WebDav to the repository using Mac's normal facilities. I'm mentioning this only to establish that I think JackRabbit is installed and
running correctly.

Further in the Wiki entry, it describes accessing the Repository via JNDI, and this is where I run into a snag. After some trial and error, I have the following
deployed:

jackrabbit-jcr-rmi-1.5.0.jar, jcr-1.0.jar in $JBOSS_HOME/server/ default/lib. jackrabbit-jca-1.5.4.rar, jackrabbit-server.war, jcr-ds.xml and my application EAR in $JBOSS_HOME/server/default/deploy

If I follow the Wiki example exactly, I get:

15:06:01,802 ERROR [STDERR] java.lang.ClassCastException: org.apache.jackrabbit.jca.JCARepositoryHandle cannot be cast to javax.jcr.Repository

during the
Repository repo = (Repository) ctx.lookup("java:jcr/local") ;

So, I made the "obvious" choice and changed the type to JCARepositoryHandle,

JCARepositoryHandle jrh = (JCARepositoryHandle) ctx.lookup("java:jcr/ local") ;

and got this.  This error makes no sense to me.

15:13:36,004 ERROR [STDERR] java.lang.ClassCastException: org.apache.jackrabbit.jca.JCARepositoryHandle cannot be cast to org.apache.jackrabbit.jca.JCARepositoryHandle

Here's the original (broken) code that tries to get a Session. It fails with the first exception. Not sure what I'm missing, but would appreciate any and all comments and pointers. Thanks!


static public Session getJackrabbitSession() throws RepositoryException
   {
      Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      env.put(Context.PROVIDER_URL, "jnp://localhost:1099");
env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");

      try
      {
         InitialContext ctx = new InitialContext(env);
         Repository repo = (Repository) ctx.lookup("java:jcr/local");
Credentials cred = new SimpleCredentials("user", new char[] { 'p', 'w', 'd' });
         return repo.login(cred);
      }
      catch (NamingException ex)
      {
         ex.printStackTrace();
      }
      return null;
   }







The human mind is an iterative processor, it never does anything right the first time. What it does well is to make improvements on every iteration (deMarco)



Reply via email to