You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by "Kevin A. Burton" <bu...@openprivacy.org> on 2002/03/10 01:10:34 UTC

Tomcat 4.0.4b1 calls init() twice? (and strange bugs)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


OK... this is very strange.  All the Tomcat 3.x and 4.x series did not do this.

Now for some reason Tomcat 4.0.4b1 calls my init() method twice.  I put in some
defensive programming to detect this but a 4.0.4 final should NOT have this bug.

Also... both the 4.0.3 and 4.0.4b1 series seem very buggy.  These are definitely
below the quality I have come to expect from Apache/Tomcat releases.

Specifically, I am running into strange classloader issues under both 4.0.3 and
4.0.4b1.  If I gather more information I will report it.  The problem is that i
am getting sporadic behavior.  For example 4.0.3 can't load xalan.jar (or some
subset of the classes) under the correct webapp.

I am also getting some classes that aren't found within the same .jar that
other classes ARE found.

Again... I wish I could be more specific but it is a strange bug.

Anyway... thanks.

- -- 
Kevin A. Burton ( burton@apache.org, burton@openprivacy.org, burtonator@acm.org )
             Location - San Francisco, CA, Cell - 415.595.9965
        Jabber - burtonator@jabber.org,  Web - http://relativity.yi.org/

Any sufficiently advanced terrorist is indistinguishable from Osama Bin Laden.



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Get my public key at: http://relativity.yi.org/pgpkey.txt

iD8DBQE8iqR5AwM6xb2dfE0RAl2SAJ94wLCZqEyB1acMX8IofWsTZQYsXACgsr16
tYrRWNN3LjCZ8cMgJmIOa7I=
=NiK8
-----END PGP SIGNATURE-----

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: ResultSet

Posted by Micael Padraig Og mac Grene <ca...@harbornet.com>.
If you want to compare String objects as literals, use the intern() method.

Micael

At 03:58 PM 3/11/02 +0700, you wrote:
>Hi,
>     For the brave, can anyone guess why with this rather unsociable code:
>
>
>   if ((res.getString(3) == null) || (res.getString(3) == "")) {
>        out.println("<td><a href=takeDetails.jsp?timeSlot=" +
>res.getString(2) + "&myDate=" + myDate + ">" + res.getString(2) +
>"</a></td>");
>    }
>   if ((res.getString(3) != null) || (res.getString(3) != "")) {
>        out.println("<td>" + res.getString(3)+ " " + res.getString(2) +
>"</td>");
>    }
>
>
>the first condition is NEVER satisfied, even though out.println of
>res.getString(3) does not display anything! Ie res.getString(3) IS null,
>empty or whatever, but the condition is never satisifed. Quickly again, this
>is executed:
>
>
>   if ((res.getString(3) != null) || (res.getString(3) != "")) {
>        out.println("<td>" + res.getString(3)+ " " + res.getString(2) +
>"</td>");
>    }
>
>
>even though - out.println("<td>" + res.getString(3)+ " " -  shows it is
>empty (no output)!
>
>Thanks
>
>Paul.
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


ResultSet

Posted by Paul Wallace <pa...@mustang-technologies.com>.
Hi,
    For the brave, can anyone guess why with this rather unsociable code:


  if ((res.getString(3) == null) || (res.getString(3) == "")) {
       out.println("<td><a href=takeDetails.jsp?timeSlot=" +
res.getString(2) + "&myDate=" + myDate + ">" + res.getString(2) +
"</a></td>");
   }
  if ((res.getString(3) != null) || (res.getString(3) != "")) {
       out.println("<td>" + res.getString(3)+ " " + res.getString(2) +
"</td>");
   }


the first condition is NEVER satisfied, even though out.println of
res.getString(3) does not display anything! Ie res.getString(3) IS null,
empty or whatever, but the condition is never satisifed. Quickly again, this
is executed:


  if ((res.getString(3) != null) || (res.getString(3) != "")) {
       out.println("<td>" + res.getString(3)+ " " + res.getString(2) +
"</td>");
   }


even though - out.println("<td>" + res.getString(3)+ " " -  shows it is
empty (no output)!

Thanks

Paul.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tomcat 4.0.4b1 calls init() twice? (and strange bugs)

Posted by "Kevin A. Burton" <bu...@openprivacy.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

"Remy Maucherat" <re...@apache.org> writes:

> > "Remy Maucherat" <re...@apache.org> writes:
> >
> > > > > I already apologized 3 times for the problems with Xalan in
> particular.
> > > > > Thankfully, the workaround is simple enough.  So here's one more:
> I'd
> > > like to
> > > > > apologoize for letting this bug sneak in the release.
> > > > >
> > > > > 4.0.4 b1 should fix it (at least with Xalan). The only thing this
> > > release
> > > > > should not like is if you have the servlet API classes in a JAR.
> > > >
> > > > Well... I did have servlet.jar in WEB-INF/lib... I removed it.  Stupid
> to
> > > have
> > > > it in there anyway.
> > >
> > > BTW, could I also get more info on your problem with init ?
> >
> > Yes... init is being called twice on the same instance of the Servlet.
> 
> Oops. That's a really stupid bug caused by a C&P error when I ported a patch
> from the HEAD branch :-(
> 
> It's too bad the CL problem isn't nearly as easy to fix :-( Anyway, sorry for
> the trouble.

<snip/>

Just an idea... maybe this would be a good use case... require that init is
only called once...

Thanks....

Kevin


- -- 
Kevin A. Burton ( burton@apache.org, burton@openprivacy.org, burtonator@acm.org )
             Location - San Francisco, CA, Cell - 415.595.9965
        Jabber - burtonator@jabber.org,  Web - http://relativity.yi.org/

Any sufficiently advanced terrorist is indistinguishable from Osama Bin Laden.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Get my public key at: http://relativity.yi.org/pgpkey.txt

iD8DBQE8jHoSAwM6xb2dfE0RAkzOAJ45MqDlDhNqORo3oyxI/uw7sTSowACeI/KU
NMnY9Vmve4qlBcjY0LAdjjU=
=Cdxk
-----END PGP SIGNATURE-----

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tomcat 4.0.4b1 calls init() twice? (and strange bugs)

Posted by Remy Maucherat <re...@apache.org>.
> "Remy Maucherat" <re...@apache.org> writes:
>
> > > > I already apologized 3 times for the problems with Xalan in
particular.
> > > > Thankfully, the workaround is simple enough.  So here's one more:
I'd
> > like to
> > > > apologoize for letting this bug sneak in the release.
> > > >
> > > > 4.0.4 b1 should fix it (at least with Xalan). The only thing this
> > release
> > > > should not like is if you have the servlet API classes in a JAR.
> > >
> > > Well... I did have servlet.jar in WEB-INF/lib... I removed it.  Stupid
to
> > have
> > > it in there anyway.
> >
> > BTW, could I also get more info on your problem with init ?
>
> Yes... init is being called twice on the same instance of the Servlet.

Oops. That's a really stupid bug caused by a C&P error when I ported a patch
from the HEAD branch :-(

It's too bad the CL problem isn't nearly as easy to fix :-(
Anyway, sorry for the trouble.

Remy


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tomcat 4.0.4b1 calls init() twice? (and strange bugs)

Posted by "Kevin A. Burton" <bu...@openprivacy.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

"Remy Maucherat" <re...@apache.org> writes:

> > > I already apologized 3 times for the problems with Xalan in particular.
> > > Thankfully, the workaround is simple enough.  So here's one more: I'd
> like to
> > > apologoize for letting this bug sneak in the release.
> > >
> > > 4.0.4 b1 should fix it (at least with Xalan). The only thing this
> release
> > > should not like is if you have the servlet API classes in a JAR.
> >
> > Well... I did have servlet.jar in WEB-INF/lib... I removed it.  Stupid to
> have
> > it in there anyway.
> 
> BTW, could I also get more info on your problem with init ?

Yes... init is being called twice on the same instance of the Servlet.

A quick fix is to do a

    private initialized = false;

    public void init( ServletConfig config ) throws ServletException {

        if ( initialized == false ) {

            //do stuff

            initialized = true;

        }    

    }

This fixes the problem... but should be fixed in Tomcat IMO.

- -- 
Kevin A. Burton ( burton@apache.org, burton@openprivacy.org, burtonator@acm.org )
             Location - San Francisco, CA, Cell - 415.595.9965
        Jabber - burtonator@jabber.org,  Web - http://relativity.yi.org/

Yes I know my enemies, they're the teachers who taught me to fight me;
compromise, conformity, assimilation, submission, ignorance, hypocrisy,
brutality, The Elite. All of which are American Dreams.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Get my public key at: http://relativity.yi.org/pgpkey.txt

iD8DBQE8jFsaAwM6xb2dfE0RAr2lAJ9e5m0K7JOCjV/++vTjSW5Qwg6k0ACgp62R
dSykqJvi1uzTNZoyfZjNgbg=
=jZ3H
-----END PGP SIGNATURE-----

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tomcat 4.0.4b1 calls init() twice? (and strange bugs)

Posted by Remy Maucherat <re...@apache.org>.
> > I already apologized 3 times for the problems with Xalan in particular.
> > Thankfully, the workaround is simple enough.  So here's one more: I'd
like to
> > apologoize for letting this bug sneak in the release.
> >
> > 4.0.4 b1 should fix it (at least with Xalan). The only thing this
release
> > should not like is if you have the servlet API classes in a JAR.
>
> Well... I did have servlet.jar in WEB-INF/lib... I removed it.  Stupid to
have
> it in there anyway.

BTW, could I also get more info on your problem with init ?

Thanks,
Remy


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tomcat 4.0.4b1 calls init() twice? (and strange bugs)

Posted by "Kevin A. Burton" <bu...@openprivacy.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

"Remy Maucherat" <re...@apache.org> writes:
<snip/>
> With JDK 1.4, it gets really tricky then, since no matter what the webapp CL
> has to delegate loading Xalan to the sys CL (ok, it didn't in 4.0.1, but
> that was a bug). The only way out would be for Xalan to use the context
> classloader to load its extensions.

OK... Remy :)

So I just tested this out on JDK 1.4 and JDK 1.3.1... same problem on both
VMs.

I am not sure this is a 1.4 issue :(... I am going to recompile my Xalan to
actually print the original stack trace...

Give you a better report soon.

- -- 
Kevin A. Burton ( burton@apache.org, burton@openprivacy.org, burtonator@acm.org )
             Location - San Francisco, CA, Cell - 415.595.9965
        Jabber - burtonator@jabber.org,  Web - http://relativity.yi.org/

I'm intercontinental when I eat french toast...
    - Beck 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Get my public key at: http://relativity.yi.org/pgpkey.txt

iD8DBQE8jSmRAwM6xb2dfE0RAiWWAJ4oDbKzJn2TMh+ye2XytHZM/ZKQ9ACcDG6u
blKcdjNS7kzuxfttE7DAoqw=
=g+kW
-----END PGP SIGNATURE-----

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tomcat 4.0.4b1 calls init() twice? (and strange bugs)

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On 11 Mar 2002, Kevin A. Burton wrote:

> Date: 11 Mar 2002 01:42:39 -0800
> From: Kevin A. Burton <bu...@openprivacy.org>
> Reply-To: Tomcat Developers List <to...@jakarta.apache.org>
> To: Tomcat Developers List <to...@jakarta.apache.org>
> Subject: Re: Tomcat 4.0.4b1 calls init() twice? (and strange bugs)
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> "Remy Maucherat" <re...@apache.org> writes:
> <snip/>
>
> > > I can't move my code from WEB-INF/classes because I am using Tomcat class
> > > reloading to test out new extension code when I am developing...
> > >
> > > Puts us in a tough situation huh ;)
> >
> > With JDK 1.4, it gets really tricky then, since no matter what the
> > webapp CL has to delegate loading Xalan to the sys CL (ok, it didn't
> > in 4.0.1, but that was a bug). The only way out would be for Xalan to
> > use the context classloader
>
> What is the context classloader?  I didn't see that:
>
> http://jakarta.apache.org/tomcat/tomcat-4.0-doc/class-loader-howto.html
>

That's because it's a standard J2SE feature:

  ClassLoader contextClassLoader =
    Thread.currentThread().getContextClassLoader();

In a servlet 2.3 environment, this is required to be the webapp class
loader (for the current request processing thread).  Although not required
by servlet 2.2, it's very commonly implemented that way (including by
Tomcat 3.2 and 3.3).

The point of this is to let you put something like Xalan in the shared
library directory (which is therefore loaded by a separate class loader),
but still give it access to the webapp class loader.  However, the shared
library code must deliberately choose to access it, instead of just using
Class.forName() to dynamically load classes -- something like this:

  private Class loadApplicationClass(String appClassName) throws Exception {
      ClassLoader appClassLoader =
       Thread.currentThread().getContextClassLoader();
      if (appClassLoader == null) {
          appClassLoader = this.getClass().getClassLoader();
      }
      return (appClassLoader.loadClass(appClassName));
  }

so Xalan would have to do this explicitly to play nice when put into the
shared class loader of Tomcat (or any other container that implements the
concept of shared JAR files in a parent class loader).

> > to load its extensions.
>
> I have to be honest... I think this is a HUGE problem.
>
> I haven't been following these issues on tomcat-dev.  Are there any threads I
> should read?
>
> I think that this will cause a LOT of people a LOT of headaches.  The
> Cocoon2 guys should really feel this.  So would anyone doing
> Xerces/Xalan stuff from within a Servlet.
>
> What happens under 1.4 which makes this different?  Is there anything that can
> be done about this?
>

What happens is that JAXP/1.1 is built in to JDK 1.4 -- therefore, once
you have delegated up to the shared class loader, it will delegate up all
the way to the version included in the JDK.

> Anyway... whatever the long term solution to this, I think it needs to be
> documented very well....
>

In the HEAD branch of Tomcat 4, we dealt with this by introducing a new
"common/endorsed" directory, and modified the Tomcat startup script to use
the new JDK 1.4 "java.endorsed.dirs" system property.  For examle, this
lets run Xerces 2 or Xalan 2 even on a 1.4 system, by putting them into
the common/endorsed directory.  It still works transparently on a JDK 1.3
system, which ignored java.endorsed.dirs, because we build common/endorsed
in to the common class loader.

More info about java.endorsed.dirs is at:

  http://java.sun.com/j2se/1.4/docs/guide/standards/index.html

Porting this back to 4.0.x would seem like a low risk way to deal with the
issue -- it seems to work pretty well.

> Anyway... sorry to be freaking out about this.  We have a fairly
> distributed app (http://reptile.openprivacy.org) and it uses Tomcat
> 4.x.... I can't release on 4.0.1 because of security issues and I can't
> use any of the other builds because it breaks my code... :(
>
> Thanks for you help Remy!  Time for sleep...
>
> Kevin
>

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tomcat 4.0.4b1 calls init() twice? (and strange bugs)

Posted by "Kevin A. Burton" <bu...@openprivacy.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

"Remy Maucherat" <re...@apache.org> writes:
<snip/>

> > I can't move my code from WEB-INF/classes because I am using Tomcat class
> > reloading to test out new extension code when I am developing...
> >
> > Puts us in a tough situation huh ;)
> 
> With JDK 1.4, it gets really tricky then, since no matter what the webapp CL
> has to delegate loading Xalan to the sys CL (ok, it didn't in 4.0.1, but that
> was a bug). The only way out would be for Xalan to use the context classloader

What is the context classloader?  I didn't see that:

http://jakarta.apache.org/tomcat/tomcat-4.0-doc/class-loader-howto.html

> to load its extensions.

I have to be honest... I think this is a HUGE problem.

I haven't been following these issues on tomcat-dev.  Are there any threads I
should read?

I think that this will cause a LOT of people a LOT of headaches.  The Cocoon2
guys should really feel this.  So would anyone doing Xerces/Xalan stuff from
within a Servlet.

What happens under 1.4 which makes this different?  Is there anything that can
be done about this?

Anyway... whatever the long term solution to this, I think it needs to be
documented very well....

Anyway... sorry to be freaking out about this.  We have a fairly distributed app
(http://reptile.openprivacy.org) and it uses Tomcat 4.x.... I can't release on
4.0.1 because of security issues and I can't use any of the other builds because
it breaks my code... :(

Thanks for you help Remy!  Time for sleep... 

Kevin

- -- 
Kevin A. Burton ( burton@apache.org, burton@openprivacy.org, burtonator@acm.org )
             Location - San Francisco, CA, Cell - 415.595.9965
        Jabber - burtonator@jabber.org,  Web - http://relativity.yi.org/

George Washington's brother was the uncle of our country.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Get my public key at: http://relativity.yi.org/pgpkey.txt

iD8DBQE8jHwPAwM6xb2dfE0RAujcAJ9a2k50fjl2jaG5mt5Km9lbQXv8PQCdFqMY
esrOPKC7m9FZ6J0DFFERwes=
=jjXb
-----END PGP SIGNATURE-----

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tomcat 4.0.4b1 calls init() twice? (and strange bugs)

Posted by Remy Maucherat <re...@apache.org>.
> "Remy Maucherat" <re...@apache.org> writes:
>
> <snip/>
> > > > Which JDK are you using ? I assume 1.3.x.
> > >
> > > 1.2.x, 1.3.x, 1.4.x ... need to support them all.
> > >
> > > > I'll do my best to continue improving the CL (so that all the
exclusions
> > > > tricks would be unnecessary), but I'm running out of ideas for some
> > cases
> > > > (JAXP, JNDI, the servlet API).  I'll try to fix it for 4.0.4 b2.
> > >
> > > Hm... so what are the options?  Stop using Tomcat WebApp classloader?
> > Move all
> > > my .jars into common/lib ?
> >
> > IMO, you don't need to move everything, but you could exepriment
removing the
> > XML parser and putting Xalan in common/lib, and see if it helps. We're
> > experimenting here.
>
> I tried removing xerces.jar from common/lib... Didn't see how that would
be a
> problem since it is Xalan that is trying to instantiate my extensions.
Still
> didn't work :(
>
> Putting Xalan in common/lib causes other problems.  All my extensions are
under
> WEB-INF/classes.  If I put Xalan under common/lib it is in a new
classloader
> and I will get Exceptions when it can't find my code.
>
> I can't move my code from WEB-INF/classes because I am using Tomcat class
> reloading to test out new extension code when I am developing...
>
> Puts us in a tough situation huh ;)

With JDK 1.4, it gets really tricky then, since no matter what the webapp CL
has to delegate loading Xalan to the sys CL (ok, it didn't in 4.0.1, but
that was a bug). The only way out would be for Xalan to use the context
classloader to load its extensions.

Remy


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tomcat 4.0.4b1 calls init() twice? (and strange bugs)

Posted by "Kevin A. Burton" <bu...@openprivacy.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

"Remy Maucherat" <re...@apache.org> writes:

<snip/>
> > > Which JDK are you using ? I assume 1.3.x.
> >
> > 1.2.x, 1.3.x, 1.4.x ... need to support them all.
> >
> > > I'll do my best to continue improving the CL (so that all the exclusions
> > > tricks would be unnecessary), but I'm running out of ideas for some
> cases
> > > (JAXP, JNDI, the servlet API).  I'll try to fix it for 4.0.4 b2.
> >
> > Hm... so what are the options?  Stop using Tomcat WebApp classloader?
> Move all
> > my .jars into common/lib ?
> 
> IMO, you don't need to move everything, but you could exepriment removing the
> XML parser and putting Xalan in common/lib, and see if it helps. We're
> experimenting here.

I tried removing xerces.jar from common/lib... Didn't see how that would be a
problem since it is Xalan that is trying to instantiate my extensions.  Still
didn't work :(

Putting Xalan in common/lib causes other problems.  All my extensions are under
WEB-INF/classes.  If I put Xalan under common/lib it is in a new classloader
and I will get Exceptions when it can't find my code.

I can't move my code from WEB-INF/classes because I am using Tomcat class
reloading to test out new extension code when I am developing...

Puts us in a tough situation huh ;)

Thanks!

Kevin

- -- 
Kevin A. Burton ( burton@apache.org, burton@openprivacy.org, burtonator@acm.org )
             Location - San Francisco, CA, Cell - 415.595.9965
        Jabber - burtonator@jabber.org,  Web - http://relativity.yi.org/

bounce. bounce. bounce. bounce. bounce. bounce. bounce. bounce. bounce. bounce.
bounce. bounce. bounce. bounce. bounce.
 - Fatboy Slim
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Get my public key at: http://relativity.yi.org/pgpkey.txt

iD8DBQE8jFpYAwM6xb2dfE0RAnFsAJkBgD/qiV+u+4x1oZ9XPpKYQm7iFACguqZE
k98pV344OaSACYxJVI1GdYk=
=bcB7
-----END PGP SIGNATURE-----

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tomcat 4.0.4b1 calls init() twice? (and strange bugs)

Posted by co...@covalent.net.
On Sun, 10 Mar 2002, Remy Maucherat wrote:

> No, everything is mostly ok and the docs are relatively up to date. You just
> forgot to read $9.7.2 in the spec. I think the CL scheme recommended by the
> servlet API is as close to being unimplementable (at least in a working
> fashion) as you can get. I'm not losing all hope just yet, though ;-)

:-)

So now I'm not the only one that believes that. 

It's not unimplementable, but conflicts to other java specifications 
and implementing it may create major security problems ( potentially 
breaking the sandbox model, on which the class loader behavior is an 
important part ). I know I sound like a broken record. 

And the current mess will only get messier. But as long as 2 people 
understand how the classloader works, we'll be ok :-)

Costin


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tomcat 4.0.4b1 calls init() twice? (and strange bugs)

Posted by Remy Maucherat <re...@apache.org>.
> "Remy Maucherat" <re...@apache.org> writes:
>
> > > "Remy Maucherat" <re...@apache.org> writes:
> <snip/>
>
> > > This is the wierdness that I was talking about.  What Xalan bug did
you fix?
> >
> > The javax.xml packages couldn't be loaded from the webapp repository
(because
> > of the way delegation works in the servlet API, the base XML classes
can't be
> > loaded from the webapp without causing lots of trouble; however, that
> > resptriction was too broad, adn is now restricted to the base SAX and
DOM
> > classes, as well as the core JAXP XML parser interfaces).
>
> This is what I assumed the problem is... I have spent a lot of time
debugging
> Tomcat classloader issue (though certainly not as much as other people
here).
>
> My document on Tomcat classloading that I am referencing:
>
> http://jakarta.apache.org/tomcat/tomcat-4.0-doc/class-loader-howto.html
>
> ... but it looks like things have changed below...
>
> > > Could you give me more insight here?
> >
> > If Xalan needs a newer version of the SAX, DOM, or JAXP XML parser APIs
than
> > what is in common/lib to support extensions, you'll have to replace it
> > there. 4.0.1 allowed you to override them (which created some problems
in many
> > cases),
>
> OK.. I think that this should be documented in class-loader-howto.html
>
> > and 4.0.2/4.0.3/4.0.4b1 don't.
>
> Yes... this is my experience exactly.
>
> > Also, if JAXP is in the system classloader, you can never override it.
>
> Ug...
>
> "As mentioned above, the web application class loader diverges from the
default
> Java 2 delegation model (in accordance with the recommendations in the
Servlet
> Specification, version 2.3, section 9.6). When a request to load a class
from
> the web application's WebappX class loader is processed, this class loader
will
> look in the local repositories first, instead of delegating before
looking. All
> other class loaders in Tomcat 4 follow the usual delegation pattern."
>
> Does this mean that Tomcat is now NOT in complaince with the Servlet 2.3
spec???

No, everything is mostly ok and the docs are relatively up to date. You just
forgot to read $9.7.2 in the spec. I think the CL scheme recommended by the
servlet API is as close to being unimplementable (at least in a working
fashion) as you can get. I'm not losing all hope just yet, though ;-)

The thing is that 'J2SE classes' is a moving target ...
In 4.0.4 b1, I prevent loading from the webapps anything which can be loaded
with the sys CL, which seems reasonable since with Catalina it doesn't
contain much more than the J2SE classes. To harmonize between the different
J2SE versions, I was considering using tricks (namely, the 'Class-Path'
attribute of the JARs) to put JNDI and JAXP/Xerces in the sys classloader,
therefore removing the need for the custom class exclusion code in the
webapp CL. Unfortunately, I think that would still lead to breaking the
Xalan extensions you're using. It's also not terribly robust (if you rename
the JAR, or use another implementation, it will break).

> > Which JDK are you using ? I assume 1.3.x.
>
> 1.2.x, 1.3.x, 1.4.x ... need to support them all.
>
> > I'll do my best to continue improving the CL (so that all the exclusions
> > tricks would be unnecessary), but I'm running out of ideas for some
cases
> > (JAXP, JNDI, the servlet API).  I'll try to fix it for 4.0.4 b2.
>
> Hm... so what are the options?  Stop using Tomcat WebApp classloader?
Move all
> my .jars into common/lib ?

IMO, you don't need to move everything, but you could exepriment removing
the XML parser and putting Xalan in common/lib, and see if it helps. We're
experimenting here.

Remy


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tomcat 4.0.4b1 calls init() twice? (and strange bugs)

Posted by "Kevin A. Burton" <bu...@openprivacy.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

"Remy Maucherat" <re...@apache.org> writes:

> > "Remy Maucherat" <re...@apache.org> writes:
<snip/>

> > This is the wierdness that I was talking about.  What Xalan bug did you fix?
> 
> The javax.xml packages couldn't be loaded from the webapp repository (because
> of the way delegation works in the servlet API, the base XML classes can't be
> loaded from the webapp without causing lots of trouble; however, that
> resptriction was too broad, adn is now restricted to the base SAX and DOM
> classes, as well as the core JAXP XML parser interfaces).

This is what I assumed the problem is... I have spent a lot of time debugging
Tomcat classloader issue (though certainly not as much as other people here).

My document on Tomcat classloading that I am referencing:

http://jakarta.apache.org/tomcat/tomcat-4.0-doc/class-loader-howto.html

... but it looks like things have changed below...

> > Could you give me more insight here?
> 
> I have no idea at this point. Too bad the original exception isn't available
> ...

Yes... thanks Xalan developers :)

> If Xalan needs a newer version of the SAX, DOM, or JAXP XML parser APIs than
> what is in common/lib to support extensions, you'll have to replace it
> there. 4.0.1 allowed you to override them (which created some problems in many
> cases),

OK.. I think that this should be documented in class-loader-howto.html

> and 4.0.2/4.0.3/4.0.4b1 don't.

Yes... this is my experience exactly.

> Also, if JAXP is in the system classloader, you can never override it.

Ug...

"As mentioned above, the web application class loader diverges from the default
Java 2 delegation model (in accordance with the recommendations in the Servlet
Specification, version 2.3, section 9.6). When a request to load a class from
the web application's WebappX class loader is processed, this class loader will
look in the local repositories first, instead of delegating before looking. All
other class loaders in Tomcat 4 follow the usual delegation pattern."

Does this mean that Tomcat is now NOT in complaince with the Servlet 2.3 spec???

> Which JDK are you using ? I assume 1.3.x.

1.2.x, 1.3.x, 1.4.x ... need to support them all.

> I'll do my best to continue improving the CL (so that all the exclusions
> tricks would be unnecessary), but I'm running out of ideas for some cases
> (JAXP, JNDI, the servlet API).  I'll try to fix it for 4.0.4 b2.

Hm... so what are the options?  Stop using Tomcat WebApp classloader?  Move all
my .jars into common/lib ?

> > Whatever you fixed has broke Xalan extension support ... at least in my app
> > which has run just fine under anything pre 4.0.3...

Thanks!

- -- 
Kevin A. Burton ( burton@apache.org, burton@openprivacy.org, burtonator@acm.org )
             Location - San Francisco, CA, Cell - 415.595.9965
        Jabber - burtonator@jabber.org,  Web - http://relativity.yi.org/

... Whereas it is essential, if man is not to be compelled to have recourse, as a
last resort, to rebellion against tyranny and oppression, that human rights
should be protected by the rule of law...
   -- Universal Declaration of Human Rights, United Nations, 1948
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Get my public key at: http://relativity.yi.org/pgpkey.txt

iD8DBQE8jEptAwM6xb2dfE0RAoWiAJ0aXnLVAi8qELRpd20vsQyIsPOCMACfT8O2
xeqopLfEWFX+bFjwGcNoZUY=
=nUc9
-----END PGP SIGNATURE-----

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tomcat 4.0.4b1 calls init() twice? (and strange bugs)

Posted by Remy Maucherat <re...@apache.org>.
> "Remy Maucherat" <re...@apache.org> writes:
> <snip/>
>
> >
> > I already apologized 3 times for the problems with Xalan in particular.
> > Thankfully, the workaround is simple enough.  So here's one more: I'd
like to
> > apologoize for letting this bug sneak in the release.
> >
> > 4.0.4 b1 should fix it (at least with Xalan). The only thing this
release
> > should not like is if you have the servlet API classes in a JAR.
>
> Well... I did have servlet.jar in WEB-INF/lib... I removed it.  Stupid to
have
> it in there anyway.

That's ok, it shouldn't cause trouble.

> That said... I still have classloader problems with 4.0.4-b1.
>
> Specifically when I try to call a Java function from Xalan
>
> javax.xml.transform.TransformerException: java.lang.NullPointerException
>         at
org.apache.xalan.extensions.ExtensionHandlerJavaClass.callFunction(Extension
HandlerJavaClass.java:357)
>         at
org.apache.xalan.extensions.ExtensionsTable.extFunction(ExtensionsTable.java
:257)
>         at
org.apache.xpath.functions.FuncExtFunction.execute(FuncExtFunction.java:181)
>
> It appears that Xalan can't instantiate my class/extension.  For whatever
reasons...
>
> <snip/>
>
> This is the wierdness that I was talking about.  What Xalan bug did you
fix?

The javax.xml packages couldn't be loaded from the webapp repository
(because of the way delegation works in the servlet API, the base XML
classes can't be loaded from the webapp without causing lots of trouble;
however, that resptriction was too broad, adn is now restricted to the base
SAX and DOM classes, as well as the core JAXP XML parser interfaces).

> Could you give me more insight here?

I have no idea at this point. Too bad the original exception isn't available
... If Xalan needs a newer version of the SAX, DOM, or JAXP XML parser APIs
than what is in common/lib to support extensions, you'll have to replace it
there. 4.0.1 allowed you to override them (which created some problems in
many cases), and 4.0.2/4.0.3/4.0.4b1 don't. Also, if JAXP is in the system
classloader, you can never override it.

Which JDK are you using ? I assume 1.3.x.

I'll do my best to continue improving the CL (so that all the exclusions
tricks would be unnecessary), but I'm running out of ideas for some cases
(JAXP, JNDI, the servlet API).
I'll try to fix it for 4.0.4 b2.

> Whatever you fixed has broke Xalan
> extension support ... at least in my app which has run just fine under
anything
> pre 4.0.3...

Remy


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tomcat 4.0.4b1 calls init() twice? (and strange bugs)

Posted by "Kevin A. Burton" <bu...@openprivacy.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

"Remy Maucherat" <re...@apache.org> writes:
<snip/>

> 
> I already apologized 3 times for the problems with Xalan in particular.
> Thankfully, the workaround is simple enough.  So here's one more: I'd like to
> apologoize for letting this bug sneak in the release.
> 
> 4.0.4 b1 should fix it (at least with Xalan). The only thing this release
> should not like is if you have the servlet API classes in a JAR.

Well... I did have servlet.jar in WEB-INF/lib... I removed it.  Stupid to have
it in there anyway.

That said... I still have classloader problems with 4.0.4-b1.

Specifically when I try to call a Java function from Xalan

javax.xml.transform.TransformerException: java.lang.NullPointerException
        at org.apache.xalan.extensions.ExtensionHandlerJavaClass.callFunction(ExtensionHandlerJavaClass.java:357)
        at org.apache.xalan.extensions.ExtensionsTable.extFunction(ExtensionsTable.java:257)
        at org.apache.xpath.functions.FuncExtFunction.execute(FuncExtFunction.java:181)

It appears that Xalan can't instantiate my class/extension.  For whatever reasons...

<snip/>

This is the wierdness that I was talking about.  What Xalan bug did you fix?
Could you give me more insight here?  Whatever you fixed has broke Xalan
extension support ... at least in my app which has run just fine under anything
pre 4.0.3...

Kevin

- -- 
Kevin A. Burton ( burton@apache.org, burton@openprivacy.org, burtonator@acm.org )
             Location - San Francisco, CA, Cell - 415.595.9965
        Jabber - burtonator@jabber.org,  Web - http://relativity.yi.org/

Please don't use hard tabs 	 in your code.  Instead use 4 spaces.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Get my public key at: http://relativity.yi.org/pgpkey.txt

iD8DBQE8jAe1AwM6xb2dfE0RAr6rAJ9285KR/fceQzEVIWt/HnaaqvaXYQCgrNB9
FIYTV6MSqqP1IHglVtEDWQU=
=5fXM
-----END PGP SIGNATURE-----

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tomcat 4.0.4b1 calls init() twice? (and strange bugs)

Posted by Remy Maucherat <re...@apache.org>.
> OK... this is very strange.  All the Tomcat 3.x and 4.x series did not do
this.
>
> Now for some reason Tomcat 4.0.4b1 calls my init() method twice.  I put in
some
> defensive programming to detect this but a 4.0.4 final should NOT have
this bug.
>
> Also... both the 4.0.3 and 4.0.4b1 series seem very buggy.  These are
definitely
> below the quality I have come to expect from Apache/Tomcat releases.
>
> Specifically, I am running into strange classloader issues under both
4.0.3 and
> 4.0.4b1.  If I gather more information I will report it.  The problem is
that i
> am getting sporadic behavior.  For example 4.0.3 can't load xalan.jar (or
some
> subset of the classes) under the correct webapp.

I already apologized 3 times for the problems with Xalan in particular.
Thankfully, the workaround is simple enough.
So here's one more:
I'd like to apologoize for letting this bug sneak in the release.

4.0.4 b1 should fix it (at least with Xalan). The only thing this release
should not like is if you have the servlet API classes in a JAR.

Both 4.0.2 and 4.0.4 b1 fix a lot of bugs which existed in 4.0.1, so I don't
consider them any more buggy than 4.0.1, or esp 4.0. I guess if you were
using native connectors, you would have a much different opinion ;-)
I don't see any change which would cause the multiple init invocation. I've
seen reports of this with JSPs, but none with servlets. Does it also happen
with 4.0.3, or is it only with 4.0.4 b1 ?

> I am also getting some classes that aren't found within the same .jar that
> other classes ARE found.
>
> Again... I wish I could be more specific but it is a strange bug.
>
> Anyway... thanks.

Remy


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>