Re: Why is Tomcat/Connector Installation So Incredibly Painful??

2004-09-08 Thread Greg Ward
On 07 September 2004, Endre St?lsvik said:
 The mod_jk approach of inventing a new binary protocol and whatnot is
 maybe not the right solution for this. A simple raw forwarding of the
 requests from Apache HTTPD to Apache Tomcat would be incredibly nice.

Do what I did: try to replace mod_jk with mod_proxy.  Do this on a
server where some requests are SSL and some are not, and where redirects
(eg. /foo - http://www.example.com/foo/;) need to work, and you'll
start to understand (like I did) why the AJP protocol exists:

  * to forward both SSL and non-SSL requests with mod_proxy, you'd
need two HTTP connectors in Tomcat, meaning two thread pools

  * to handle server-generated redirects (which includes
response.sendRedirect() calls in your webapps), you need to ensure
that Tomcat knows the name of the server as seen by clients -- in
our environment (hundreds of servers to administer worldwide behind
NAT firewalls with poor DNS control), this is rather tricky, and
would most likely mean generating server.xml when Tomcat starts up.
(No, we don't handle this very well with Apache either, but at least
we don't need to dynamically generate httpd.conf -- we just include
a servername.conf file that's generated when Apache's config files
are installed on that server.)

Once I hit those two stumbling blocks, I backed off and decided to live
with mod_jk for a while longer.  (They're not insurmountable, but I have
better things to do with my time.)

Greg

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Why is Tomcat/Connector Installation So Incredibly Painful??

2004-09-08 Thread Greg Ward
[me]
  * to forward both SSL and non-SSL requests with mod_proxy, you'd
need two HTTP connectors in Tomcat, meaning two thread pools

[Yoav Shapiro]
 This is a serious stumbling block?  Really?  I buy your other
 (redirect-related) argument but not this one at all.  You can easily
 configure thread pools to consume almost no resources when they're not
 used.

It wasn't the overhead of the extra thread pool that bothered me, it's
more the fact that Tomcat would be unable to amortize thread creation as
well.  Eg. if I have one thread pool with max 75 threads for *all*
requests, then Tomcat only has to create 75 threads, period.  But if I
need a pool of (say) 50 threads for SSL requests and another 50 for
non-SSL requests, then Tomcat might need to create 100 threads.  (Also,
it's harder to know if my numbers are right -- it's like partitioning a
hard disk into two partitions that you *think* will do the trick versus
creating one big partition for everything.  The latter almost always
wins.)

I doubt this would have much of a performance impact, and I didn't
bother to implement and measure it.  It's just the howling inelegance of
the whole scheme that bugged me.  That was when the little now I know
why AJP and mod_jk exist light bulb clicked on.  ;-)

Greg

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Why is Tomcat/Connector Installation So Incredibly Painful??

2004-09-07 Thread Greg Ward
On 03 September 2004, Peter Alvin said:
 But why is it so
 incredibly painful to install Apache/Tomcat/Connector?  It always
 takes me about two days.  I look forward to it as much as doing my
 federal tax returns.

I'm in complete agreement with you.  Even finding the right files to
download is a bit of a chore.  (OK, so everyone says I need mod_jk.
Therefore I'm looking for a file called...
jakarta-tomcat-connectors-jk-1.2.6-src.tar.gz.  Rght.  Well, at
least they have two letters in common.)

Here's an interesting experiment: google'ing for mod_jk finds this
page:
  http://jakarta.apache.org/site/binindex.cgi
as the second hit.  But the string mod_jk occurs nowhere in that page;
you have to hunt around until you realize that what you're really
looking for is Tomcat Web Server Connectors.  And then you only get to
the binary releases page, which is useless -- I need the source,
dammit!

Oh, the *first* Google hit for mod_jk is
  http://jakarta.apache.org/tomcat/tomcat-3.3-doc/mod_jk-howto.html
which I think most people who are working with Tomcat 4.1.x or 5.0.x
would probably ignore based on the URL.

Anyways, once you've downloaded the source (which I've already forgotten
how to do -- luckily I kept a local copy), you then have to figure out
*what* to build in that tree and where to find it.  Not obvious.  And
it's different from mod_jk to mod_jk2.  And then getting things to build
is even less obvious.

Alas, I don't have time to do anything more than bitch and gripe.
Whoever is actually maintaining mod_jk, mod_jk2, and associated web
pages, please hear our cries!

Greg

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: RHEL 3.0, Tomcat 4.x and IPTables

2004-09-02 Thread Greg Ward
On 02 September 2004, Sean Finkel said:
 When Tomcat hangs, what happens is, half the page is returned to the 
 browser and the status bar sits at waiting for domain.com. As Soon as 
 I issue service iptables stop the page finishes loading, and I cannot 
 make any other pages half-load. Any apache process that were tied up 
 waiting on tomcat stay hung though, and I have to either manually kill 
 those PIDS or issue a SIGHUP to Apache. When only a few are hung, I kill 
 them, as to not interrupt downloads for other users. However, when 92 
 are hung, I just SIGHUP apache.

Sounds like you need to list your firewall rules:

  iptables -nL

If you don't know how to interpret the output, the netfilter howto is
only a click away (http://www.netfilter.org/documentation/).  Or post it
here and maybe someone can help.  ;-)

Greg

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Tomcat 4.1.29 - Special chars in a file name

2004-08-31 Thread Greg Ward
On 31 August 2004, Surendra Kumar said:
 Hi
I am using Tomcat 4.1.29 + Apache 1.3.31.  In one of my webapp i have a file 
 named test+.gif

Probably a URL encoding problem -- if a web page includes

  a href=test+.gif

then the browser will ask for test .gif, because test+.gif is one of
the ways to encode test .gif so it's a legal URL.  (The other is
test%20.gif.)

Whatever code is generating 

  a href=test+.gif

is wrong -- it should be

  a href=test%2B.gif

which the browser will decode to test+.gif.

Greg

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



IllegalStateException from java.nio.charset.CharsetEncoder

2004-08-31 Thread Greg Ward
On one of our servers, we're using Tomcat 4.1.29 under Java 1.4.2_02,
connecting to Apache 2.0.48 with mod_jk 1.2.4, all running on Red Hat
Linux 6.2.  (Wow, what a zoo of version numbers!)

Recently we got a support call because some (all?) HTTP requests were
failing with Internal Server Error.  The support tech who took the
call noticed this in mod_jk's log file:

[Sat Aug 28 15:59:39 2004] [jk_ajp_common.c (1309)]: sending request to tomcat failed 
in send loop. err=2
[Sat Aug 28 15:59:39 2004] [jk_ajp_common.c (1318)]: Error connecting to tomcat. 
Tomcat is probably not started or is listening on the wrong port. Failed errno = 104 

(Errno 104, for the curious, is ECONNRESET -- Connection reset by
peer.)

He tried restarting Tomcat, which sounds like the right thing to me.
That didn't help, so then he tried restarting Apache.  Still nothing, so
he rebooted the server, after which things started working again.
H.

Looking in catalina.out after the reboot, I saw this stack trace:

  java.lang.IllegalStateException: Current state = FLUSHED, new state = CODING_END
  at 
java.nio.charset.CharsetEncoder.throwIllegalStateException(CharsetEncoder.java:933)
  at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:529)
  at sun.nio.cs.StreamEncoder$CharsetSE.flushLeftoverChar(StreamEncoder.java:358)
  at sun.nio.cs.StreamEncoder$CharsetSE.implClose(StreamEncoder.java:414)
  at sun.nio.cs.StreamEncoder.close(StreamEncoder.java:160)
  at java.io.OutputStreamWriter.close(OutputStreamWriter.java:222)
  at java.io.PrintWriter.close(PrintWriter.java:137)
  at org.apache.catalina.connector.ResponseBase.finishResponse(ResponseBase.java:483)
  at 
org.apache.catalina.connector.HttpResponseBase.finishResponse(HttpResponseBase.java:253)
  at org.apache.ajp.tomcat4.Ajp13Response.finishResponse(Ajp13Response.java:191)
  at org.apache.ajp.tomcat4.Ajp13Processor.process(Ajp13Processor.java:479)
  at org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:576)
  at java.lang.Thread.run(Thread.java:534) 

Of course, catalina.out is clobbered with every Tomcat restart, so
there's no way of knowing if this exception is actually the cause of the
problem, i.e. if it was happening before the first Tomcat restart.
Nevertheless, I poked around a bit and stumbled across these two entries
in Tomcat's bug database:

  http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7725
  http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6519

Both of these have a *nearly* identical stack trace (the connector is
different -- org.apache.catalina.connector.http.HttpProcessor vs
org.apache.ajp.tomcat4.Ajp13Processor in my example) that ends with the
same IllegalStateException.  Both are about 2 years old, around the time
that Tomcat 4.0 and Java 1.4 were in beta.  And it sorta-kinda-vaguely
sounded like the bug(s), whatever they were, have been fixed.

First of all, from those two bug reports, it's not clear if this is a
Tomcat bug or a Java bug.  Second of all, has anyone else seen this on
stable, mature versions of Tomcat 4.0 and Java 1.4 (ie. 4.0.29 and
1.4.2_02)?

Thanks --

Greg

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: change mod_jk2.conf without restarting Apache

2004-08-25 Thread Greg Ward
On 23 August 2004, Richard Dyson said:
  I'm working on a web application (platform details - SuSE 8.2, Apache 2.0.50, 
 mod_jk2 as the connector between Tomcat and Apache). 
  
  My intention is to make changes to mod_jk2.conf (add/remove LocationMatch 
 blocks), and have Apache pick them up without my having to restart the server. Is it 
 even possible to do that?

Well, this is really an Apache question, not a Tomcat question.  And I'm
hardly a world-renowned Apache expert, just a bloke who's been using it
and reading its fine manual for many years.  So take the following with
a grain of salt.

Apache never magically re-reads config files.  You have to make it
re-read them.  The clean way to do this is with apachectl graceful
which, if I understand it correctly, instructs each child worker to
finish processing its current request and then terminate.  The parent
(controlling process) will re-read its config files (and reopen its log
files), and replace each worker in turn by new ones that have the new
configuration.

See http://httpd.apache.org/docs-2.0/stopping.html for details.

Greg

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ajp1.3 errors while using tomcat 5.0.25, apache 2.0.49, modjk2

2004-08-20 Thread Greg Ward
On 17 August 2004, dawg fan said:
 
 I get the following error in apache's error logs while testing tomcat
 under extreme load:
 
 [Tue Aug 17 14:15:25 2004] [error] channelApr.receive(): Error
 receiving message body -1 11
 [Tue Aug 17 14:15:25 2004] [error] workerEnv.processCallbacks() Error
 reading reply
 [Tue Aug 17 14:15:25 2004] [error] ajp13.service() ajpGetReply
 recoverable error 12

I got exactly the same thing, but it didn't require extreme load -- if I
remember correctly, it generally started happening after a handful of
requests (3-5?) had been processed, and after that it happened fairly
regularly -- not every request, but often enough.  This was on a test
server that only I was hitting.

At the time, I google'd for those error messages, and saw that various
people over the last year or two have asked about them, and never saw
any constructive response.  I also asked the question on this list a few
weeks ago, and got no response.

Apparently, either mod_jk2 is unmaintained, or its maintainers do not
read this list.  ;-(  I wonder how to contact them?

Greg

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



HttpConnector: seting proxyName dynamically

2004-08-11 Thread Greg Ward
Hello -- I'm trying to setup Apache 2.0.50 and Tomcat 4.1.30 together,
with requests relayed from Apache to Tomcat using mod_proxy.  (We've
been using mod_jk for many months, but have observed random,
hard-to-reproduce flakiness, so I'm investigating the possibility of
dropping mod_jk in favour of mod_proxy.)

Everything works fine as long as I set proxyName and proxyPort in the
Connector element, eg.:

Connector className=org.apache.catalina.connector.http.HttpConnector
   address=127.0.0.1 port=8180
   proxyName=servername proxyPort=80
   minProcessors=1 maxProcessors=5
   acceptCount=5 debug=0 connectionTimeout=3/

(Without those, redirects didn't work: a request for /foo should have
been redirected to http://servername.domain/foo/;, but was actually
redirected to http://localhost:8180/foo/;, because Tomcat had no clue
what hostname was used by the outside world.)

No problem, right?  Well, there is: we install Apache and Tomcat on
hundreds of servers at dozens of customer sites, and manually editing
server.xml to set the server hostname every time we setup or upgrade a
server is not an option.

For Apache, we have this line in httpd.conf:

  Include conf/servername.conf

and create servername.conf at installation time like this:

  echo ServerName `hostname`  conf/servername.conf

This works like a charm, at least until the server changes names.  ;-)

So I'd like to cook up something like this for Tomcat.  I suppose I
could hold my nose and install a default server.xml that looks like
this:

Connector className=org.apache.catalina.connector.http.HttpConnector
   address=127.0.0.1 port=8180
   proxyName=@SERVERNAME@ proxyPort=80
   minProcessors=1 maxProcessors=5
   acceptCount=5 debug=0 connectionTimeout=3/

and then do some sed magic at installation time, but, well, blecc.
Surely there's a better way!

Ideas?

Greg

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: HttpConnector: seting proxyName dynamically

2004-08-11 Thread Greg Ward
On 11 August 2004, I said:
 Everything works fine as long as I set proxyName and proxyPort in the
 Connector element, eg.:
 
 Connector className=org.apache.catalina.connector.http.HttpConnector
address=127.0.0.1 port=8180
proxyName=servername proxyPort=80
minProcessors=1 maxProcessors=5
acceptCount=5 debug=0 connectionTimeout=3/

Interesting: I just noticed that
org.apache.catalina.connector.http.HttpConnector is deprecated, so
changed my test config to use org.apache.coyote.tomcat4.CoyoteConnector,
as recommended by
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/config/connectors.html .

But that broke redirects in a different way!  With HttpConnector,
properly configured with proxyName and proxyPort, /myapp is
redirected to http://servername/myapp/; -- good.  But if I change that
Connector to use CoyoteConnector (no other changes), it's redirected
to http://servername/; -- the context URI is dropped!

Is this a bug in CoyoteConnector?

Greg

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Can't compile jk 1.2.6

2004-08-04 Thread Greg Ward
On 03 August 2004, Joseph Shraibman said:
 Then configure ends with:
 creating libtool
 checking for test... /usr/bin/test
 checking for rm... /bin/rm
 checking for grep... /bin/grep
 checking for echo... /bin/echo
 checking for sed... /bin/sed
 checking for cp... /bin/cp
 checking for mkdir... /bin/mkdir
 checking for snprintf... yes
 checking for vsnprintf... yes
 no apxs given
 checking for target platform... unix
 no apache given
 configure: error: Cannot find the WebServer
 
 
 But the apxs does exist.  This is apache 2.0.50

I believe you need to run

  ./configure --with-apxs=${apache_prefix}/bin/apxs

where $apache_prefix is wherever you installed Apache
(eg. /usr/local/apache2).

Greg

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ajp over ssl

2004-08-04 Thread Greg Ward
On 03 August 2004, Michael J?rgens said:
 No I want to connect an apache webserver over internet to a tomcat
 server. So far I have no problem.
 My problem is, how to secure the connection between apache and tomcat.

One idea: you could use mod_proxy as the Apache/Tomcat connection rather
than mod_jk, and then configure Tomcat to do SSL.  Then Apache and
Tomcat are just talking HTTP over SSL; a bit less efficient than mod_jk,
perhaps, but probably easier to configure.  No idea if mod_proxy can
proxy HTTP connections to HTTPS; you might have to force clients to use
HTTPS to make it happen.  Just a wild idea.

Greg



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



mod_jk2: channelApr.receive(): Error receiving message body

2004-07-21 Thread Greg Ward
I've just compiled Apache 2.0.50 and mod_jk2 2.0.4.  (We've been using
mod_jk 1.2.4 for a while, and it seems to work -- but we have observed
occasional problems with response bodies being truncated.  So I figured
as long as I'm building a new Apache, might as well throw in mod_jk2 and
see if it helps with that problem.)

Anyways, I got the basic configuration working, can access our web apps,
and so forth.  But I notice these three lines in Apache's error_log
rather frequently:

[Wed Jul 21 16:57:37 2004] [error] channelApr.receive(): Error receiving message body 
-1 11
[Wed Jul 21 16:57:37 2004] [error] workerEnv.processCallbacks() Error reading reply
[Wed Jul 21 16:57:37 2004] [error] ajp13.service() ajpGetReply recoverable error 12

I can't figure out a pattern here -- it happens with a browser and with
command-line clients, on the server itself or from a different host.

The requests where mod_jk2 logs these errors do not seem to be affected
-- I haven't seen any garbled/truncated response bodies.

The numbers (-1, 11, 12) are always the same.  I took a brief look
in the mod_jk2 source to see where the first error is coming from; I was
not enlightened.  Haven't done any digging for the other two.

Does anyone have a clue what these errors mean?  Should I forget about
upgrading to mod_jk2, ie. is it flakier than the original mod_jk or not?

Thanks --

Greg

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Thread reuse question (Tomcat 4.1)

2004-06-08 Thread Greg Ward
I have a question motivated by our application's slightly peculiar
logging requirements.  (Details below, if you're curious.)

Specifically, does Tomcat 4.1 reuse request-processing threads across
web apps, or only within a single web app?  I.e. if thread X is created
to service a request for web app #1, will that thread ever be used to
service requests for any other web app?  Or is it exclusively devoted to
the use of web app #1?

Rationale: we'd like our web apps to have per-user log files; this is
for a moderate-traffic, high-log-output family of applications, so
separating the log output by user makes sense.  The obvious way to do
that is have a thread-local log object that is initialized when starting
a request, and closed when finishing the request.

The catch: what state do I leave the ThreadLocal in when finishing each
request?  Right now, I'm pointing it to the default log file for the
current web app, eg. app1.log.  But if the thread that just processed a
request for web app #1 is reused for web app #2, and web app #2 does not
set the thread-local log object correctly, things will get confusing --
some libraries used by web app #2 in processing the request will log to
the thread-local log object, namely app1.log.

So at the very least, I'd like to know how Tomcat 4.1 reuses threads.
Better yet, I'd like to know if the servlet spec makes any guarantees in
this are -- I've read what I think are the relevant sections (2.2, 2.3),
but I didn't see anything.

Thanks --

Greg

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: HTML quoting

2003-10-03 Thread Greg Ward
On 02 October 2003, Andy Eastham said:
 Standard one is java.net.URLEncoder.encode() and
 java.net.URLEncoder.decode()

No.  HTML quoting and URL encoding are quite different.

URLEncoder.encode() on my test string returns

  Jeb+said%2C+%22Hell+%26+damnation%21+Is+5+%3E+4%3F%22

(It would also be correct to replace every space with %20.)

HTML quoting is for handlingand maybe  '.  Eg. Python's cgi.escape()
returns

  Jeb said, Hell amp; damnation! Is 5 gt; 4?

while Perl's CGI::escapeHTML() returns

  Jeb said, quot;Hell amp; damnation! Is 5 gt; 4?quot;

Hmmm, I see that Python's cgi.escape() has an optional arg to specify
quoting  characters.  Looks like Perl's CGI::escapeHTML() always quotes
quotes.  That's essential for cases like

  out.print(input name=\foo\ value=\ + someUserSuppliedValue + \)

-- if someUserSuppliedValue has  characters in it, they must be quoted!

Greg

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: HTML quoting

2003-10-03 Thread Greg Ward
On 02 October 2003, Tim Funk said:
 JSTL by default escapes all output to be HTML friendly
 c:out value=${myValue}/
 and to disable:
 c:out value=${myValue} escapeXML=false/

Alas, I'm working on some crufty old servlets that are chock full of

  System.out.println( ... boatloads of HTML ...);

We plan to move to a real template language one of these days, but for the
time being we're stuck maintaining this vile code.  ;-(

I asked on the Tomcat list because I know that lots of people who know lots
about web development with Java hang out here...

Greg

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



HTML quoting

2003-10-02 Thread Greg Ward
What's the standard way of quoting text for inclusion in a web page in
Java?  Ie. I need a method to convert the string

  Jeb said, Hell  damnation! Is 5  4?

to

  Jeb said, quot;Hell amp; damnation! Is 5 gt; 4?quot;

(I think: I've never been entirely sure what the right way to handle
quotes is.)  That is, I want the standard Java equivalent of Python's
cgi.escape(), or Perl's CGI::escapeHTML().

To my utter amazement, I cannot find any indication that such a method
even exists in the standard Java library!  (I tried Google'ing and
poking through the JDK 1.4 docs.)

So I went looking in the source for Tomcat 4.1.27 -- surely the HTML
version of the manager app must quote at least the webapp's display
name, since it comes from a user-supplied file and therefore might
contain funny characters.  Surprisingly, the manager just lets funny
characters through without touching them.  Eg. if you put

  display-namefoo amp; bar webapp/display-name

then amp; is translated back to  by some part of the XML-parsing
chain, and is emitted as  in the manager HTML page.  Most browsers
can deal with minor violations like this, but it's still technically
incorrect.  Just for fun I tried this:

  display-namemy lt;scriptgt;alert(foo);lt;/scriptgt;/display-name

...and it works!  The manager emits this HTML:

 td class=row-leftsmallmy scriptalert(foo);/script webapp/small/td

and my browser pops up a JavaScript window while rendering the manager
page.  Cool!  I doubt this is a security hole -- not many people can
edit web.xml! -- but surely it at least counts as a rendering bug.  ;-)

So: can someone tell me what the standard way of quoting text for
inclusion in a web page generated by a Java web application is?

Thanks!

Greg

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Stop Tomcat Remotely

2003-09-24 Thread Greg Ward
On 24 September 2003, srinath narasimhan said:
 Is there any way to stop tomcat from remote computer ?
 Tomcat is run as windows service.

Well, how do you normally run commands remotely with Windows?
If the server is a Unix box, you could do this:

  ssh [EMAIL PROTECTED] $CATALINA_HOME/bin/catalina.sh stop

or even this:

  ssh [EMAIL PROTECTED] echo SHUTDOWN | nc localhost 8005

If Windows doesn't have a way to execute commands remotely, what on
earth are you doing using it as a server OS?

Greg

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Simple command-line manager tool?

2003-09-23 Thread Greg Ward
Has anyone written a simple command-line interface to the Tomcat
Manager?  Having Ant tasks is nice, but I have no intention of
installing Ant on our production servers.  I'm thinking of something
like this:

  # tomcat restart app1
  # tomcat stop app2

...where all the script does is stitch the command-line args into a URL,
send the HTTP request, wait for the Manager's response, and report
success/failure.

Surely I'm not the first one to want such a tool...

Greg

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Disabling session management (FAQ not enough)

2003-09-22 Thread Greg Ward
On 20 September 2003, Chris Rolfe said:
 You might try: 
 
 Manager classname=org.apache.catalina.session.StandardManager
 pathname= /

Yep, I eventually found that in the O'Reilly Tomcat book.  Turns out
classname isn't even necessary, so this is a
one-line-of-XML-per-context configuration change.

Thanks!

Greg

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Disabling session management (FAQ not enough)

2003-09-18 Thread Greg Ward
I would like to completely disable Tomcat session management.  I'm in
the process of porting a legacy app with homebrew session management
from JServ to Tomcat, and I want to keep using that homebrew session
management for the time being.  (I'm using Tomcat 4.1.24, JDK 1.4.0.)

Currently, Tomcat's StandardSessionManager is getting in the way; it

  * writes an empty (well, 81-byte) SESSIONS.ser for every webapp
at shutdown

  * logs lots of stack traces at startup and shutdown, because the
classes in that old session management scheme are not serializable
(but they are accessible via the HttpSession objects)

So, of course I consulted the FAQ, which says this:

   Look at the Session manager component and tweak accordingly.

That sentence is actually a link to
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/config/manager.html,
which has lots of information on how to configure StandardSessionManager
and PersistentSessionManager -- but nothing at all on completely
disabling Tomcat's session management.  Arggh.  My naive attempt was to
add this:

  Manager pathname=/dev/null /

to one of my Context elements, but that didn't work -- Java barfs
(EOFException) trying to read a serialized file from /dev/null.

Surely someone has written a dummy session manager class that does
nothing...

Greg

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Disabling session management (FAQ not enough)

2003-09-18 Thread Greg Ward
On 18 September 2003, Greg Ward said:
 Surely someone has written a dummy session manager class that does
 nothing...

OK, I took a crack at this.  My first attempt at DummySessionManager
looked like this:

import org.apache.catalina.Manager;


class DummySessionManager implements Manager
{
  public Container getContainer()
  {
  return null;
  }

  public void setContainer(Container container)
  {
  }

  public DefaultContext getDefaultContext()
  {
  return null;
  }

  [... you get the idea ...]

}

Never mind worrying about whether all those return null statements
will cause NullPointerExceptions later on; Tomcat can't even create
DummySessionManager objects.  (I put DummySessionManager.class in
server/classes so Tomcat could at least load it.)  catalina.sh run
dies with this exception:

java.lang.IllegalAccessException: Class org.apache.commons.digester.ObjectCreateRule 
can not access a member of class DummySessionManager with modifiers 
at org.apache.commons.digester.Digester.createSAXException(Digester.java:2540)
at org.apache.commons.digester.Digester.createSAXException(Digester.java:2566)
at org.apache.commons.digester.Digester.startElement(Digester.java:1276)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown 
Source)
at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
 Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 
Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.commons.digester.Digester.parse(Digester.java:1548)
at org.apache.catalina.startup.Catalina.start(Catalina.java:449)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
at org.apache.catalina.startup.Catalina.process(Catalina.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)

Arrggh.  Now what?  Do I have to add some magic to catalina.policy?
(Wild guess -- so far, I have remained happily ignorant of Java security
policy stuff.)

Greg

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Memory leaks?

2003-09-04 Thread Greg Ward
On 03 September 2003, Jim Lynch said:
 OK, that's probably what's going on.  I know I should close Statements
 and Connections and do normally but I'm fairly certain I've some out
 there dangling.  I didn't know you had to close ResultSets, however. 
 Glad to know that.

You don't have to close ResultSets -- check the JDBC docs:

  http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Statement.html#close()

(Closing a Statement also closes any open ResultSets associated with
that Statement.)

Greg

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: setting the field focus with a servlet

2003-09-04 Thread Greg Ward
On 04 September 2003, Luke Vanderfluit said:
 I am working on a servlet that checks a form content without using
 javascript.
 
 Does anyone know if there is a way to set the focus to a particular
 field using java?

I think you need to learn how HTML forms work and interact with the
browser.  If you want to control the browser at this level, you need to
do it with JavaScript.  In general, Java code (servlets, JSPs, whatever)
run on your web server, not in the user's browser.  (Of course that's
not the case if you're using applets, but the only thing that sucks more
than trying to get JavaScript working portably across browsers is trying
to get Java applets working portably across browsers.  ;-( )

Greg


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]