You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Robert Morse <rm...@mdesignz.com> on 2009/04/12 00:08:23 UTC
Classloader Issue?
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)
Re: Classloader Issue?
Posted by Robert Morse <rm...@mdesignz.com>.
Nevermind!
I had an errant copy of jcr-1.0.jar in my EJB. My final working
configuration, in order to close this issue:
jackrabbit-jca-1.5.4.jar, jackrabbit-jcr-rmi-1.5.0.jar, and
jcr-1.0.jar in $JBOSS_HOME/server/default/lib
jackrabbit-jca-1.5.4.rar, jackrabbit-werver.war, jcr-ds.xml in
$JBOSS_HOME/server/default/deploy
NO jackrabbit components in the EAR, EJB or WEB packages. Referenced
as <scope>provided</scope> in the Maven dependencies.
Sorry for the noise.
-robert.
On Apr 11, 2009, at 4:08 PM, Robert Morse wrote:
> 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)
>
>
>
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)