You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Stefano Mazzocchi <st...@apache.org> on 2000/09/11 19:09:37 UTC

[C2|bug] weirdest bug ever

With latest C2 and latest Catalina from CVS, with all jars in the
classpath (otherwise it doesn't even compile the sitemap) I get

java.lang.ClassCastException
	at
org.apache.cocoon.sitemap.SitemapHandler.run(SitemapHandler.java:147)
	at java.lang.Thread.run(Thread.java:479)

After accessing the /cocoon/welcome page.

The strange thing that sitemap IS compiled and javap tells me that it is
an instance of Sitemap, but at runtime it doesn't.

This is both the same on JDK 1.2.2 and JDK 1.3 (on win2k)

and this code added to SitemapHandler right before the class cast is
performed 

Class c = s.getClass().getSuperclass();
System.out.println("superclass: " + c.getName());
Class[] cs = c.getInterfaces();
for (int i = 0; i < cs.length ; i++) {
    System.out.println(cs[i]);
}
System.out.println("instance of Sitemap: " + (s instanceof
org.apache.cocoon.sitemap.Sitemap));

returns

superclass: org.apache.cocoon.sitemap.AbstractSitemap
interface org.apache.cocoon.sitemap.Sitemap
instance of Sitemap: false

what the hell is going on?

-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<st...@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Missed us in Orlando? Make it up with ApacheCON Europe in London!
------------------------- http://ApacheCon.Com ---------------------


Re: [C2|bug] weirdest bug ever

Posted by Giacomo Pati <Gi...@pwr.ch>.
Stefano Mazzocchi wrote:
> 
> With latest C2 and latest Catalina from CVS, with all jars in the
> classpath (otherwise it doesn't even compile the sitemap) I get
> 
> java.lang.ClassCastException
>         at
> org.apache.cocoon.sitemap.SitemapHandler.run(SitemapHandler.java:147)
>         at java.lang.Thread.run(Thread.java:479)
> 
> After accessing the /cocoon/welcome page.
> 
> The strange thing that sitemap IS compiled and javap tells me that it is
> an instance of Sitemap, but at runtime it doesn't.
> 
> This is both the same on JDK 1.2.2 and JDK 1.3 (on win2k)
> 
> and this code added to SitemapHandler right before the class cast is
> performed
> 
> Class c = s.getClass().getSuperclass();
> System.out.println("superclass: " + c.getName());
> Class[] cs = c.getInterfaces();
> for (int i = 0; i < cs.length ; i++) {
>     System.out.println(cs[i]);
> }
> System.out.println("instance of Sitemap: " + (s instanceof
> org.apache.cocoon.sitemap.Sitemap));
> 
> returns
> 
> superclass: org.apache.cocoon.sitemap.AbstractSitemap
> interface org.apache.cocoon.sitemap.Sitemap
> instance of Sitemap: false
> 
> what the hell is going on?
> 
> --
> Stefano Mazzocchi      One must still have chaos in oneself to be
>                           able to give birth to a dancing star.
> <st...@apache.org>                             Friedrich Nietzsche
> --------------------------------------------------------------------
>  Missed us in Orlando? Make it up with ApacheCON Europe in London!
> ------------------------- http://ApacheCon.Com ---------------------

I've changed the ResourcePipeline recently to have it load classes with
ClassUtils like the most of the other classes to now, but I don't think
this can be a problem. Looks like a clasloader problem? I've had a demo
this morning using Tomcat-4.0 and the latest C2 and all works charming.  

Giacomo

-- 
PWR GmbH, Organisation & Entwicklung      Tel:   +41 (0)1  856 2202
Giacomo Pati, CTO/CEO                     Fax:   +41 (0)1  856 2201
Hintereichenstrasse 7                     Mobil: +41 (0)78 759 7703 
CH-8166 Niederweningen                    Mailto:Giacomo.Pati@pwr.ch 
                                          Web:   http://www.pwr.ch

Re: [C2|bug] weirdest bug ever

Posted by Giacomo Pati <Gi...@pwr.ch>.
"Craig R. McClanahan" wrote:
> 
> Not being familiar with the Cocoon codebase, I've got a real quick question
> -- where do you have the Cocoon JAR files?  If they are not loaded by the
> webapps class loader (i.e. because the Cocoon JARs are under WEB-INF/lib),
> you can have problems like this.  I will also look into the issue more --
> but a "quick and dirty" test case that illustrates the problem would be
> helpful.

Usually we need to put all jars (except ant, stylebook and servlet) from
the cocoon2/lib directory and the build/cocoon/cocoon.jar into
tomcat-4.0/lib directory because of XSP (the javac used to compile the
generated code only look into the CLASSPATH for classes).

Giacomo

> 
> Craig
> 
> Stefano Mazzocchi wrote:
> 
> > With latest C2 and latest Catalina from CVS, with all jars in the
> > classpath (otherwise it doesn't even compile the sitemap) I get
> >
> > java.lang.ClassCastException
> >         at
> > org.apache.cocoon.sitemap.SitemapHandler.run(SitemapHandler.java:147)
> >         at java.lang.Thread.run(Thread.java:479)
> >
> > After accessing the /cocoon/welcome page.
> >
> > The strange thing that sitemap IS compiled and javap tells me that it is
> > an instance of Sitemap, but at runtime it doesn't.
> >
> > This is both the same on JDK 1.2.2 and JDK 1.3 (on win2k)
> >
> > and this code added to SitemapHandler right before the class cast is
> > performed
> >
> > Class c = s.getClass().getSuperclass();
> > System.out.println("superclass: " + c.getName());
> > Class[] cs = c.getInterfaces();
> > for (int i = 0; i < cs.length ; i++) {
> >     System.out.println(cs[i]);
> > }
> > System.out.println("instance of Sitemap: " + (s instanceof
> > org.apache.cocoon.sitemap.Sitemap));
> >
> > returns
> >
> > superclass: org.apache.cocoon.sitemap.AbstractSitemap
> > interface org.apache.cocoon.sitemap.Sitemap
> > instance of Sitemap: false
> >
> > what the hell is going on?
> >
> > --
> > Stefano Mazzocchi      One must still have chaos in oneself to be
> >                           able to give birth to a dancing star.
> > <st...@apache.org>                             Friedrich Nietzsche
> > --------------------------------------------------------------------
> >  Missed us in Orlando? Make it up with ApacheCON Europe in London!
> > ------------------------- http://ApacheCon.Com ---------------------
> 
> --
> ====================
> See you at ApacheCon Europe <http://www.apachecon.com>!
> Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
> Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
>                                     Applications to Tomcat

-- 
PWR GmbH, Organisation & Entwicklung      Tel:   +41 (0)1  856 2202
Giacomo Pati, CTO/CEO                     Fax:   +41 (0)1  856 2201
Hintereichenstrasse 7                     Mobil: +41 (0)78 759 7703 
CH-8166 Niederweningen                    Mailto:Giacomo.Pati@pwr.ch 
                                          Web:   http://www.pwr.ch

Re: [C2|bug] weirdest bug ever

Posted by "Pier P. Fumagalli" <pi...@eng.sun.com>.
Stefano Mazzocchi wrote:
> 
> "Craig R. McClanahan" wrote:
> >
> > Not being familiar with the Cocoon codebase, I've got a real quick question
> > -- where do you have the Cocoon JAR files?  If they are not loaded by the
> > webapps class loader (i.e. because the Cocoon JARs are under WEB-INF/lib),
> > you can have problems like this.  I will also look into the issue more --
> > but a "quick and dirty" test case that illustrates the problem would be
> > helpful.
> 
> At this point, we must place all jars (even Cocoon.jar) into the ./lib
> directory (NOT the WEB-INF/lib but Catalina's own) because otherwise the
> javac compiler is not able to compile things due to missing
> dependencies.
> 
> This is the case with this bug.

Put tools.jar in WEB-INF/lib :)

	Pier

Re: [C2|bug] weirdest bug ever

Posted by Stefano Mazzocchi <st...@apache.org>.
"Craig R. McClanahan" wrote:
> 
> Not being familiar with the Cocoon codebase, I've got a real quick question
> -- where do you have the Cocoon JAR files?  If they are not loaded by the
> webapps class loader (i.e. because the Cocoon JARs are under WEB-INF/lib),
> you can have problems like this.  I will also look into the issue more --
> but a "quick and dirty" test case that illustrates the problem would be
> helpful.

At this point, we must place all jars (even Cocoon.jar) into the ./lib
directory (NOT the WEB-INF/lib but Catalina's own) because otherwise the
javac compiler is not able to compile things due to missing
dependencies.

This is the case with this bug.

-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<st...@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Missed us in Orlando? Make it up with ApacheCON Europe in London!
------------------------- http://ApacheCon.Com ---------------------



Re: [C2|bug] weirdest bug ever

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Not being familiar with the Cocoon codebase, I've got a real quick question
-- where do you have the Cocoon JAR files?  If they are not loaded by the
webapps class loader (i.e. because the Cocoon JARs are under WEB-INF/lib),
you can have problems like this.  I will also look into the issue more --
but a "quick and dirty" test case that illustrates the problem would be
helpful.

Craig


Stefano Mazzocchi wrote:

> With latest C2 and latest Catalina from CVS, with all jars in the
> classpath (otherwise it doesn't even compile the sitemap) I get
>
> java.lang.ClassCastException
>         at
> org.apache.cocoon.sitemap.SitemapHandler.run(SitemapHandler.java:147)
>         at java.lang.Thread.run(Thread.java:479)
>
> After accessing the /cocoon/welcome page.
>
> The strange thing that sitemap IS compiled and javap tells me that it is
> an instance of Sitemap, but at runtime it doesn't.
>
> This is both the same on JDK 1.2.2 and JDK 1.3 (on win2k)
>
> and this code added to SitemapHandler right before the class cast is
> performed
>
> Class c = s.getClass().getSuperclass();
> System.out.println("superclass: " + c.getName());
> Class[] cs = c.getInterfaces();
> for (int i = 0; i < cs.length ; i++) {
>     System.out.println(cs[i]);
> }
> System.out.println("instance of Sitemap: " + (s instanceof
> org.apache.cocoon.sitemap.Sitemap));
>
> returns
>
> superclass: org.apache.cocoon.sitemap.AbstractSitemap
> interface org.apache.cocoon.sitemap.Sitemap
> instance of Sitemap: false
>
> what the hell is going on?
>
> --
> Stefano Mazzocchi      One must still have chaos in oneself to be
>                           able to give birth to a dancing star.
> <st...@apache.org>                             Friedrich Nietzsche
> --------------------------------------------------------------------
>  Missed us in Orlando? Make it up with ApacheCON Europe in London!
> ------------------------- http://ApacheCon.Com ---------------------

--
====================
See you at ApacheCon Europe <http://www.apachecon.com>!
Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
                                    Applications to Tomcat



Re: [C2|bug] weirdest bug ever

Posted by Stefano Mazzocchi <st...@apache.org>.
Vadim Gritsenko wrote:
> 
> Try add following lines to your code:
> 
> System.out.println("Code =
> "+System.identityHashCode(s.getClass().getSuperclass()));
> System.out.println(X-Mozilla-Status: 0009ityHashCode(cs[i]));
> System.out.println("Code =
> "+System.identityHashCode(org.apache.cocoon.sitemap.AbstractSitemap.class));
> System.out.println("Code =
> "+System.identityHashCode(org.apache.cocoon.sitemap.Sitemap.class));
> 
> These codes should be different (in your case) - and this should indicate,
> IMHO, that you have several
> class objects of the same class loaded - may be by different classloaders.

Uh, didn't think of that... here's the result:

superclass: org.apache.cocoon.sitemap.AbstractSitemap (5245364)
interface: org.apache.cocoon.sitemap.Sitemap (2954665)
AbstractSitemap code = 6889309
Sitemap code = 670500
instance of Sitemap: false

which clearly indicate the reason why this happens.

Now: how do I cast something indicating which classloader to use?

geez, we are getting nasty... gotta take out the JLP...

-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<st...@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Missed us in Orlando? Make it up with ApacheCON Europe in London!
------------------------- http://ApacheCon.Com ---------------------



Re: [C2|bug] weirdest bug ever

Posted by Stefano Mazzocchi <st...@apache.org>.
Vadim Gritsenko wrote:
> 
> Try add following lines to your code:
> 
> System.out.println("Code =
> "+System.identityHashCode(s.getClass().getSuperclass()));
> System.out.println("Code = "+System.identityHashCode(cs[i]));
> System.out.println("Code =
> "+System.identityHashCode(org.apache.cocoon.sitemap.AbstractSitemap.class));
> System.out.println("Code =
> "+System.identityHashCode(org.apache.cocoon.sitemap.Sitemap.class));
> 
> These codes should be different (in your case) - and this should indicate,
> IMHO, that you have several
> class objects of the same class loaded - may be by different classloaders.

Uh, didn't think of that... here's the result:

superclass: org.apache.cocoon.sitemap.AbstractSitemap (5245364)
interface: org.apache.cocoon.sitemap.Sitemap (2954665)
AbstractSitemap code = 6889309
Sitemap code = 670500
instance of Sitemap: false

which clearly indicate the reason why this happens.

Now: how do I cast something indicating which classloader to use?

geez, we are getting nasty... gotta take out the JLP...

-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<st...@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Missed us in Orlando? Make it up with ApacheCON Europe in London!
------------------------- http://ApacheCon.Com ---------------------



RE: [C2|bug] weirdest bug ever

Posted by Vadim Gritsenko <vg...@hns.com>.
Try add following lines to your code:

System.out.println("Code =
"+System.identityHashCode(s.getClass().getSuperclass()));
System.out.println("Code = "+System.identityHashCode(cs[i]));
System.out.println("Code =
"+System.identityHashCode(org.apache.cocoon.sitemap.AbstractSitemap.class));
System.out.println("Code =
"+System.identityHashCode(org.apache.cocoon.sitemap.Sitemap.class));

These codes should be different (in your case) - and this should indicate,
IMHO, that you have several
class objects of the same class loaded - may be by different classloaders.

Vadim

> -----Original Message-----
> From: Stefano Mazzocchi [mailto:stefano@apache.org]
> Sent: Monday, September 11, 2000 1:10 PM
> To: Cocoon
> Cc: Craig R. McClanahan
> Subject: [C2|bug] weirdest bug ever
>
>
> With latest C2 and latest Catalina from CVS, with all jars in the
> classpath (otherwise it doesn't even compile the sitemap) I get
>
> java.lang.ClassCastException
> 	at
> org.apache.cocoon.sitemap.SitemapHandler.run(SitemapHandler.java:147)
> 	at java.lang.Thread.run(Thread.java:479)
>
> After accessing the /cocoon/welcome page.
>
> The strange thing that sitemap IS compiled and javap tells me that it is
> an instance of Sitemap, but at runtime it doesn't.
>
> This is both the same on JDK 1.2.2 and JDK 1.3 (on win2k)
>
> and this code added to SitemapHandler right before the class cast is
> performed
>
> Class c = s.getClass().getSuperclass();
> System.out.println("superclass: " + c.getName());
> Class[] cs = c.getInterfaces();
> for (int i = 0; i < cs.length ; i++) {
>     System.out.println(cs[i]);
> }
> System.out.println("instance of Sitemap: " + (s instanceof
> org.apache.cocoon.sitemap.Sitemap));
>
> returns
>
> superclass: org.apache.cocoon.sitemap.AbstractSitemap
> interface org.apache.cocoon.sitemap.Sitemap
> instance of Sitemap: false
>
> what the hell is going on?
>
> --
> Stefano Mazzocchi      One must still have chaos in oneself to be
>                           able to give birth to a dancing star.
> <st...@apache.org>                             Friedrich Nietzsche
> --------------------------------------------------------------------
>  Missed us in Orlando? Make it up with ApacheCON Europe in London!
> ------------------------- http://ApacheCon.Com ---------------------
>
>