You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Tim Funk <fu...@joedog.org> on 2003/02/03 01:59:43 UTC

[PATCH] allow tomcat5 to compile/run with JDK1.3

Tomcat5 does not compile with JDK1.3. It does with JDK1.4.

There is only one line of code that prevents it from compiling with JDK1.3.
org.apache.catalina.loader.WebappClassLoader depends on File.toURI() 
which does not exist on jdk1.3.

I got around this by the performing the following:
OLD CODE:
   return realFile.toURI().toURL();
NEW CODE
   return new URL("file:" + realFile.toURL().getPath());

My patch also has some spurious stuff because my text editor 
automatically strips all trailing whitespace from lines and converts 
tabs to spaces. The important stuff is the last 9 lines of the patch file.

-Tim

Re: Tomcat ajp13 connector: ajp14 extension how to force apache to do login

Posted by Henri Gomez <hg...@apache.org>.
Gang Zhang wrote:
> Hi:
> 
>   I read the ajp faq and noticed that the ajp13 extension allows login to be
> performed between apache/IIS and tomcat.  However it was hard for me to find
> any information about how to set the password information for apache side.
> 
>   I read the java side of the connector, Seems that for tomcat 3.3, the
> adaptor do set  the negotion handler, and for tomcat4, I need to add the
> negotion handler by myself to the code.  So is the extension already been
> done or it is still in its proposal period?

Something to be added in both jk/jk2 .... A little latter....





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


Tomcat ajp13 connector: ajp14 extension how to force apache to do login

Posted by Gang Zhang <gz...@Access4Less.net>.
Hi:

  I read the ajp faq and noticed that the ajp13 extension allows login to be
performed between apache/IIS and tomcat.  However it was hard for me to find
any information about how to set the password information for apache side.

  I read the java side of the connector, Seems that for tomcat 3.3, the
adaptor do set  the negotion handler, and for tomcat4, I need to add the
negotion handler by myself to the code.  So is the extension already been
done or it is still in its proposal period?

 Thanks
 Gang


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


RE: [PATCH] allow tomcat5 to compile/run with JDK1.3

Posted by pero <me...@gmx.de>.
ok, looked into cvs so forget that mail :)

> -----Original Message-----
> From: pero [mailto:megapero@gmx.de] 
> Sent: Wednesday, February 05, 2003 4:20 AM
> To: 'Tomcat Developers List'
> Subject: RE: [PATCH] allow tomcat5 to compile/run with JDK1.3
> 
> 
> > Everyone will call JdkCompat.getJdkCompat() to get a
> > JdkCompat instance. 
> > When JdkCompat is statically initialized, it determines which 
> > implementation to load. Currently, it performs a check on 
> > System.getProperty("java.version"). If the property starts 
> > with 1.4 then 
> > the Jdk14Compat class is loaded. Otherwise, the default 
> > JdkCompat will 
> > be loaded.
> > 
> > So, this has the side effect that when jdk1.5(and beyond) 
> comes out -
> > this will load the wrong version of the class. Should I ignore that 
> > issue for now or create a better comparison?
> 
>   I don't know whether System.getProperty ("java.version") 
> always returns the correct version, especially for non 
> SUN-implementations. Perhaps it is better (for now) to 
> perform the check on the actual need, meaning trying to 
> invoke "file.toURI().toURL()" via Reflection and see if it 
> works. This will give the safety that for JDK 1.5 the correct 
> (i.e. 1.4) compat will be used. But this mechanism will get 
> complicated if other methods with other dependencies are added. :( 
> 
> Really only my $0.02,
> 
> Peter
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
> 


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


RE: [PATCH] allow tomcat5 to compile/run with JDK1.3

Posted by pero <me...@gmx.de>.
> Everyone will call JdkCompat.getJdkCompat() to get a 
> JdkCompat instance. 
> When JdkCompat is statically initialized, it determines which 
> implementation to load. Currently, it performs a check on 
> System.getProperty("java.version"). If the property starts 
> with 1.4 then 
> the Jdk14Compat class is loaded. Otherwise, the default 
> JdkCompat will 
> be loaded.
> 
> So, this has the side effect that when jdk1.5(and beyond) comes out - 
> this will load the wrong version of the class. Should I ignore that 
> issue for now or create a better comparison?

  I don't know whether System.getProperty ("java.version") always returns
the correct version, especially for non SUN-implementations. Perhaps it is
better (for now) to perform the check on the actual need, meaning trying
to invoke "file.toURI().toURL()" via Reflection and see if it works. This
will give the safety that for JDK 1.5 the correct (i.e. 1.4) compat will be
used. But this mechanism will get complicated if other methods with other
dependencies are added. :( 

Really only my $0.02,

Peter


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


Re: [PATCH] allow tomcat5 to compile/run with JDK1.3

Posted by Tim Funk <fu...@joedog.org>.
Here is an attempt at a JdkCompat implementation. There are 2 classes, 
JdkCompat which is the base support class and Jdk14Compat which extends 
JdkCompat.

The patch is in JdkCompat.txt for WebappClassloader and build.xml. I 
manually edited the patch file to eliminate all the extra edits my text 
editor makes with respect to whitespace changes.

Everyone will call JdkCompat.getJdkCompat() to get a JdkCompat instance. 
When JdkCompat is statically initialized, it determines which 
implementation to load. Currently, it performs a check on 
System.getProperty("java.version"). If the property starts with 1.4 then 
the Jdk14Compat class is loaded. Otherwise, the default JdkCompat will 
be loaded.

So, this has the side effect that when jdk1.5(and beyond) comes out - 
this will load the wrong version of the class. Should I ignore that 
issue for now or create a better comparison?


-Tim

Costin Manolache wrote:
> Tim Funk wrote:
> 
> 
>>To get functionality like jdkCompat (and looking at tomcat3), it looks
>>like something similar to the following would need added to the existing
>>jakarta-tomcat-catalina/catalina/build.xml:
>>------------------------------------------
>>   <exclude name="org/apache/catalina/util/compat/JdkCompat14.java"
>>            unless="jdk.1.4.present"/>
>>------------------------------------------
>>Where would jdkCompat live with respect to package name? Does it belong
>>in catalina? (org.apache.catalina.util.compat.ClassXXX)
> 
> 
> I would place it in j-t-c/util, even in o.a.tomcat.util.compat ( but with a
> different name than jkd11compat class in 3.3 ).
> 
> This kind of code is very common.
>  

Re: [PATCH] allow tomcat5 to compile/run with JDK1.3

Posted by Costin Manolache <cm...@yahoo.com>.
Tim Funk wrote:

> To get functionality like jdkCompat (and looking at tomcat3), it looks
> like something similar to the following would need added to the existing
> jakarta-tomcat-catalina/catalina/build.xml:
> ------------------------------------------
>    <exclude name="org/apache/catalina/util/compat/JdkCompat14.java"
>             unless="jdk.1.4.present"/>
> ------------------------------------------
> Where would jdkCompat live with respect to package name? Does it belong
> in catalina? (org.apache.catalina.util.compat.ClassXXX)

I would place it in j-t-c/util, even in o.a.tomcat.util.compat ( but with a
different name than jkd11compat class in 3.3 ).

This kind of code is very common.



> Are there any other methods (wishlist) which need to be here?

We can add as we go. You can do a grep in sources for all reflection - and
see if anything else is needed there.

 
> Or am I getting ahead of myself and should I be patient and wait for
> someone with better insight to do this instead?

You seem to have good insight, please do it.

Costin 

> 
> -Tim
> 
> 
> Remy Maucherat wrote:
>> Costin Manolache wrote:
>> 
>>> Tim Funk wrote:
>>>
>>>
>>> Oh, NO. Please don't even think about it.... Commons-dbcp must do it
>>> because
>>> it is impossible to write a JDBC driver that works and compiles in
>>> both 1.3
>>> and 1.4.
>>> Reflection is fine - I would preffer using a jdkCompat-like trick and
>>> have
>>> substitute code for 1.3, but I'm fine with reflection.
>> 
>> 
>> Yes, I agree using a compat class is definitely much nicer :)
>> 
>> Remy
>>



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


Re: [PATCH] allow tomcat5 to compile/run with JDK1.3

Posted by Tim Funk <fu...@joedog.org>.
To get functionality like jdkCompat (and looking at tomcat3), it looks 
like something similar to the following would need added to the existing 
jakarta-tomcat-catalina/catalina/build.xml:
------------------------------------------
   <exclude name="org/apache/catalina/util/compat/JdkCompat14.java"
            unless="jdk.1.4.present"/>
------------------------------------------
Where would jdkCompat live with respect to package name? Does it belong 
in catalina? (org.apache.catalina.util.compat.ClassXXX)

Are there any other methods (wishlist) which need to be here?

Or am I getting ahead of myself and should I be patient and wait for 
someone with better insight to do this instead?

-Tim


Remy Maucherat wrote:
> Costin Manolache wrote:
> 
>> Tim Funk wrote:
>>
>>
>> Oh, NO. Please don't even think about it.... Commons-dbcp must do it 
>> because
>> it is impossible to write a JDBC driver that works and compiles in 
>> both 1.3
>> and 1.4.
>> Reflection is fine - I would preffer using a jdkCompat-like trick and 
>> have
>> substitute code for 1.3, but I'm fine with reflection.
> 
> 
> Yes, I agree using a compat class is definitely much nicer :)
> 
> Remy
> 


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


Re: [PATCH] allow tomcat5 to compile/run with JDK1.3

Posted by Remy Maucherat <re...@apache.org>.
Costin Manolache wrote:
> Tim Funk wrote:
> 
> 
> Oh, NO. Please don't even think about it.... Commons-dbcp must do it because
> it is impossible to write a JDBC driver that works and compiles in both 1.3
> and 1.4. 
> 
> Reflection is fine - I would preffer using a jdkCompat-like trick and have
> substitute code for 1.3, but I'm fine with reflection.

Yes, I agree using a compat class is definitely much nicer :)

Remy


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


Re: [PATCH] allow tomcat5 to compile/run with JDK1.3

Posted by Costin Manolache <cm...@yahoo.com>.
Tim Funk wrote:

> After looking at the older revisions, I agree my patch was stupendously
> horrible :(
> 
> The patch now uses reflection to keep the current code equivalent for
> jdk14 and use the old way in case of a jdk1.3 jvm.
> 
> That being said - I would assume that the RMI issue your patch addressed
> would still be an issue in JDK1.3. Can you give me some insight on what
> it was? If possible I can attempt to make the appropriate fix.
> 
> I think commons-dbcp project do some wacky magic on java src files (
> poor man's equivalent of c directives for code include/exclude). Is that
> an alternative to move towards for situations like this? Or is having
> one and only one binary the a better goal? (So users don't need to
> choose a 1.3 and 1.4 binary)

Oh, NO. Please don't even think about it.... Commons-dbcp must do it because
it is impossible to write a JDBC driver that works and compiles in both 1.3
and 1.4. 

Reflection is fine - I would preffer using a jdkCompat-like trick and have
substitute code for 1.3, but I'm fine with reflection.

Costin




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


Re: [PATCH] allow tomcat5 to compile/run with JDK1.3

Posted by Tim Funk <fu...@joedog.org>.
After looking at the older revisions, I agree my patch was stupendously 
horrible :(

The patch now uses reflection to keep the current code equivalent for 
jdk14 and use the old way in case of a jdk1.3 jvm.

That being said - I would assume that the RMI issue your patch addressed 
would still be an issue in JDK1.3. Can you give me some insight on what 
it was? If possible I can attempt to make the appropriate fix.

I think commons-dbcp project do some wacky magic on java src files ( 
poor man's equivalent of c directives for code include/exclude). Is that 
an alternative to move towards for situations like this? Or is having 
one and only one binary the a better goal? (So users don't need to 
choose a 1.3 and 1.4 binary)

-Tim


Remy Maucherat wrote:
> Tim Funk wrote:
> 
>> Tomcat5 does not compile with JDK1.3. It does with JDK1.4.
>>
>> There is only one line of code that prevents it from compiling with 
>> JDK1.3.
>> org.apache.catalina.loader.WebappClassLoader depends on File.toURI() 
>> which does not exist on jdk1.3.
>>
>> I got around this by the performing the following:
>> OLD CODE:
>>   return realFile.toURI().toURL();
>> NEW CODE
>>   return new URL("file:" + realFile.toURL().getPath());
>>
>> My patch also has some spurious stuff because my text editor 
>> automatically strips all trailing whitespace from lines and converts 
>> tabs to spaces. The important stuff is the last 9 lines of the patch 
>> file.
> 
> 
> The patch is a bad idea. The change was made to fix RMI related problems.
> 
> What should be done is invoke the appropriate methods through 
> reflection, catching any error (and defaulting to the old code if it 
> fails).
> 
> Remy
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
> 
> 

Re: [PATCH] allow tomcat5 to compile/run with JDK1.3

Posted by Costin Manolache <cm...@yahoo.com>.
Remy Maucherat wrote:

> Costin Manolache wrote:
>> Remy Maucherat wrote:
>> 
>> 
>>>Tim Funk wrote:
>>>
>>>>Tomcat5 does not compile with JDK1.3. It does with JDK1.4.
>>>>
>>>>There is only one line of code that prevents it from compiling with
>>>>JDK1.3. org.apache.catalina.loader.WebappClassLoader depends on
>>>>File.toURI() which does not exist on jdk1.3.
>>>>
>>>>I got around this by the performing the following:
>>>>OLD CODE:
>>>>  return realFile.toURI().toURL();
>>>>NEW CODE
>>>>  return new URL("file:" + realFile.toURL().getPath());
>>>>
>>>>My patch also has some spurious stuff because my text editor
>>>>automatically strips all trailing whitespace from lines and converts
>>>>tabs to spaces. The important stuff is the last 9 lines of the patch
>>>>file.
>>>
>>>The patch is a bad idea. The change was made to fix RMI related problems.
>>>
>>>What should be done is invoke the appropriate methods through
>>>reflection, catching any error (and defaulting to the old code if it
>>>fails).
>> 
>> 
>> Well, reflection is a bad idea too :-) A better solution is to use a
>> wrapper like jdkCompat ( i.e. a base class with the 1.3 implementation,
>> extended with a 1.4 impl ). This class could include other 1.4 methods
>> and their 1.3 equivalent, if any.
> 
> Well, I was planning to implement it as:
> 
> try {
>   // do the nasty 1.4 stuff with reflection
> } catch (Throwable t) {
>   // do the compatible stuff
> }
> 
> It's not nice but it works (and as the CL is cached, we don't care too
> much about the performance loss due to the exception).

It works - but programming control statements via exceptions is ugly.
And very likely the code will be cut&pasted in other places.

Having a base jdkCompat will allow this code to be reused and will be
cleaner ( IMO ).

Not a big deal...


Costin


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


Re: [PATCH] allow tomcat5 to compile/run with JDK1.3

Posted by Remy Maucherat <re...@apache.org>.
Costin Manolache wrote:
> Remy Maucherat wrote:
> 
> 
>>Tim Funk wrote:
>>
>>>Tomcat5 does not compile with JDK1.3. It does with JDK1.4.
>>>
>>>There is only one line of code that prevents it from compiling with
>>>JDK1.3. org.apache.catalina.loader.WebappClassLoader depends on
>>>File.toURI() which does not exist on jdk1.3.
>>>
>>>I got around this by the performing the following:
>>>OLD CODE:
>>>  return realFile.toURI().toURL();
>>>NEW CODE
>>>  return new URL("file:" + realFile.toURL().getPath());
>>>
>>>My patch also has some spurious stuff because my text editor
>>>automatically strips all trailing whitespace from lines and converts
>>>tabs to spaces. The important stuff is the last 9 lines of the patch
>>>file.
>>
>>The patch is a bad idea. The change was made to fix RMI related problems.
>>
>>What should be done is invoke the appropriate methods through
>>reflection, catching any error (and defaulting to the old code if it
>>fails).
> 
> 
> Well, reflection is a bad idea too :-) A better solution is to use a 
> wrapper like jdkCompat ( i.e. a base class with the 1.3 implementation,
> extended with a 1.4 impl ). This class could include other 1.4 methods
> and their 1.3 equivalent, if any.

Well, I was planning to implement it as:

try {
  // do the nasty 1.4 stuff with reflection
} catch (Throwable t) {
  // do the compatible stuff
}

It's not nice but it works (and as the CL is cached, we don't care too 
much about the performance loss due to the exception).

> This would allow implementing the correct stuff, instead of failing. 

Sure.

Remy


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


Re: [PATCH] allow tomcat5 to compile/run with JDK1.3

Posted by Costin Manolache <cm...@yahoo.com>.
Remy Maucherat wrote:

> Tim Funk wrote:
>> Tomcat5 does not compile with JDK1.3. It does with JDK1.4.
>> 
>> There is only one line of code that prevents it from compiling with
>> JDK1.3. org.apache.catalina.loader.WebappClassLoader depends on
>> File.toURI() which does not exist on jdk1.3.
>> 
>> I got around this by the performing the following:
>> OLD CODE:
>>   return realFile.toURI().toURL();
>> NEW CODE
>>   return new URL("file:" + realFile.toURL().getPath());
>> 
>> My patch also has some spurious stuff because my text editor
>> automatically strips all trailing whitespace from lines and converts
>> tabs to spaces. The important stuff is the last 9 lines of the patch
>> file.
> 
> The patch is a bad idea. The change was made to fix RMI related problems.
> 
> What should be done is invoke the appropriate methods through
> reflection, catching any error (and defaulting to the old code if it
> fails).

Well, reflection is a bad idea too :-) A better solution is to use a 
wrapper like jdkCompat ( i.e. a base class with the 1.3 implementation,
extended with a 1.4 impl ). This class could include other 1.4 methods
and their 1.3 equivalent, if any.

This would allow implementing the correct stuff, instead of failing. 

Costin



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


Re: [PATCH] allow tomcat5 to compile/run with JDK1.3

Posted by Remy Maucherat <re...@apache.org>.
Tim Funk wrote:
> Tomcat5 does not compile with JDK1.3. It does with JDK1.4.
> 
> There is only one line of code that prevents it from compiling with JDK1.3.
> org.apache.catalina.loader.WebappClassLoader depends on File.toURI() 
> which does not exist on jdk1.3.
> 
> I got around this by the performing the following:
> OLD CODE:
>   return realFile.toURI().toURL();
> NEW CODE
>   return new URL("file:" + realFile.toURL().getPath());
> 
> My patch also has some spurious stuff because my text editor 
> automatically strips all trailing whitespace from lines and converts 
> tabs to spaces. The important stuff is the last 9 lines of the patch file.

The patch is a bad idea. The change was made to fix RMI related problems.

What should be done is invoke the appropriate methods through 
reflection, catching any error (and defaulting to the old code if it fails).

Remy


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