You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by test123456 <sa...@thinkcoretech.com> on 2010/01/05 08:47:06 UTC

ClassCastException in tomcat 6


I am trying to setup content repository using the jackrabbit  and tomcat 6
server.

I put the jackrabbit.war file into the webapps.

I have a new test project which will access the jackrabbit.war through the
JNDI lookup.

In server.xml i have a global jndi resource.
and the tomcat lib directory contain all the required jar files.

In the test project , i am able to get the JNDI resource and lookup()
returns a org.apache.jackrabbit.core.jndi.BindableRepository object

When i try to cat this to org.apache.jackrabbit.api.jsr283.Repository object
, it throws the ClassCastException .

What will e thr problem.. i am not able to find out where it went wrong..



-- 
View this message in context: http://old.nabble.com/ClassCastException-in-tomcat-6-tp27024798p27024798.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ClassCastException in tomcat 6

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Peter,

On 1/5/2010 2:56 AM, Peter Crowther wrote:
> 2010/1/5 test123456 <sa...@thinkcoretech.com>
> 
>> I put the jackrabbit.war file into the webapps.
>>
>> I have a new test project which will access the jackrabbit.war through the
>> JNDI lookup.
>>
>> In server.xml i have a global jndi resource.
>> and the tomcat lib directory contain all the required jar files.
>>
>> In the test project , i am able to get the JNDI resource and lookup()
>> returns a org.apache.jackrabbit.core.jndi.BindableRepository object
>>
>> When i try to cat this to org.apache.jackrabbit.api.jsr283.Repository
>> object
>> , it throws the ClassCastException .
>>
>> I suspect you have the same class defined twice: once in jackrabbit.war,
> once in Tomcat's lib directory.  The version loaded by JNDI will be from
> lib, the version from the webapp will be the one from jackrabbit.war.
> Because they are loaded by different classloaders, they are *different*
> classes and are not castable even though they have the same name.
> 
> If this is the issue: to fix it, ensure no duplicate classes are defined.
> This may require removing a number of jars from the war file.

The easiest thing to do if you need the classes in both Tomcat (for JNDI
binding) and your webapp (so you can use the JNDI resource) is to place
the jackrabbit.jar file into a commons ClassLoader such as
CATALINA_BASE/lib for Tomcat 6.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAktDrwsACgkQ9CaO5/Lv0PCIyACgjvIfbPbzgSNEATjUo6wzcNVr
cKYAn0xSa8G2DZrUejddBRdU4AexCmMh
=chZO
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ClassCastException in tomcat 6

Posted by Peter Crowther <pe...@melandra.com>.
2010/1/5 test123456 <sa...@thinkcoretech.com>

> I put the jackrabbit.war file into the webapps.
>
> I have a new test project which will access the jackrabbit.war through the
> JNDI lookup.
>
> In server.xml i have a global jndi resource.
> and the tomcat lib directory contain all the required jar files.
>
> In the test project , i am able to get the JNDI resource and lookup()
> returns a org.apache.jackrabbit.core.jndi.BindableRepository object
>
> When i try to cat this to org.apache.jackrabbit.api.jsr283.Repository
> object
> , it throws the ClassCastException .
>
> I suspect you have the same class defined twice: once in jackrabbit.war,
once in Tomcat's lib directory.  The version loaded by JNDI will be from
lib, the version from the webapp will be the one from jackrabbit.war.
Because they are loaded by different classloaders, they are *different*
classes and are not castable even though they have the same name.

If this is the issue: to fix it, ensure no duplicate classes are defined.
This may require removing a number of jars from the war file.

- Peter