Re: Apache http / mod_rewrite / mod_jk

2004-04-08 Thread Christopher Schultz
Yoav,

Do you know if this is supposed to work?

JkMount /myapp/*;jsessionid=* workerX

It has allegedly worked for some other people.
I don't know if it's supposed to work.  Is it difficult to test?
I have tested it. It does not work for me. Others claim that it does 
work. I'm wondering if I have something wrong. I've been using mod_jk 
for years with no problems. I have multiple workers and multiple 
applications, all running fine.

This particular directive seems to be ignored on my setup. I guess I'll 
just look at the module source and figure it out myself.

-chris


signature.asc
Description: OpenPGP digital signature


Re: Apache http / mod_rewrite / mod_jk

2004-04-08 Thread Christopher Schultz
Kenneth,

Instead of directly redirect to mod_jk, can you just use mod_write to
insert a directory prefix which can trigger mod_jk?
That's an idea. If I did that, how could I get Tomcat to figure out the 
right path, then? Can I do a reverse rewrite in Tomcat?

Thanks,
-chris


signature.asc
Description: OpenPGP digital signature


Re: Apache http / mod_rewrite / mod_jk

2004-04-08 Thread Christopher Schultz
All,

JkMount /myapp/*;jsessionid=* workerX

This particular directive seems to be ignored on my setup. I guess I'll 
just look at the module source and figure it out myself.
It turns out that mod_jk does not consider ;jsessionid= part of the 
URL when it does matching. :(

From mod_jk.log:

[jk_uri_worker_map.c (486)]: Into jk_uri_worker_map_t::map_uri_to_worker
[jk_uri_worker_map.c (500)]: Attempting to map URI 
'/app/includes/css/styles.css'
[jk_uri_worker_map.c (618)]: jk_uri_worker_map_t::map_uri_to_worker, 
done without a match
[jk_uri_worker_map.c (486)]: Into jk_uri_worker_map_t::map_uri_to_worker
[jk_uri_worker_map.c (500)]: Attempting to map URI '/app/images/select.gif'
[jk_uri_worker_map.c (618)]: jk_uri_worker_map_t::map_uri_to_worker, 
done without a match

Both of these URLs definately have the session id attached to them.

jk_uri_worker_map.c::map_uri_to_worker contains the following code 
torards the beginning of the function:

char *url_rewrite = strstr(uri, JK_PATH_SESSION_IDENTIFIER);

if(url_rewrite) {
*url_rewrite = '\0';
}
jk_no2slash(uri);
So, they completely strip-out the sessionid before checking 
(JK_PATH_SESSION_IDENTIFIER = ;jsessionid).

My conclusion is that there's no support for this kind of think in 
mod_jk. The following matches are supported (from the code docs):


* Exact Context - /exact/uri=worker e.g. /examples/do*=ajp12 *
* Context Based - /context/*=worker e.g. /examples/*=ajp12   *
* Context and suffix -/context/*.suffix=worker e.g. /examples/*.jsp=ajp12*

It's not a simple fix to add the kind of checking I'm talking about. 
I'll poke around to find out how this might be done.

If there are any mod_jk hackers on the list reading this thread, please 
let me know. Also, if anyone knows if this works in other connectors 
(i.e. jk2), please let me know.

I'm putting all of this in a post so that it gets into the archives.

I'm also adding this sentence to help out with searches: The problem is 
with jsessionid, Apache, mod_jk and is most often characterized by 
broken images and failure to load stylesheets when URLs are encoded in 
Java doe these resources.

Thanks,
-chris


signature.asc
Description: OpenPGP digital signature


Re: Apache http / mod_rewrite / mod_jk [hacked SOLUTION]

2004-04-08 Thread Christopher Schultz
All,
Here is my solution to the jsessionid issue discussed in this thread.
The problem is that when Tomcat encodes URLs without knowing if the 
browser supports cookies, it adds ;jsessionid=BLAHBLAH to each encoded 
URL. This is perfectly normal behavior.

However, when using Apache httpd, Apache does not properly handle the 
addition of the ;jsessionid information, and fails to serve up the 
proper file.

One of the simplest solutions is to simply pass requests including the 
jsessionid information to Tomcat and let Tomcat handle them.

mod_jk does not support this type of behavior, since it only does simple 
context matches (like /context/*, suffix-based context matches 
(/context/*.suffix) or exact matches (/context/j_security_check).

I have modified mod_jk to allow URIs of this special form:

/context/*;jsessionid*

So you can actually do this in your configuration file:

JkMount /context/*;jsessionid* my_worker

The syntax matches what I figured was the most natural way to write this 
in a configuration file. Note that this fix does not actually let you 
use wildcards as flexibly as the config directive would lead you to 
believe. It only works with the specific string *;jsessionid* after 
the context and slash character.

Below is the diff for jk_uri_worker_map.c. It works on my configuration. 
I hope it may help others. I would love to receive any constructive 
criticism of this patch. Feel free to email me directly.

All the best,
-chris
=
[EMAIL PROTECTED] common]$ diff -bc jk_uri_worker_map.c jk_uri_worker_map.c.new
*** jk_uri_worker_map.c 2003-09-06 11:37:21.0 -0400
--- jk_uri_worker_map.c.new 2004-04-08 10:07:36.0 -0400
***
*** 80,85 
--- 80,86 
  #define MATCH_TYPE_GENERAL_SUFFIX (3) /* match all URIs of the form 
*ext */
  /* match all context path URIs with a path component suffix */
  #define MATCH_TYPE_CONTEXT_PATH (4)
+ #define MATCH_TYPE_JSESSIONID (5) /* match all URLs that contains a 
jsessionid */

  struct uri_worker_record {
  /* Original uri for logging */
***
*** 300,305 
--- 301,316 
 Into 
jk_uri_worker_map_t::uri_worker_map_open, 
   suffix rule %s.%s=%s was added\n,
  uri, asterisk + 3, worker);
+   } else if(0 == strncmp(/* JK_PATH_SESSION_IDENTIFIER 
*,asterisk,14) ) {
+ /* jsessionid interceptor */
+ asterisk[1] = '\0';
+   uwr-worker_name = worker;
+   uwr-context = uri;
+   uwr-match_type = MATCH_TYPE_JSESSIONID;
+   jk_log(l, JK_LOG_DEBUG,
+  Into jk_uri_worker_map_t::uri_worker_map_open, 
+  jsessionid rule %s*;jsessionid*=%s was added\n,
+  uri, worker);
} else if ('\0' != asterisk[2]) {
/* general suffix rule */
asterisk[1] = '\0';
***
*** 478,483 
--- 489,522 
  *d = '\0';
  }

+ uri_worker_record_t *check_jsessionid_matches(char *uri,
+ jk_uri_worker_map_t *uw_map,
+ jk_logger_t *l)
+ {
+   unsigned i;
+   uri_worker_record_t *match = NULL;
+
+   for(i = 0 ; i  uw_map-size ; i++) {
+ uri_worker_record_t *uwr = uw_map-maps[i];
+
+ if(MATCH_TYPE_JSESSIONID == uwr-match_type) {
+   /* Check context match */
+
+   if(0 == strncmp(uwr-context,
+ uri,
+ uwr-ctxt_len)) {
+   /* Looks like a match: URI contains ;jsessionid, context 
matches */
+
+   jk_log(l, JK_LOG_DEBUG, check_jsessionid_matches: Found context 
match: %s\n, uwr-context);
+
+   match = uwr;
+   break;
+   }
+ } /* MATCH_TYPE_JSESSIONID */
+   } /* foreach mapping */
+
+   return match;
+ }

  char *map_uri_to_worker(jk_uri_worker_map_t *uw_map,
  char *uri,
***
*** 493,498 
--- 532,544 
  char *url_rewrite = strstr(uri, JK_PATH_SESSION_IDENTIFIER);
  if(url_rewrite) {
+ uri_worker_record_t *match = check_jsessionid_matches(uri, 
uw_map, l);
+ if(NULL != match) {
+   jk_log(l, JK_LOG_DEBUG, Mapped URI %s to context %s using 
jsessionid match\n, uri, match-context);
+
+   return match-worker_name;
+ }
+
  *url_rewrite = '\0';
  }
  jk_no2slash(uri);


signature.asc
Description: OpenPGP digital signature


Re: Apache http / mod_rewrite / mod_jk [hacked SOLUTION]

2004-04-08 Thread Christopher Schultz
All,

There was a bug in the patch that I posted. Below is the final patch I 
will post to the group.

-chris

*** common/jk_uri_worker_map.c	2003-09-06 11:37:21.0 -0400
--- common/jk_uri_worker_map.c.new	2004-04-08 14:23:10.0 -0400
***
*** 80,85 
--- 80,86 
  #define MATCH_TYPE_GENERAL_SUFFIX (3) /* match all URIs of the form 
*ext */
  /* match all context path URIs with a path component suffix */
  #define MATCH_TYPE_CONTEXT_PATH (4)
+ #define MATCH_TYPE_JSESSIONID (5)

  struct uri_worker_record {
  /* Original uri for logging */
***
*** 300,305 
--- 301,317 
 Into 
jk_uri_worker_map_t::uri_worker_map_open, 
  			   suffix rule %s.%s=%s was added\n,
  uri, asterisk + 3, worker);
+ 		} else if(0 == strncmp(/* JK_PATH_SESSION_IDENTIFIER 
*,asterisk,14) ) {
+ /* jsessionid rule */
+ 		asterisk[1] = '\0';
+ 		uwr-worker_name = worker;
+ 		uwr-context = uri;
+ 		uwr-suffix = \0; /* avoids some problems */
+ 		uwr-match_type = MATCH_TYPE_JSESSIONID;
+ 		jk_log(l, JK_LOG_DEBUG,
+ 			   Into jk_uri_worker_map_t::uri_worker_map_open, 
+ 			   jsessionid rule %s*;jsessionid*=%s was added\n,
+ 			   uri, worker);
  		} else if ('\0' != asterisk[2]) {
  		/* general suffix rule */
  		asterisk[1] = '\0';
***
*** 478,483 
--- 490,523 
  *d = '\0';
  }

+ uri_worker_record_t *check_jsessionid_matches(char *uri,
+ 	  jk_uri_worker_map_t *uw_map,
+ 	  jk_logger_t *l)
+ {
+   unsigned i;
+   uri_worker_record_t *match = NULL;
+
+   for(i = 0 ; i  uw_map-size ; i++) {
+ uri_worker_record_t *uwr = uw_map-maps[i];
+
+ if(MATCH_TYPE_JSESSIONID == uwr-match_type) {
+   /* Check context match */
+
+   if(0 == strncmp(uwr-context,
+ 		  uri,
+ 		  uwr-ctxt_len)) {
+ 	/* Looks like a match: URI contains ;jsessionid, context matches */
+
+ 	jk_log(l, JK_LOG_DEBUG, check_jsessionid_matches: Found context 
match: %s\n, uwr-context);
+
+ 	match = uwr;
+ 	break;
+   }
+ } /* MATCH_TYPE_JSESSIONID */
+   } /* foreach mapping */
+
+   return match;
+ }

  char *map_uri_to_worker(jk_uri_worker_map_t *uw_map,
  char *uri,
***
*** 493,498 
--- 533,545 
  char *url_rewrite = strstr(uri, JK_PATH_SESSION_IDENTIFIER);
  if(url_rewrite) {
+ 	uri_worker_record_t *match = check_jsessionid_matches(uri, 
uw_map, l);
+ 	if(NULL != match) {
+ 	jk_log(l, JK_LOG_DEBUG, Mapped URI %s to context %s using 
jsessioni match\n, uri, match-context);
+
+ 		return match-worker_name;
+ 	}
+
  *url_rewrite = '\0';
  }
  jk_no2slash(uri);
***
*** 559,564 
--- 606,615 
  }
  }
  }
+ 		} else if (MATCH_TYPE_JSESSIONID == uwr-match_type) {
+
+ 		  /* do nothing -- these have already been handled */
+
  } else /* suffix match */ {
  int suffix_start;



signature.asc
Description: OpenPGP digital signature


Apache http / mod_rewrite / mod_jk

2004-04-07 Thread Christopher Schultz
All,
The archives show this questions being asked all the time, but with no 
useful responses. Please let me know if this is a known unresolved or 
unresolvable issue.

All solutions posted anywhere for jsessionid makes Apache go beaindead 
apparently use a mod_rewrite incantation similar to the following:

  IfModule mod_rewrite.c
  RewriteEngine on
  # Force URLs with a jsessionid to go to Tomcat. Necessary because
  # Apache doesn't recognise that the semi-colon is special.
  RewriteRule   ^(/.*;jsessionid=.*)$   $1 [T=jserv-servlet]
  /IfModule
While I'm sure this worked out great the people using mod_jserv back in 
1997, it does not work for mod_jk. For one thing, it does not even let 
you specify which worker to use :(

Back in the day, Craig responded by pointing to a Tomcat FAQ entry which 
no longer exists, but presumably had something to do with Apache's 
mod_rewrite.

On the other hand, a solution was posted (and confirmed by some readers) 
that the following works:

JkMount /test/*;jsessionid=* ajp13

This seems very obvious, and there's a caveat about how it might not 
work on older versions of mod_jk. It apparently does not work for me. 
I'm using mod_jk (not mod_jk2), version 1.2.5 (current release) on 
Apache 2.0.48 as a dynamic module on Linux -- everything compiled myself 
with nothing out of the ordinary.

Can anyone offer any advice? I've just been sucking it up and ignoring 
this problem for a while, now (years). Is there actually a solution out 
there for this? Am I just mistyping the JkMount configuration?

Anyone, please help.

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


Re: Apache http / mod_rewrite / mod_jk

2004-04-07 Thread Christopher Schultz
Yoav,

I have no clue as to your actual question, but I'm curious:

The archives show this questions being asked all the time, but with no
How do you define all the time in the statement above?
Like this:

Dubious responses:
http://www.mail-archive.com/[EMAIL PROTECTED]/msg84808.html
http://www.mail-archive.com/[EMAIL PROTECTED]/msg74207.html
http://www.mail-archive.com/[EMAIL PROTECTED]/msg84936.html
   (references a URL @ Google Groups with a simple solution that does 
not appear to work for me)

References Craig's pointers:
http://www.mail-archive.com/[EMAIL PROTECTED]/msg78826.html
No responses:
http://www.mail-archive.com/[EMAIL PROTECTED]/msg75615.html
That's just in the tomcat-user archives. Similar discussions occur in 
other forums (fora?), like jGuru.

Do you know if this is supposed to work?

JkMount /myapp/*;jsessionid=* workerX

It has allegedly worked for some other people.

-chris


signature.asc
Description: OpenPGP digital signature


Load testing using ApacheBench

2004-04-03 Thread Christopher Schultz
All,
I've started load testing my application using ApacheBench and I think I 
must be missing something. I only heard about this tool very recently, 
so I have pretty much no experience with it.

I was getting some odd behavior (i.e. very long response times compared 
to what I observe when just hitting the app myself via a browser) so I 
decided to lower the number of requests. The response times became very 
erratic. I tried 10 requests. Sometimes, I'd get all of them back within 
a few (10) ms. Other times, it would take 5-10 seconds for the last few 
requests. I figured I'd profile it.

So I did. But I continued to get strange results. For example, making a 
single request would take 30 seconds and create a ton of objects, etc. 
During the 30-second test, I could use my browser and make the same 
request with a reasonable response time (5 sec). Bizarre.

So, I started studying the output of ab: (Sorry for the full output, but 
I need some advice and I figured that more info would be better).

===

localhost[root]:/usr/local/src/httpd-2.0.48/support$ ./ab -n 1 
http://host/app/simple_search.do?query=testresourceType=-1search=Search;
This is ApacheBench, Version 2.0.40-dev $Revision: 1.121.2.4 $ apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, 
http://www.apache.org/

Benchmarking host (be patient).done

Server Software:Apache/2.0.46
Server Hostname:host
Server Port:8180
Document Path: 
/app/simple_search.do?query=testresourceType=-1search=Search
Document Length:14140 bytes

Concurrency Level:  1
Time taken for tests:   108.739776 seconds
Complete requests:  1
Failed requests:215
   (Connect: 0, Length: 0, Exceptions: 215)
Write errors:   0
Total transferred:  3069721 bytes
HTML transferred:   3017449 bytes
Requests per second:0.01 [#/sec] (mean)
Time per request:   108739.777 [ms] (mean)
Time per request:   108739.777 [ms] (mean, across all concurrent 
requests)
Transfer rate:  27.56 [Kbytes/sec] received

Connection Times (ms)
  min  mean[+/-sd] median   max
Connect:00   0.0  0   0
Processing:  1422 1422   0.0   14221422
Waiting: 1059 1059   0.0   10591059
Total:   1422 1422   0.0   14221422
localhost[root]:/usr/local/src/httpd-2.0.48/support$
===

WTF? 215 failed requests? I only asked for one! Not only that, but I 
tailed my apache request log during a subsequent identical test and 
found lots of these:

192.168.1.43 - - [03/Apr/2004:13:29:49 -0500] GET 
/app/simple_search.do?query=testresourceType=-1search=Search HTTP/1.0 
200 14146
192.168.1.43 - - [03/Apr/2004:13:29:49 -0500] GET 
/app/simple_search.do?query=testresourceType=-1search=Search HTTP/1.0 
200 14140
192.168.1.43 - - [03/Apr/2004:13:29:50 -0500] GET 
/app/simple_search.do?query=testresourceType=-1search=Search HTTP/1.0 
200 14140
192.168.1.43 - - [03/Apr/2004:13:29:50 -0500] GET 
/app/simple_search.do?query=testresourceType=-1search=Search HTTP/1.0 
200 14140

WTF? Response=200 looks good to me! Why am I getting all of these 
failed requests? Am I totally missing something?

This tool seems stupidly simple to use. Am I not reading the output 
correctly?

I tried to use the -v switch for verbose troubleshooting information, 
but I don't know what the following argument should be. I tried 
everything I could think of like numbers and stuff like debug error, 
etc. -- no dice.

Please, can someone help me understand what I'm doing wrong?

Thanks a /ton/ in advance,
-chris


signature.asc
Description: OpenPGP digital signature


ChannelSocket.read -- always runnable?

2004-04-03 Thread Christopher Schultz
All,
I'm currently profiling my app running on:
RH Linux 9 / kernel 2.4.20-8
Sun JDK 1.4.2
Tomcat 4.1.29
I'm using Borland's OptimizeIt v4.2 (a bit old, but hey! it's 
expensive!). Technically, I'm running the host on my server (on Linux) 
and the OptimizeIt profiling client on a separate windoze box and 
attaching to the process over the network. It's really irrelevant, but 
often people ask about these things.

When I do a CPU profile (really a what are threads doing profile) 
during a test where I just make requests as fast as possible, one at a 
time, I'm seeing that most of the time spent by runnable 
(RequestProcessor) threads is in this method:

java.net.SocketInputStream.read()

which gets called by org.apache.jk.common.ChannelSocket.read.

I assume that this is just the Java part of the JK connector sitting 
there waiting for a connection from Apache.

My question is this: why is it runnable? A VM thread dump says that 
they're *all* runnable, instead of sleeping, waiting for data. Is this 
just the way that Java does its sockets? I don't know a ton about the 
Java socket and I/O implementations, but I didn't think that it did a 
spin-wait on stream reading (rather than a blocking read, which would... 
well, block).

Anyhow, it makes the thread profile look very weird, because all of the 
threads are runnable all of the time. Makes it tough to find out which 
threads are actually doing any work :(

It this behavior consistent across Java versions? Are different socket 
implementations used with different connectors? It would be nice if 
fewer threads were runnable when they're really not doing anything.

If someone can give me a good reason for these threads being runnable, 
I'd love to hear it.

Thanks,
-chris


signature.asc
Description: OpenPGP digital signature


Re: Native libraries configuration under tomcat.

2004-03-18 Thread Christopher Schultz
Nick,

JMagick comes as a semi-stub library .jar archive and a native library
libJMagick.so - under the command line my code works (following ldconfig),
but I get errors in the catalina.out complaining about being unable to find
the library (details at the end of this message). the key clause being:
Caused by: java.lang.RuntimeException: Can't load MagickLoader (class not
found)
at magick.Magick.clinit(Magick.java:25)
Essentially, having trawled through the various documentation, I haven't
worked out how to direct Tomcat to find/use the .so library, so any pointers
to how to do this would be great.
I'm not sure where it is, but I'm sure that Tomcat has a directory 
that's specified as a search path for shared libs. Your JMagick class's 
clinit (public static { }) method is bombing probably because a call 
to System.loadLibrary() can't find the shared lib.

Can anyone say if Tomcat itself provides 'another' directory where 
shared objects can go?

You can put it in the SDK somewhere, but that's ugly.

Finally, let me issue a word of warning: using native code from a webapp 
is pretty dangerous: if the native code, say, segfaults, then Tomcat 
will go down along with all your webapps. Also, you have to be careful: 
the JVM gets very upset if you call System.loadLibrary() more than once 
for a given library. So, you should take care to have your JMagick 
library sitting in a common area, rather than your webapp's WEB-INF/lib 
directory. (Unless you promose never to re-start your webapp without 
re-starting Tomcat ;)

-chris


signature.asc
Description: OpenPGP digital signature


Re: apache 1.3 tomcat 5.0.19

2004-03-18 Thread Christopher Schultz
Emerson,

a second question: may I use the same mod_jk.so I used with tomcat 3.2.3??
The configuration of mod_jk is independent of the Tomcat version. As 
long as the version of Tomcat that you are using supports mod_jk (really 
ajp13), you can use mod_jk with it (including any existing configuration).

apj13 is supported by pretty much every version of Tomcat that you can 
get your hands on.

-chris


signature.asc
Description: OpenPGP digital signature


Re: JNDI Datasource Reference in DD Not Necessary?

2004-03-16 Thread Christopher Schultz
Kawthar,

In my web.xml:
...
res-ref-namejdbc/mySQLDatabase/res-ref-name
Does this looks correct? From the exception message, which  class name
is it looking for?
It looks like I have the same stuff that you do. This is my entire 
resource-ref element in web.xml:

resource-ref
descriptionDataSource for [the] application/description
res-ref-namejdbc/[ref-name]/res-ref-name
res-typejavax.sql.DataSource/res-type
res-authContainer/res-auth
/resource-ref
(Note that I'm using Tomcat 4.1.30)

-chris


signature.asc
Description: OpenPGP digital signature


Re: Why Tomcat (4.1.29) cannot find third party package's classes

2004-03-16 Thread Christopher Schultz
Ari,

is there any particular reason why all classes in third party 
jar-package (Exolab Castor in my case) can

not be imported in my JSP pages on new Tomcat (4.1.29 and Java build 
1.4.2_03-b02)? It works fine with

the old version (Tomcat 4.0.1 and Java build 1.3.1_02-b02).
Where is your Castor JAR file located?

-chris


signature.asc
Description: OpenPGP digital signature


Re: Filters and load-on-startup

2004-03-16 Thread Christopher Schultz
Raphael,

The webapp has a login filter that needs a connection from the connection
pool.  The webapp loads the login filter first.  I don't really want to
remove the filter because its integral to the application's design.   Is
there another solution, to getting the connection pool instantiated before
the filter?
Is this really a problem? Even though the filter needs a DB connection 
to do it's work, it doesn't need that connection until it's time to 
actually /do/ work, right?

You're certainly not going to get a request processed before the 
servlets are loaded, so it's probably alright that the DBCP is 
initialized *after* the filter itself.

Oh, and Yoav is right: you really want a ServletContextListener, rather 
than an 'init' servlet.

-chris


signature.asc
Description: OpenPGP digital signature


Re: Symbolic links in docroot?

2004-03-16 Thread Christopher Schultz
Hello,

cd SUNWappserver/domain/domain1/docroot
ln -s /usr/home/BB/public_html BB
but when I try and access
http://localhost:8080/BB/index.html I get 404 errors?
Is this file being served by Apache or by Tomcat? (The error page should 
make this obvious).

If it's Apache, then Apache is likely unable to serve the file for any 
of these reasons:

1. There's a Directory element in httpd.conf prohibiting access to 
files in / and others that specifically allow access to other directories.

2. The permissions on the directories leading to 
/usr/home/BB/public_html are not set properly (apache's effective uid or 
gid needs to have both read and execute permission on each of those 
directories).

3. Apache has been setup NOT to follow synlinks.

-chris


signature.asc
Description: OpenPGP digital signature


Re: JNDI Datasource Reference in DD Not Necessary?

2004-03-15 Thread Christopher Schultz
Kawthar,

I've been trying to setup my mySQL connection to tomcat as well and
has
been reading a lot of documents on how to do this.  I think I'm getting
more
confused.
Context evtCtx = (Context) ctx.lookup(java:comp/env);
DataSource ds = (DataSource) evtCtx.lookup(jdbc/mySQLDatabase);
--- in my web.xml : res-ref-namejdbc/mySQLDatabase/res-ref-name
--- in my server.xml: ResourceParams name=jdbc/mySQLDatabase
If you have your data source defined in GlobalNamingResources then 
you'll need a ResourceLink element in your Context in order to use 
the DataSource.

Other than that, things look good.

-chris


signature.asc
Description: OpenPGP digital signature


Re: 60 second timeouts?

2004-03-15 Thread Christopher Schultz
Allen,

 I am seeing pauses in page rendering that
are unrelated to GC. They are pretty much exactly (60 seconds + render time)
in length. 
Check your DNS resolver settings. I had problems like this unrelated to 
Java, and it turned out to be that. Make sure that localhost is actually 
pointing to 127.0.0.1, and that all of your nameservers are corect (and 
working).

In my case, I had a bogus primary nameserver which had to time out 
before the others were tried. All networking ops sucked bigtime.

-chris


signature.asc
Description: OpenPGP digital signature


Re: delaying context reload

2004-03-15 Thread Christopher Schultz
Cindy,

I like Tomcat's ability to reload a context when a change is made to
one of my application's classes, but I'm having a problem with it
reloading before the class has finished compiling. Is there a way to
delay the reloading until all the files are ready?
I highly recommend doing all your compilation in a 'local' directory and
then using a tool like ant (I hope you're already using ant!) to copy
all the updated files.
This allows you to attempt a compile without disturbing a running
server. (For example, if some of your files compile, but others don't
you could disable your server -- even if it is only a test server).
Generally, the copy will take less time that the compile ;)

Hope that helps,
-chris


signature.asc
Description: OpenPGP digital signature


Re: Help exporting a working turbine app to tomcat

2004-03-15 Thread Christopher Schultz
Inandjo,

i had a webapp developped under win2k and runing just fine.
When i tried to export it to a unix machine where tomcat 4.0 is running, 
this is the exception i get:

Horrible Exception: java.lang.Exception: Screen template '/Home.vm' not 
found
If you're switching from win32 to UNIX, make sure that the filename is 
correct, including case. If you were running this on win32 already, all 
of your search paths should be the same, and correct.

If your filenames are correct, check your TurbineResources.template file 
to make sure that all the / characters in your search paths are 
correctly done as forward slashes: /

-chris


signature.asc
Description: OpenPGP digital signature


Re: delaying context reload

2004-03-15 Thread Christopher Schultz
Tim,

So what do you suggest in the case of copying a war file that takes 15
seconds to copy?
That's a good question. I have a couple of thoughts:

1) When does the date of the inode get set -- at the beginning of the 
copy or at the end

2) Isn't there a way to set the time interval used to check for updates?

3) If you're hot-deploying WAR files, shouldn't you be using the Tomcat 
deployment tool instead of just copying it in there? ;)

(I don't know anything about Tomcat's WAR deployment -- I use ant to war 
and unwar my apps to do hot deployment.)

-chris


signature.asc
Description: OpenPGP digital signature


Re: Exporting turbine app to a working tomcat

2004-03-13 Thread Christopher Schultz
Inandjo,

i developped an app using TDK 2.1 (an official bundle i downloaded from 
apache site) on a windows 2k box, and it was working just fine.
Now i would like to deploy the app on a unix machine using tomcat 4.0 
with apache, by copying the folder under the webapps folder to the same 
folder on the unix machine. There is nothing concerning turbine on the 
box, just the tomcat and apache.
Without commenting too much on Turbine/TDK (I've had a ... poor 
experience with them), I can say that removing the 'TDK' part from your 
application is a challenge, but doable. I was able to do it by basically 
starting with nothing in my WEB-INF/lib except for turbine-x.y.z.jar, 
and adding JAR files until it started working again. (Lots of the TDK 
stuff is unnecessary for 'normal' deployment).

Anyhow, moving this from a working win32 machine to a Linux environment 
shouldn't be too much of a problem. I'd recommend divorcing the TDK 
(even if you keep Turbine, which is a good idea with a working app ;) 
but it's not cricual. You'll have to edit the configuration files that 
point to the TDK installation directory (there are properties like 
'tdk.home.dir' and stuff like that -- just make sure they point to the 
right place).

I would like to know what modifications i have to do in order to make 
the application work on that unix box (especially concerning tomcat 
configuration,the librairies i may have to copy to the unix box, and the 
changes required in the apache httpd.conf file).
Well, make sure you copy all the JAR files in binary more (if you're 
using FTP, for example), otherwise FTP will corrupt many your binary 
files -- the JARs being the most obvious.

You'll need pretty much everything you had on the win32 box -- including 
the TDK, unless you want to spend the time to break free of it and just 
use Turbine in a more 'standalone' fashion. So, install the TDK on the 
Linux box, copy your app-specific files to the Linux machine in roughly 
the same place they were before, and then adjust your paths in the 
properties files.

Other than that, all you need if Tomcat and a JDK (which you mentioned 
were already installed).

I would also like to know what is required to do for the app to work 
with apache.
That's a whole other ball of wax. Check out the Tomcat 4.1 
documentation, specifically at the Connector HOWTO. Use the JK 
connector. You'll have the best luck compiling it yourself against your 
local Apache version, so don't ask for binaries for the connector. That 
means you'll need a c compiler on the Linux box. That's not tough -- 
Linux often has gcc already installed, which works just fine with the JK 
stuff.

Good luck,
-chris


signature.asc
Description: OpenPGP digital signature


Re: JNDI Datasource Reference in DD Not Necessary?

2004-03-12 Thread Christopher Schultz
All,

I was just about to ask a question like this thread's today... glad I 
read the archives. ;)

I have an intersting observation in Tomcat 4.1.29. I found that my 
resource-ref was misnamed in web.xml, so I decided to check it out. A 
long time ago, I wrote a quick-and-dirty JNDI browser to help me figure 
out these things.

Using my JNDI browser, and looking at the path java:/comp/env/jdbc I 
find the following entries:

*  DSMstandard, class = org.apache.naming.ResourceLinkRef
* diagnosis, class = org.apache.commons.dbcp.BasicDataSource
(I have two DataSources configured -- I have to deal w/two DBs, so 
they're both there).

It's odd that one of them shows up as a ResourceLinkRef and the other as 
a BasicDataSource. (I have no resource-ref elements in my web.xml, for 
testing). They were defined the same way in server.xml:

GlobalNamingResources
Resource name=jdbc/diagnosis
auth=Container
type=javax.sql.DataSource/
Resource name=jdbc/DSMstandard
auth=Container
type=javax.sql.DataSource/
(I'll spare you the details of the ResourceParams, but they are 
identical except for the name used).
/GlobalNamingResources

N.B.: I have my Resource declaration in GlobalNamingResources 
because I need to use it for my Realm. Apparently, Resources defined 
within a Context that will use it as a Realm don't work well -- at least 
this was my experience. I found that putting the resource in the global 
resources and then using a ResourceLink did the trick.

Then, later, within the Context that will be using these, I had to add 
these:

ResourceLink name=jdbc/diagnosis
global=jdbc/diagnosis
type=javax.sql.DataSource /
ResourceLink name=jdbc/DSMstandard
global=jdbc/DSMstandard
type=javax.sql.DataSource /
Why wouldn't I get both BasicDataSource objects, or both ResourceLinkRef 
objects?

I thought it may have to do with the fact that I have the same name for 
the global reference and the local reference, so I changed the global 
references to jdbc/[dbname]-global and re-started. I got the exact 
same stuff in that JNDI context.

Can anyone explain what's going on?

Logically, I would expect the following:

1. Resource elements in the GlobalNamingResources would show up for 
all Contexts. If this is true, then why do I need ResourceLink in my 
context?

2. ResourceLink elements in a Context grant access to a 
globally-defined resource to that particular Context. Makes sense -- 
maybe you have a global resource for convenience, but it's a security 
issue to grant that resource to *any* webapp running on the server. So, 
if this is true, why don't I get two objects of type ResourceLinkRef in 
my context's JNDI namespace? Instead, I get one DataSource and one 
ResourceLinkRef.

3. resource-ref elements in web.xml should map the local name of a 
resource (the one you use from your webapp in JNDI lookups) to the 
resource mentioned in the Context's ResourceLink element.

So, if all that's true, then here's what happens:

Resource defines the canonical name for the resource. ResourceLink 
grants the resource to a particular webapp, possibly re-naming it in the 
process. (This should produce a ResourceLinkRef object in the JNDI 
namespace as seen by the webapp). resource-ref adds a 'local' 
reference name to a resource provided by the container. This should add 
another ResourceLinkRef (or something similar) to the JNDI namespace as 
seen by the webapp.

Can someone comment on my logic, and show me where I'm making incorrect 
assumptions or missing some crucial detail?

Thanks so much for helping me beat a dead horse. I really want to know 
what's going on. I'm *not* in a position where something's not working, 
so examples for getting things working aren't a ton of help (they pop up 
on the list often, and are in both Tomcat 4.x and 5.x JNDI HOWTOs).

Thanks,
-chris


signature.asc
Description: OpenPGP digital signature


Re: problem with mod_jk 1.2: error in action code

2004-03-12 Thread Christopher Schultz
All,

when you specify the connection to mysql, are you including the
'autoreconnect=true' parameter? If not, the connections will be closed
by mysql after (I think) 8 hrs.
I'm not sure why everyne's caught up in database connection code. This 
is a Coyote connector exception -- which is the HTTP/1.1 protocol 
connector. It allows you to connect directly to Tomcat using a browser, 
instead of going through Apache.

Usually the Broken Pipe means the the client hung up before listening 
for all the data. That could mean pressing the STOP button on the 
browser, following another link before the page fully loads, or pressing 
the back button.

I wouldn't worry too much about it, unless your users are somehow being 
affected.

-chris



-Original Message-
From: Michael Görlich (CSC) [mailto:[EMAIL PROTECTED] 
Sent: Friday, March 12, 2004 9:53 AM
To: Tomcat Mailinglist
Subject: problem with mod_jk 1.2: error in action code

Hello,

I've got problems with a tomcat web application, that 
establishes a connection pool to a database (mysql). This 
connection pool is lost after an unspecified period of time 
the system wasn't used (f.e. 8 houres).

I think the problem is due to the mod_jk connector between 
apache and tomcat.

The web application is accessible over apache 1.3.27, that 
connects to tomcat 4.1.27 via jk connector mod_jk 1.2.25.

The exception I got in catalina.out is:

10.03.2004 15:59:58 org.apache.jk.server.JkCoyoteHandler action
SCHWERWIEGEND: Error in action code
java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at org.apache.jk.common.ChannelSocket.send(ChannelSocket.java:407)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:599)
at 
org.apache.jk.server.JkCoyoteHandler.action(JkCoyoteHandler.java:385)
at org.apache.coyote.Response.action(Response.java:222)
at org.apache.coyote.Response.finish(Response.java:343)
at 
org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:268)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:360)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:604)
at
org.apache.jk.common.ChannelSocket.processConnection(ChannelSo
cket.java:562)
at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:679)
at 
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(
ThreadPool.jav
a:619)
at java.lang.Thread.run(Thread.java:534)
10.03.2004 15:59:58 org.apache.jk.common.ChannelSocket 
processConnection
INFO: server has been restarted or reset this connection

The HTTP connector defined in tomcats server.xml is:

Connector className=org.apache.coyote.tomcat4.CoyoteConnector
port=8009 minProcessors=5 maxProcessors=75 
enableLookups=false redirectPort=8443 acceptCount=10 
debug=5 connectionTimeout=0 useURIValidationHack=false 
protocolHandlerClassName=org.apache.jk.server.JkCoyoteHandler
scheme=http
secure=false /

The log in mod_jk.log shows the following:

[Wed Mar 10 15:59:58 2004] [jk_ajp_common.c (1052)]: ERROR 
sending data to client. Connection aborted or network 
problems [Wed Mar 10 15:59:58 2004] [jk_ajp_common.c (1303)]: 
ERROR: Client connection aborted or network problems

Here is the summary of my environment options:
- tomcat 4.1.27
- apache 1.3.27
- mod_jk 1.2.25
- Suse Linux 7.2
- Java 2 RE Standard Edition, Version 1.4.1 (build Blackdown-1.4.1-01)
My special problem is, that I'm not able to reproduce the 
error, it occurs after an unspecified period of time. I found 
nothing related to this problem. Any ideas?

Thanks in advance
M.Goerlich
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


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



signature.asc
Description: OpenPGP digital signature


Re: reclaiming memory problem PS

2004-03-04 Thread Christopher Schultz
Jerald (or is it Gerald -- your email address and 'name' don't match),

Now sessionStatus is getting caught  fine, but when I try and
redirect to a JSP after that, nothing happens. I originally tried
mapping.findForward (Struts), response.sendRedirect and forwarding
using RequestDispatcher. I have tried getSession(true) and false.
What implications (if any) does session timeout have in terms of
forwarding after the session is invalidated?
Session state should have nothing to do with your ability to forward, etc.

Can you post thesnippet of code where you try to redirect the user?

-chris



signature.asc
Description: OpenPGP digital signature


Re: Serialization issue

2004-03-04 Thread Christopher Schultz
Sean,

I'm trying to grab the current session ID and the request parameter map  
from the current request and serialize them into a base64 string to  
pass to a PHP application.  Problem is, I keep running into the  
following exception everytime I try to serialize anything imlementing  
the Map interface:

java.io.NotSerializableException: org.apache.coyote.tomcat5.CoyoteWriter
If you're passing this to PHP, I'm guessing that you don't want to use 
serialization. (Unless PHP can de-serialize Java objects and I didn't 
know...)

I think you want to do your own type of 'serialization', something like 
this:

Map parameters = ...;
StringBuffer sb = new StringBuffer();
for(Iterator i=parameters.entrySet().iterator(); i.hasNext(); )
{
Map.Entry entry = (Map.Entry)i.next();
ab.append(entry.getKey())
  .append('=')
  .append(entry.getValue());
if(i.hasNext())
sb.append(',');
}
// send sb (or sb.toString()) to PHP

Hope that helps,
-chris


signature.asc
Description: OpenPGP digital signature


Re: RegExp issues with Tomcat 5

2004-03-03 Thread Christopher Schultz
Karl,

Using the regexp tag library I think it is still at version 1.0.

Because INSERT into tablename (field1) values ('I CAN'T DO THIS')
generates an error in SQL Server.
If you use a PreparedStatement, then you can send any string to the
statement object and it will do it's own escaping.
-chris



signature.asc
Description: PGP signature


signature.asc
Description: OpenPGP digital signature


Re: Global URL Redirect Tomcat 5

2004-03-03 Thread Christopher Schultz
Nathan,

I am trying to migrate to Tomcat 5 from a different app server.  Is 
there a way to define url redirects? i.e. if a page moved off your 
server to a different location and you do not want to make a redirect page.
You could write a servlet that's mapped to /*, and then have that
servlet replace the hostname (and part of the path?), then send a
redirect back to the browser.
Would this meet your needs?

-chris



signature.asc
Description: PGP signature


signature.asc
Description: OpenPGP digital signature


Re: ClassNotDefError problems within JAR files under Tomcat 4.1.12

2004-03-03 Thread Christopher Schultz
Nathan,

I am developing an imaging servlet under Tomcat 4.1.12 using JAI 1.1.2.
Every time I update my code to add new features, it will return with a
NoClassDefFoundError until I restart Tomcat.  At that point, it finds
the 'missing' class and everything works as expected.
I'm no expert on JAI, but I believe that it uses JNI and a native
library to do some of it's dirty work. If that's the case, then you
should make sure that the JAI JAR file and native library are loaded by
a classloader outside (higher than) your webapp.
There's documentation on the Tomcat site (and probably other servlet
containers, too) that says that native libraries should only be loaded
one time. IF they get loaded multiple times (as would happen if they
were loaded by the webapp), strange behavior can result.
Try putting jai.jar (or whatever) into TOMCAT_HOME/common/lib and jai.so
(or whatever) in a convenient place where it can be found. (Sorry, dunno
where that might be. Anyone else?)
Hope that helps,
-chris


signature.asc
Description: PGP signature


signature.asc
Description: OpenPGP digital signature


Re: reclaiming memory problem PS

2004-03-03 Thread Christopher Schultz
Jerald,

 session.setMaxInactiveTimeout(-1);

Yeah, this is a bad idea. The session will never go away by itself. This 
*requires* the user to press a logout button, and for you to explicitly 
call session.invalidate(). Users frequently do not log themselves out, 
and their sessions will never die. You will eventually run out of memory.

If you need a long timeout, just make it really long (like a couple of 
hours). There's usually no good reason to make it -1.

PS is the session time out linked wirth inactivity? My session
attribute only persists as long as I am using the app.
That's exactly how the 'inactive' timeout works.

-chris



signature.asc
Description: OpenPGP digital signature


Re: OracleConnectionPoolDataSource creates too many connections

2004-03-03 Thread Christopher Schultz
Rudi,

I have two things to add that nobody seems to have mentioned.

In my LoginServlet, I create a new PooledConnection, which I add to the
Servlet Context:
PooledConnection pc = ConnectionFactory.getInstance.getPooledConnection();
ServletContext ctx = getServletContext();
ctx.setAttribute(pooled_conn, pc);
Gah! Why are you putting a database connection into the application 
context? This sounds like a concurrency nightmare! I think you want to 
put the /pool/ into the application scope, not a single connection.

Connection con = pc.getConnection
//do a few things with the connection
try{
if (con != null){
con.close();
} // I'm assumingthis returns the connection to the Pool
}catch(SQLException sqle){
sqle.printStackTrace();
}
You need more try/catch blocks. conn.close should /always/ be in a 
finally block:

Connection conn = null;
// Declare your statements and resultsets, here, too
try
{
conn = // whatever
// Do stuff with connection
}
finally
{
// Close your statements and result sets, here, too
if(null != conn)
try { conn.close(); } catch (SQLException sqle)
{ /* log this exception somewhere */ }
}
Hope that helps,

-chris


signature.asc
Description: OpenPGP digital signature


Re: how to get or build a mod_jk module for Cygwin Apache ?

2004-03-03 Thread Christopher Schultz
Flo,

i try to configure Apache 1.3.xx from cygwin and Tomcat 5.0 from windows to work
together with JK.
Okay. Isn't there a win32 binary?

http://apache.towardex.com/jakarta/tomcat-connectors/jk/binaries/win32/
(Look for files with 1.3.27 in their name -- those are for Apache 1.3.27).
But i have a problem getting a binary version of mod_jk.
At this URL : http://apache.crihan.fr/dist/jakarta/tomcat-connectors/jk/binaries/
the freebsd directory is empty.
Maybe I'm confused. Why are you looking in the freebsd directory for 
cygwin binaries?

For cygwin i don't know if i must use a win32 mod_jk.dll (version 1 or 2) or
build a mod_jk.so.
It will be a .dll file. However, I'm not sure cygwin has anything to do 
with this. You'll be running Apache-win32 and mod_jk-win32, and I assume 
Java/Tomcat will be running on JDK-win32, so where does cygwin come in?

-chris


signature.asc
Description: OpenPGP digital signature


Re: RE : how to get or build a mod_jk module for Cygwin Apache ?

2004-03-03 Thread Christopher Schultz
Flo,

I thought FreeBSD works like cygwin but it seems wrong.
FreeBSD is a 'real' UNIX flavor, while cygwin provider UNIX-like 
services and libraries on win32.

I tried the mod_jk_1_2_5_2_0_47.dll I got errors launching httpd :
Win32 error 126 (The specified module could not be found)
I needed to add ApacheCore.dll Win9xConHook.dll to the PATH
Then i got another error message : Win32 error 127 (The specified
procedure could not be found).
You shouldn't have used mod_sk_1_2_5__2_0_47.dll -- that's for Apache 
2.0, not Apache 1.3.

Then I tried mod_jk2-1.3.27.dll but I get this error :

Syntax error on line 1020 of /etc/apache/httpd.conf:
Can't locate API module structure `jk_module' in file
/usr/lib/apache/mod_jk2-1.
3.27.dll: dlsym: Win32 error 127
You probably have the dll in the wrong place. The standard location for 
Apache modules is in the 'modules' directory in the Apache installation.

So I thought to build any mod_jk but how?
You'll have the same problems if you build it yourself. You still need 
to put it in the right place.

I would like to find a better and easier solution.
Are you using Apache as a package that was installed via Cygwin? You 
might have better luck with the 'standard' distribution, which comes 
with a very simple installer, from httpd.apache.org.

-chris


signature.asc
Description: OpenPGP digital signature


Re: Virtual Hosts with Apache and Tomcat

2004-03-02 Thread Christopher Schultz
Antonio,

In fact, cap it at 10 and watch the app dring to a halt before it even 
gets going. This is a pretty compelling example. If the pool is drying 
up, they're definately screwing up.
It is. But developers may reply: You are using less connections than 
those specified in (the contract) / (the manual) / (fill in yourself).
I thinks we're misunderstanding each other. I think that when the pool 
is capped, and the connections are never returned, you get to a point 
where the pool refuses to give you a new connection, no matter how long 
you wait.

This is a pretty good idea for some basic debugging. You should only 
have to demonstrate to your devs that you can deadlock their server by 
capping the connection pool. After that, it's their problem, right? :)
With the proposal, you demonstrate they have a connection leak, which is 
the real problem.

Once you showed them they had ONE connection leak, you can urge them to 
dig for other connection leaks themselves.

But, of course, the idea about the deadlock seems really good also. If I 
understood, what you mean is: If you set the connection pool size too 
low for the app, it should crash at will (or better, show an 
'unavailable' screen), but it should continue working as soon as load 
permits it. Am I wrong?
I'm thinking that the connections are added to the pool upon request 
(from his observationa, it looks like the 10 pre-allocated connections 
are always ignored), and then never returned. The pool remembers the 
pre-allocated ones, plus the ones it created on-the-fly. I think that if 
he caps the connection pool size at 25, it will only take 20 requests to 
lock up the server for want of a DB connection.

Try setting the pool size to 11 and see if you lock up after one request ;)

-chris


signature.asc
Description: OpenPGP digital signature


Re: Process Died | Production

2004-03-02 Thread Christopher Schultz
Yoav,

I've had the displeasure of experiencing a Tomcat JVM core
dump
on me not too long ago (in a multi-user development environment,
fortunately) on a Sparc/Solaris box. It turned out to be due to
insufficient swap memory in the system. I didn't see any
OutOfMemoryExceptions raised prior to the crash, so it wasn't that
obvious, but the top command came to the rescue in the end.
Good one ;)  It reminds of another time, where I had internal crashes
occurring due to a low limit of file descriptors (ulimit -a will show
you the limits).  That one was frustrating ;)  I'm sure many people on
this list of horror stories with seemingly random crashes...
I've experienced even more random crashes (SEGV). It turned out to be 
bad memory (or bus), and it only showed up under pretty heavy load. :(

-chris


signature.asc
Description: OpenPGP digital signature


Re: Securing SSL from IIS to Tomcat

2004-03-02 Thread Christopher Schultz
Antonio,

Nice demonstration. I only miss the seriously part, which is covered 
partially by the term expensive ;-)
Right. :)

I wanted only to add IPSEC as another possible scenario. It has less 
(no) TCP overhead than a SSL tunnel. And it works without even changing 
your config files.
Now that's an idea. I don't even know how IPSEC works. However, I think 
it might be a UNIX-only thang (and he's on win32). However, the point 
you make about VPNs is a good one. I think you can't 'avoid' the TCP 
overhead, though, since this stuff runs over something which has to have 
some kind of error-correcting and delivery guarentees like TCP does 
(even if it's not actually implemented using TCP).

At any rate, you could tunnel your JDBC connections through some other 
kind of secure connection.

-chris


signature.asc
Description: OpenPGP digital signature


Re: Virtual Hosts with Apache and Tomcat

2004-03-02 Thread Christopher Schultz
Stephen,

In fact, cap it at 10 and watch the app dring to a halt before it even
gets going. This is a pretty compelling example. If the pool is drying
up, they're definately screwing up.
Whoa there pardner:  I am not going to deliberately cripple a production box. 
The problem has been demonstated in test environments and that is as far as I 
will intentionally let it go.
Oh, I totally meant in a development setting. I would never suggest that 
you cripple a production box. You can easily demonstrate the problem. Do 
that in dev, and make them fix it. Then, deploy the fix as part of your 
regular deployment procedure.

-chris


signature.asc
Description: OpenPGP digital signature


Re: Virtual Hosts with Apache and Tomcat

2004-03-02 Thread Christopher Schultz
Kennan,

I can agree partially to yours. But if you see him, he doesn't know about
the impact of JVM and tuning parameters, as he mentioned in his email. Do
you expect him to take a lead in fixing that? I have seen the projects
losing its focus by the nature of peoples deviating to get their interests
fulfilled.
This is not a 'special' interest. This is a legitimate resource leak 
that he wants them to fix. He can demonstrate the leak. That's all 
that's necessary on his part. The rest is up to the developers. I'm not 
suggesting that he fix the problem. Only to demonstrate it and get the 
developers to fix the problem.

I would appreciate, if the developer and sysadmin working together in this
problem (i doubt verymuch as sysadmin involvment, all he can do is give
top or sar reports). Sysadmin has much knowledge in configuring servers,
architect the infrastructure, manage the network, backups etc. 
Yes, but *this* sysadmin also has enpirical data that demonstrates the 
resource leak. Forget sar and top. How about the app locks up. That 
should be motivating enough.

I never seen any sysadmin trying to fine tune any Application Servers.
Actually, the sysadmin is the /perfect/ person to fine-tune app servers. 
Most devs don't know jack about the app server they use. That's why they 
deploy onto app servers with standard interfaces and services (Servlet 
and JSP spec). The deployment and admin folks are the ones who should 
know how to configure the app servers.

If
that is the case, then the project sucess will be in stake. Everyone has to
do their own roles. If I would be the sysadmin, then i would tell the
developers to go these newsgroups. Dont you think that most of developers
resolve their issues by newsgroups and websites for their problems. 
Here's the problem: the devs refuse to admit there's a problem. They 
won't go to the newsgroups to ask about a problem that they don't 
believe exists. That's why the sysadmin is here. He wanted to get some 
information on how to prove that there's a leak. He's gotton that 
information. Let's wait for the devs to visit the group, now ;)

He clearly mentioned that the developeers raised that questions and trying
to get the verification from the newsgroups. Dont you think that is the part
of communication gap between the developers and him. If he is very keen, why
not one of the developers responding his thread and get the issues fixed for
the project. 
I think the problem is that the devs think the sysadmin is foolish and 
wrong about the resource leak. Now that he can demonstrate the leak, 
they will take him more seriously.

I believe that we have helped in this situation, and that the devs will 
now address the problem instead of sticking their heads in the sand.

-chris


signature.asc
Description: OpenPGP digital signature


Re: Deploying a simple servlet

2004-03-02 Thread Christopher Schultz
Leon,

I'm new to tomcat and am trying to run a very simple hello world type of
servlet.  I've configured the web.xml to mimic a similar servlet in tomcat
examples.  Still while all the example servlets from tomcat work mine fails
to run.
I receive the following message:

HTTP Status 404 - /MyApp/servlet/Testing

I would greatly appreciate any advice.
In the newer versions of Tomcat, the 'invoker' servlet is disabled by 
default. The best way to get your servlet running it to create a 
servlet-mapping element in your web.xml and then use your mapped URL 
to access the servlet (instead of using a URL like 
/context/servlet/ClassName).

-chris


signature.asc
Description: OpenPGP digital signature


Re: RegExp issues with Tomcat 5

2004-03-02 Thread Christopher Schultz
Karl,

We upgraded tomcat running one of our applications from 4 to 5 this past =
Friday, March 27th. Since, one of our regular expressions is not =
functioning properly. Here is the expression:
s/(\\|')/\\$1/g

Instead of escaping the apostrophe with another apostrophe for SQL =
purposes, it is replacing the apostrophe with the literal '$1'. It was =
working with Tomcat 4 and that is the only thing that has changed.
What regex library are you using? Tomcat shouldn't have anything in it 
that would affect your regexs.

Not to open up too big of a can of worms, but if you're using JDBC, why 
do you have to escape your own SQL statements?

-chris


signature.asc
Description: OpenPGP digital signature


Re: Deploying a simple servlet

2004-03-02 Thread Christopher Schultz
Leon,

I've set up a directory structure for this app exactly like the servlet
examples structure and after making changes to web.xml I'm recieving the
following root cause error:
java.lang.NoClassDefFoundError: TestingServlet (wrong name:
myApp/TestingServlet)
Is your TestingServlet class in a package? If so, you need to give the 
fully-qualified class name in your web.xml file.

If it's not in a package, I've heard many reports that it simply won't 
work :(

Try putting your servlet class into a package, updating your web.xml 
file and trying again.

-chris


signature.asc
Description: OpenPGP digital signature


Re: scope order of initialization of variabes includes

2004-03-02 Thread Christopher Schultz
Marc,

I thought I should get the output:
First page: ok
Second page: ok
I think this is what's happening. (You can probably verify this by 
looking at the java source code generated by Tomcat from your JSP):

When you do a jsp:useBean and declare where the bean lives, the 
translator essentially converts that to this line of code:

String bandBg = (String)request.getAttribute(bandBg);

Then, later, you are using a scriptlet to do this:

bandBg = ok;

In the other JSP, the same code executes:

String bandBg = (String)request.getAttribute(bandBg);

However, you never poked 'ok' back into the request, so it's still 
either null or blank or whatever it was when you started.

Setting the local reference bandBg in your Page1.jsp doesn't do anything 
outside of it. You'd have to do something like this in your scriptlet to 
make it work:

% request.setAttribute(bandBg, ok); %

If you're going to use jsp:useBean, you probably shouldn't screw 
around with those variables inside of scriptlets. Try to stick with the 
bean tags only. That generally means that you'll have to write your own 
bean instead of using a string (so it can have a 'setValue' method or 
something).

Hope that helps.

-chris


signature.asc
Description: OpenPGP digital signature


Re: [OT] Re: Process Died | Production

2004-03-02 Thread Christopher Schultz
Ankur,

I've experienced even more random crashes (SEGV). It turned out to be 
bad memory (or bus), and it only showed up under pretty heavy load. :(

This is a little OT, but just out of curiosity, has anybody been 
successful in gaining root/tomcat/whatever-uid shell by capitalizing on 
a JVM's (not necessarily tomcat's) core dump? I've always wondered if 
that was possible. I know its extremely hard (impossible?) to 
consistently overflow JVM's stack, but has it ever been done?
I've never heard of anything like this before.

However, Java's stack is not what gets overflowed, here. IF the JVM 
goes down, it's the JVM code that faults, not the Java code itself. 
Java's stack and heap are pretty far away from anything that's executing.

Generally stack or buffer overflow bugs are exploited because someone 
corrupted the stack and not only inserted some maliscious code, but also 
modified the return pointer to call that code. In Java (without native 
code, at least), I don't think you could intentionally do anything like 
this. I suppose it you had an evil app connect to a JVM using something 
like JVMPI, you might be able to do something like this. However, you 
usually don't have the profiling hooks turned on in production ;)

-chris


signature.asc
Description: OpenPGP digital signature


Re: reclaiming memory problem

2004-03-01 Thread Christopher Schultz
G,

But, when I close down a client window, the
memory consumption remains at it's peak (and climbs with each
successive new client opened) In other words, memory consumption
increments but never decrements, necessitating a server bounce at
unacceptable frequency.
What is your definition of 'never'?

Java cannot immediately reclaim the memory used by that user's sesson if 
the user closes the browser. Tomcat doesn't know that the client has 
closed their browser. It must wait until the session times out (30 
minutes, I think) before the session can be cleaned up automatically. 
Solutions?

1. Reduce the session timeout.
2. Store less stuff in the session so that it's not such a memory drain.
3. Beg your customers to logout before leaving your app. ;)
Why are the resources not being reclaimed, and how might I gently
encourage resource reclamation? I fear System.gc() is not the answer
here.
System.gc only tells the GC 'now might be a convenient time to run the 
GC'. Other than that, it's not much good.

-chris



signature.asc
Description: OpenPGP digital signature


Re: Virtual Hosts with Apache and Tomcat

2004-03-01 Thread Christopher Schultz
Antonio,

And bad.  Every time I restart, Tomcat loses the state information for 
established login sessions.  Customer don't like that.
That (with a high probability) is because some objects they store in 
sessions are not Serializable. IOW, they violate the Servlet Specification.
I'm just curious: is this actually a violation of the servlet spec? The 
API seems to indicate that you can put anything in the session that you 
want. I don't think it has to be Serializable... thought I was wrong 
before, once ;)

Tried that.  Capped it at 35 and the webserver stopped servicing any 
DB request as soon as the pool reached 35.  This is why I believe the 
pool management is faulty and/or something is hogging all the 
connections.
I share your belief. Let's try to prove it. Raise it to some other 
figure, and see if the same happens again. Ask them how big should the 
figure be.
In fact, cap it at 10 and watch the app dring to a halt before it even 
gets going. This is a pretty compelling example. If the pool is drying 
up, they're definately screwing up.

Oracle 9i takes 16M per connections.  So Oracle claims.  I've tested 
it as high as 20M.  I generally use 18M as a guideline
I've heard (not a DBA, though) that Oracle 9i has a mode where it does 
not spawn a process per connection, but uses threads instead (?) and in 
that mode it uses far less resources. This way, we have some modest 
Oracle servers hjandling up to 300 simultaneous (mostly idle) connections.
It depends on the size of your rollback segments and the number of 
transactions you are doing. If you do big transactions, each DB 
connection (thread *or* process) wioll need a big chunk of memory. I 
wouldn't kill yourself trying to figure out how to reduce this process 
size. Fix the real problem, which is poor connection management.

I'll mention DBCP and see what happens
DBCP has a nice removeAbandoned feature.

Otherwise, you can use this code (tweak it to your needs) to track where 
connections are opened and closed from:

(code not tested at all)

// open method signature
// code that opens the connection (and stores it in conn variable)
try {
throw new Exception(Pool Debugger says: Connection  + conn +  
opened:);
} catch (Exception e) {
e.printStackTrace();
}
I've seen code like this before. Many people think you can't get a stack 
trace unless you throw an exception. Not so. All you have to do is 
instantiate it, and you get the stack trace. So, the following will 
produce identical results, without the nasty try/throw/catch:

new Exception(Pool debugged says: ...).printStackTrace();

I would recommend explicitly printing out the hashCode of the Connection 
object itself, just in case the connection doesn't include any 
identifying information in it's .toString method.

Then you can...
#!/bin/sh
# Filter pool debugger statements.
This is a pretty good idea for some basic debugging. You should only 
have to demonstrate to your devs that you can deadlock their server by 
capping the connection pool. After that, it's their problem, right? :)

-chris


signature.asc
Description: OpenPGP digital signature


Re: Virtual Hosts with Apache and Tomcat

2004-03-01 Thread Christopher Schultz
Kannan,

Being yourself as SYSADMIN for UNIX and Network, it would be nice that
developers or professional should take a lead into get into this problem.
Easy for you to say.

Let's face it: these guys have a connection leak. Plain and simple. Your 
devs need to find their leak. It is demonstrable. It locks up the 
server. QED. Make them fix it.

This isn't about communication or a sysadmin whining to the devs about 
something he doesn't understand. This is a resource leak. It is 
apparently well-understood. He's done his homework. They are clowns.

-chris


signature.asc
Description: OpenPGP digital signature


Re: Syntax Question

2004-03-01 Thread Christopher Schultz
Jack,

I want to add a variable to the web.xml file and be able to call in
from within a servlet, taglib or bean.
You need to use the init-parameter element in your web-app element 
in web.xml. Your JSP syntax appears to be correct.

-chris


signature.asc
Description: OpenPGP digital signature


Re: Do servlet threads ever die?

2004-03-01 Thread Christopher Schultz
Ken,

Problem: I call native code (Tcl) from my servlet.  Tcl's thread model 
forces me to run Tcl only on the thread that created the Tcl 
interpreter.  So now how do I cleanup these interpreters?  The cleanup 
code needs to be run on the creating thread.
Guh. I highly recommend against running native code from an app server. 
There are lots of reasons I could enumerate if you ask. Number one 
reason: crashed native code = crashed server. :(

Is there a way you can call the Tcl code through a socket or by invoking 
another process and communicating with it via stdin/stdout? (see 
java.lang.Process)

Do servlet threads ever die besides during shutdown?  If not, I may have 
no problem.
AFAIK, Tomcat never retires threads unless something horrible happens 
(or tomcat is shutting down).

Can I register a listener to be invoked on the thread before it shuts 
down?
I don't think you can do this to a thread. You might be able to hack 
Tomcat's thread pool so that you can cleanup after a thread if it's 
going to be retired. I don't have any good ideas.

Sorry I couldn't help more.

-chris


signature.asc
Description: OpenPGP digital signature


Re: Securing SSL from IIS to Tomcat

2004-03-01 Thread Christopher Schultz
Antonio,

Since IIS decrypts the request and passes it unencrypted to Tomcat,
 How do I encrypt the request so that all communication from IIS
with Tomcat is secure???
Do you really need it? It would probably affect your performance 
seriously. (No, I cannot prove that statement...)
I can prove this statement. :)

Connection latency = network transfer time + 2 * (TCP overhead +
encryption/decryption)
(Twice since both clients have these overheads).

When the encryption/decryption term becomes zero (removal of SSL),
performance increases. The assertion that encryption/decryption takes
more than zero time is left as an exercise to the reader. (Oh, and SSL
acceleration hardware is expensive, which would seem silly if the ops
were trivial).
Latest reference I've been able to google for is from Tomcat 4.1 JK 
connector (deprecated). But I have not searched a lot.
I don't think that the JK mod is deprecated. In fact, it's suggested for
production installations with Apache 1.3 and 2.0 (and IIS, I guess).
(From the other followup post):
I doubt any has that kind of need. If that is the case, then everyone will
pull their brains out. 
Often, there's a need. What if you don't trust your own network?

If we are worried about the IIS having SSL with Tomcat, then how about SSL
between database and Tomcat. How about query tools used in database (
secured query tool? , I dont know who has like this).
Some people need this type of stuff. Let's say that your database server 
is on another network, and you need confidential transfers?

I would not worry, if the Tomcat behind firwall, and behind the IIS (SSL).
I would still worry. For example, all of our hardware is hosted by a 
data center. We get all kinds of M$ virus crap spewing into our syslogs 
every single day. We get SMB traffic logs. We get all kinds of crap. 
There's nothing stopping me from running a packet sniffer on my 
machines, which would compromise the entire network if SSL were not 
being used. (Fortunately, each app is small enough that we can runn both 
 the app and db on the same machine and avoid those security concerns).

The JK documentation says nothing about SSL (other than forwarding SSL 
information from thr web server to Tomcat). I assert that you have two 
options:

1. Use Tomcat standalone (why not? do you have a huge amount of 
non-dynamic content? If not, consider Tomcat standalone)

2. Set up an SSL tunnel using your favorite ssh software. OpenSSH is 
available for win32 (at least through cygwin). You can punch through 
pretty much any network and firewall (as long as they allow SSH). All 
the data is encrypted. Most ssh clients/servers also support compression 
as well, which /might/ help offset the performance penalty of encryption 
(due to lower network transfer times).

Good luck.

-chris



signature.asc
Description: OpenPGP digital signature


Re: The server encountered an internal error () that prevented it from fulfilling this request.

2004-03-01 Thread Christopher Schultz
Metin,

What can be the reason of this error?

java.lang.NoClassDefFoundError: org/jdom/JDOMException
Looks like you need to install the JDOM library...

-chris


signature.asc
Description: OpenPGP digital signature


Re: Tomcat 4.1.29 JVM crash on RHEL-3-ES

2004-03-01 Thread Christopher Schultz
Joe,

I'm experiencing sporadic crashing of the JVM running Tomcat in 2 of my
environments.  These environments both run the same webapps, and they both
use JDK 1.4.2_03 on RHEL-3 ES.  Other environments where these same webapps
run are using JDK 1.4.1 and Redhat7.2, and are not experiencing these
crashes.
What kernel version are you using (I assume you're using 2.4.something). 
There's a lot of talk on this list about having to set the 
LD_ASSUME_KERNEL environment variable in order to prevent crashes like 
these on various versions of Linux (esp. RedHat). I myself have never 
needed this setting.

Do a quick search in the archives for LD_ASSUME and see whet they have 
to say.

-chris


signature.asc
Description: OpenPGP digital signature


Re: classloader order

2004-03-01 Thread Christopher Schultz
Yoav,

What can I do to make sure that whatever I have in my /WEB-INF/lib/
 directory takes precedence?
You're not doing anything wrong, your systems group is.  You can't 
override the bootstrap classloader.
Aw, sure you can (-Xbootclasspath/p). But trumping the boot classloader
with WEB-INF/lib is an even worse transgression than putting
app-specific JARs into JAVA_HOME/lib/ext.
-chris


signature.asc
Description: OpenPGP digital signature


Re: Virtual Hosts with Apache and Tomcat

2004-02-29 Thread Christopher Schultz
Stephen,

I am having a problem with tomcat opening up up a number of connections to an 
oracle server that never get closed.  This causes the number of open 
connections to build up over time and, eventually, causes the oracle server 
to use all of its swap.
That's not good :(

Restarting tomcat clers this up.
That's good! :)

I think there is a problem with some jsp's opening connections and then not 
closig them but the developers claim (surprise) their code is clean.
It's tough to make sure that database connections (and statements, and 
result sets) get cleaned up in JSPs, unless you have a talented JSP 
author. (Most JSP authors aren't that talented, unless they are also 
good Java developers, in which case they would have implemented the DB 
access in a servlet and just used the JSP for display. Anywho...)

If the number of connections keeps going up and never tapers off or 
stops altogether, then something is misconfigured with your connection 
pools. Even if the engineers say that the pages are clean, you should 
protect the app server (and the DB server) from being swamped by capping 
the number of DB connections allowed. Ever. Any decent DB connection 
pool lets you specify this kind of thing. You should set that value to 
something reasonable. You can get away with a suprisingly low number of 
these.

(I was consulting on a big project that was a somewhat DB intensive, 
web-based app. They had the app server configured to accept 75 
simultaneous connections. They also set the db connection pool size to 
75. I asked why and they basically said so that every HTTP connection 
can get a db connection. Duh. I talked to management and make them put 
in debugging information to find out how many connections were ever in 
use simultaneously. Seven. (Suckers). They also didn't realize that 
Oracle takes like 10MB per connection on the backend, and they had six 
physical app servers running two separate copies of the application. 
That's 75 * 6 * 2 * 10MB = 900MB. Good thing the DB server had 3.5GB of 
RAM, but still...)

The explanation they give is:

The increase in number of connections beyond the CACHE_MAX_SIZE setting in 
the app1.properties file is due to the private labeled sites. For each 
virtual host (private labeled site), there will be a separate JVM running the 
Tomcat web server space. For each of these JVMs, there will be a separate 
database connection cache pool to serve the user requests. This is the 
designed functionality of a web server that will support virtual hosts.

I don't know tomcat near as well as I do Apache but this sounds like someone 
is blowing smoke.
This isn't too outrageous, actually. If each webapp has its own 
connection pool, and they are configured to have at maximum, say, 10 
connections, then you'll probably end up with 10 * webapp_count 
connections to the database server, regardless of the number of 
Tomcats/JVMs are running.

If Tomcat is configured to handle the connection to the database (say, 
through a Realm and a JNDI-configured connection pool), you might be 
able to share connections between all of the webapps. If you solve the 
private-labelling problem by using multiple webapps, but through the 
same database, this approach seems like an excellent idea; configure 
Tomcat to provide a JNDI-based connection pool, and then configure the 
separate applications to use that pool. That way, you can control the 
total number of connections across all private labels, instead of having 
them be independent.

If I run ps on the server it looks to me like there is 
only one instance and if I restart tomcat, _all_ virtual hosts are restarted.
Yeah, then it's definately separate webapps running on a single instance 
of Tomcat. Try to pitch the above idea to your engineers and see what 
they say (probably something like it's fine the way it is!).

I don't care who is right or wrong but I do want to clear up this problem.  
Any ideas?  If you need any more information, just ask.
I think I'd need to know if the connections were really never going 
away. Use netstat to find out what state they're in. If they all say 
ESTABLISHED, then you've got a connection leak. If many of them say 
TIME_WAIT or something like that, then you might have a problem with 
either the client or the server not properly hanging up the phone. If 
it's the former, then yell at your engineers. Cap that connection pool 
size at something reasonable, like ten connections. After that, the 
application starves. That's good for the app server and the database, 
while bad for your application. You can use Jakarta Commons' DBCP as 
your connections pool. It has some wonderful debug options, like giving 
you a stack trace for the code that obtained the connection if that 
connection isn't returned within a certain amount of time. That can save 
days or weeks of code reviews. If your connections are in TIME_WAIT, see 
how long they stay that way. Waiting 5-10 minutes for a connection like 
that to get 

Re: image not displayed

2004-02-29 Thread Christopher Schultz
Peter,

Since i am new to Tomcat i installed tomcat 5 on a Suse 8.2 linux machine and tried to install the First Webapp Servlet example.
I have placed all files in subdirectories of myapp, thus:
myapp/src/mypackage/Hello.java, 
myapp/web/WEB-INF/web.xml 
myapp/web/image/tomcat.gif

After ant install and starting a local browser, the text output is shown correctly but the image is not displayed. I cant figure out why the image isn't shown. Did i mis something in the web.xml? (see below)
web.xml is probaly not your problem. What does your 'ant install' do?

Are you using Tomcat standalone? If so, your context path (in 
server.xml) should point to the directory where your WEB-INF and 'image' 
directories are. If you are using Tomcat's auto-deploy feature and just 
shove your files into {tomcat-home}/webapps/myapp, then make sure your 
image path is {tomcat-home}/webapps/myapp/image. Also, make sure that 
your URLs for the images in your web page look like this:

img src=http://host/myapp/image/tomcat.gif; /
or
img src=/myapp/image/tomcat.gif /
...or they are relative to your actual web page or JSP. I recommend 
against this, since you then get lots of img 
src=../../image/whatever.gif / which gets unmanageable after a while, 
especially if you start including some JSPs in others where the paths 
aren't always the same relative to the root.

-chris


signature.asc
Description: OpenPGP digital signature


Re: Help tomcat problem with memory

2004-02-27 Thread Christopher Schultz
So,

Hi this  the statemens that i posted in the catalina.sh file
JAVA_HOME=/usr/java/j2sdk1.4.0 ; export JAVA_HOME
CATALINA_HOME=/usr/local/tomcat1 ; export CATALINA_HOME
JAVA_OPST=-server -Xms30m -Xmx40m -Dfile.encoding=ISO-8859-1
CATALINA_OPTS=-Xms30m -Xmx40m
Your app seems to be taking more than 30m, eh? Try 30M -- it might 
be case sensitive. Although the VM and Tomcat might not even be able to 
load and get anything done in that little memory.

This the output of the top command and both tomcats has been installed 
in the same server

1:22pm  up 21 days,  5:36,  6 users,  load average: 0.17, 0.23, 0.28
Your load average looks great. What's the problem?

CPU0 states:  9.5% user,  4.0% system,  0.0% nice, 85.5% idle
CPU1 states:  7.4% user,  8.5% system,  0.4% nice, 83.3% idle
Mem:  1030580K av, 1019220K used,   11360K free,   0K shrd,   92348K 
You've got a dual-CPU machine with a gig of RAM and your app is 
responding slowly? What are you running?

buff
Swap: 2096376K av,   58748K used, 2037628K free  706776K 
Your swap hasn't been touched. Unless you have a totally braindead app, 
something is terribly wrong if it's really not responding.

Have you hooked up a profiler to your app?

-chris


signature.asc
Description: OpenPGP digital signature


Re: Help tomcat problem with memory

2004-02-27 Thread Christopher Schultz
Fabian,

If  i have only two java proccess of 141 MB and 55 MB why my memory is 
over 90% of the utilization and the application working slowly or not 
working, when the users try to get access using the webserver in this 
server. i can't understand this problem...thnaks
You have to understand something about Linux memory: it never gives it 
up. So, even though 'top' reports that your box has very little free 
physical memory, that doesn't mean that it's all being used.

When the kernel obtains memory on behalf of a process, it doesn't go 
back into 'free' when the process fees it or dies. I know it's a little 
weird.

However, you do have a reasonable complaint: the app seems sluggish, and 
with that hardware, it shouldn't be.

Again: what are you running? If your code fires off 500 threads every 
time a request comes in, then maybe you shoudl rethink your 
architecture. If it's nothing heavy-hitting, then something else is 
wrong. What else is running on the box?

What benchmarks have you run? Or, are you just complaining about 
wall-clock time? Could your problem be network latency? How far from the 
box are you?

-chris


signature.asc
Description: OpenPGP digital signature


Re: Tomcat heap vs. java.exe

2004-02-27 Thread Christopher Schultz
Asim,

kill doesn't work on Windows.  Besides, I can't afford to stop the 
server right now.  Many of our customers are using currently using the 
websites.
In order to get a thread-dump, you can do a CRTL-BREAK (not CTRL-C) on 
win32. Unfortunately, you have to already have started the JVM on a 
console, instead of as a service.

If it's already running, and you can't restart, you can write a JSP that 
will get a thread dump for you. Just look up Thread.getThreadGroup, 
ThreadGroup.getParent, and ThreadGroup.list and you can throw something 
together pretty quickly. Ideally, you can get a VM thread-dump, though.

Any idea why JVM would run out of memory?  I thought GC would clean up 
the memory at a certain ratio.
In general, yes. However, it's easy to eat-up memory when you think the 
GC will take care of *everything*.

Sometimes, you will get a legitimate OutOfMemoryError. These occur when 
your application just plain needs more memory than you have allowed Java 
to use. Setting the max (and usually min) heap size to something larger 
will certainly help with that. However, if you have a memory leak, it 
will only prolong the enevitable.

-chris


signature.asc
Description: OpenPGP digital signature


Re: Tomcat heap vs. java.exe

2004-02-27 Thread Christopher Schultz
Hello,

If I were you, I'd load test your site first before going to production. As
you pointed out, you cannot afford to stop your production server or hang
it with OutOfMemory errors.
This is good advice. Load testing is generally easy to do in 
development, and hard to recover from if you don't do it, once you're in 
prod.

You can get jvm dumps on windows by turning on the -verbosegc. This will
dump out stack traces repeatedly without exiting the JVM.
I don';t think this is accurate. '-verbosegc' only logs the GC activity 
to the stdout or stderr or whatever. It does not generate stack traces 
for you.

CTRL-BREAK on win32 gives you a full thread-dump. This will give you a 
stack trace for any running thread, as well as information about it's 
state (runnable, waiting on monitor, sleeping, etc.). This can be 
valuable when your application is not responding in timely way. If 
you're thrashing or getting LOTS and lots of GC activity, your memory 
settings might be off. On the other hand, if you have horrible code, you 
can never recover from that, even with a dual-cpu box ith a gig of ram :)

-chris


signature.asc
Description: OpenPGP digital signature


Re: Run Applet on Tomcat 5.0

2004-02-26 Thread Christopher Schultz
Henry,

Is anyone know where is Web-accessible directory in Tomcat 5.0.16?
A web-accesible directory is anywhere you could put a JSP or HTML file 
or image. Just some place where a URL can point to the class file and 
the server will give the browser access to it.

-chris


signature.asc
Description: OpenPGP digital signature


Re: Run Applet on Tomcat 5.0 -- Where to put the plugin class files?

2004-02-26 Thread Christopher Schultz
Henry,

Please respond to the list, so everyone can see this conversation. Also 
note that this isn't really a Tomcat question. It's an applet question. 
However, I'm happy to help.

1. I put PluginApplet.jsp in the directory 
[TomcarInstalledHome]\webapps\ROOT\
Okay, that should be fine. Since IE is trying to load your applet, I 
assume that the page is in the proper place.

2. I use IE to browse http://localhost/PluginApplet.jsp
Result: IE failed in initializing PluginApplet.
Where should I put the following 4 class files?
DrawingPanel.class ,PluginApplet.class, TextPanel.class, 
WindowUtilities.class
First of all, I highly recommend using a JAR file since you have 
multiple class files. I believe that most browsers will use the current 
base URI for loading classes, so your classes should be in the same 
directory as your PluginApplet.jsp file (or, at least, the URL created 
by replacing 'PluginApplet.jsp' with 'PluginApplet.class' should resolve 
to your class file.

jsp:plugin type=applet 
code=PluginApplet.class
width=370 height=420
/jsp:plugin
You should, however, specify either the 'codebase' attribute for the 
jsp:plugin element, or use the 'archive' attribute, which would be 
required if you were to use a JAR file.

So, if you JAR'd all your class files together into, say, 
PluginApplet.jar, then your JSP code would look like this:

jsp:plugin type=applet
code=PluginApplet.class
archive=/path/to/PluginApplet.jar
... other attributes like width, etc. ...
/jsp:plugin
Hope that helps.
-chris


signature.asc
Description: OpenPGP digital signature


Re: Run Applet on Tomcat 5.0.16 -- Where should I to put class files?

2004-02-26 Thread Christopher Schultz
Henry,

I still get applet not initialized error after I using  the 
archive=http://localhost/PluginApplet.jar; tag in jsp:plugin.
What is the actual error? IE should provide a more descriptive error 
message when the pplet does not load. Try double-clicking on any 
strange-looking icons in IE's status bar (like the one when you get a 
JavaScript error).

If you're using Sun's VM (with the plug-in), you probably have a Java 
console running in your system tray. Check that for some kind of log, etc.

 Do I have
to setup classpath environment variable on my Windows system?
No.

Do you have any external dependencies that are not provided by the Java 
version you are expecting (like a strange UI library or something)? If 
so, you'll have to make those JAR files available to the applet by 
adding them to the archive attribute, separated by commas, like this:

jsp:plugin type=applet
code=PluginApplet.class
archive=http://localhost/PluginApplet.jar,http://localhost/foo.jar;

/jsp:plugin


signature.asc
Description: OpenPGP digital signature


Re: apache 2, tomcat 5, and ROOT application

2004-02-26 Thread Christopher Schultz
Dean,

I want apache to handle static content
and tomcat to handle servlet related
stuff (jsp, etc). I am wondering how
to specify that in httpd.conf. If I set
DocumentRoot to /home/mywebsite/webapps/ROOT/
that will work for http://mywebsite.com/ but
it will not find myapp. If I set it to
/home/mywebsite/webapps/ it can find
http://mywebsite.com/myapp, but then I don't
know how it can find the ROOT directory.
Here's what you want. For each webapp, you need JkMounts and Aliases. 
You can use VirtualHosts if you have different server names, but this 
works, too.

# Here's the root stuff
DocumentRoot/path/to/webapps/ROOT
JkMount /*.jsp  root-worker
JkMount /whatever   root-worker
# Here's the stuff for 'app1'
Alias   /app1   /path/to/webapps/app1
JkMount /app1/*.jsp app1-worker
JkMount /app1/whatever  app1-worder
You can do this for each of your applications. Just alias the base URL 
to the webapp's directory and add JkMounts.

-chris


signature.asc
Description: OpenPGP digital signature


Displaying a 'down' page with mod_* / Apache

2004-02-26 Thread Christopher Schultz
All,
I was unable to find anything like this on the mod_* howtos or in the 
archives. Sorry if I missed somethign blatently obvious.

I would like to display a 'down' page when tomcat is not running and the 
user hits a URL that gets mapped to a worker.

Do any of the existing connectors do this sort of thing? Ideally, it 
would be something like this:

JkNoConnectionPage /sorry-app-down-for-maintenance.html

...or something like that.

I don't want to just catch error 500 in Apache and use the down page for 
that, since 500 can occur for any number of reasons -- not just Tomcat 
being unavailable.

I'm currently using mod_jk 1.2.5, but will consider switching to another 
mod if one supports this kind of thing.

Thanks,
-chris


signature.asc
Description: OpenPGP digital signature


Re: verbose gc

2004-01-15 Thread Christopher Schultz
Mohammed,

1) [Full GC 34521K-15504K(38328K), 0.5953540 secs]
[GC 27533K-16335K(38328K), 0.0396336 secs]
2) what does the above statements got in catalina.out means, is garbage
collection active?


Yes, garbale collection is active. When the garbage collector runs, it 
will print a line out to stdout (or stderr?) which ends up in your 
catalina.out.

If it runs a 'full' GC (where it takes a lot of time and cleans up a lot 
of stuff), then it'll say Full GC, like the first example. Otherwise, 
it's doing an incremental GC and not hitting everything, like the second 
example. In a healthy syste, you should see lots of regular GCs, and 
occationally see a full GC.

The two big numbers indicate the size of the active heap (the total size 
of 'live' objects before and after the GC). So, in the first one, the 
heap was reduced from 34521k of active objects to 15505k of active 
objects. The number in parens () is the size of the non-permanent heap, 
which is the total heap minus one of the surviver spaces.

The last number is the wall-clock time that the GC was active -- it 
tools half a second to so a full GC and about 1/20 of a second to do the 
incremental GC.

Please see 
http://java.sun.com/docs/hotspot/gc1.4.2/#2.2.%20Measurement|outline for 
more information.

When i execute top command on solaris and see the memory it shows  size and
resisdent memory , what is the diference between the two.
I think this might mean different things to different OSs, but generally 
the size is the total size of executable + code + heap for that 
process -- everything it needs to run. The 'resident' is usually the 
amount of 'size' that's actually in physical RAM and not swapped out to 
disk by the OS.

3) I see that gc statements are logged to catalina.out but the memory usage
keeps increasing, does it mean there is problem with
garbage collection,
When you say 'memory usage', do you mean from top? Right. Java doesn't 
return memory to the OS once it requests it -- there's generally no need 
to do that. Even though Java's heap has more 'space' left over in it, it 
only has space left over for more Java objects. You should not be 
comparing the Java heap and GCs to what you read out of 'top'. You 
should use Runtime.freeMemory (the available heap size), 
Runtime.totalMemory (the total heap size + internal VM memory), and 
Runtime.maxMemory (the maximum amount of memory that the VM will try to 
use).

4) can we get more information like how many obejcts created / objects
destroyed during a gc run, what options to pass to get that information
You need a profiler to do heap inspections, which has been discussed 
many times on this list. I'm not sure you can find out exactly what the 
GC is doing... you might need a very nice profiler for that.

-chris

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


Re: [OT] Apache and Tomcat together

2004-01-15 Thread Christopher Schultz
Mike,

Apache is faster for static content. 
Don't get Yoav started...
:) I have gotton him started on this, before. It's funny, though... last 
time I looked at the Tomcat Connector FAQ, it actually says flat out 
Apache is faster than Tomcat at serving static content: 
http://jakarta.apache.org/tomcat/faq/connectors.html. It does qualify 
that statement by saying that unless you're talking about high traffic, 
then it doesn't really matter. However, they *do* make that claim.

-chris

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


Re: problem with arabic in multilanguage jsp

2004-01-15 Thread Christopher Schultz
Thomas,

Until now, our solution was indeed to put
META HTTP-EQUIV=Content-Type CONTENT=text/html;charset=windows-1256 /
into the html code. ( Tomcat 4.1.24)
If the browser finds a content type in the HTTP header, it 
ignores the HTML header.
What? The whole point of the META tag is actually to *trump* the HTTP 
header. That's the whole reason that the META HTTP-EQUIV tag exists. For 
the browser to ignore what you put in there pretty much breaks the 
rules, right?

-chris

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


Re: Signal 11 crash and mod_jk, mod_jk2, apache2

2004-01-15 Thread Christopher Schultz
All,

With RH8, I assume that at the very least you'll need to set 
LD_KERNEL_ASSUME.

I would consider that the first course of action, and likely would not 
need to do anything else. I could see hyperthreading a problem if the 
kernel didn't support it very well. You could try the latest 2.4.x kernel.
If the LD_ASSUME_KERNEL doesn't help, try disabling both SMP and 
hyperthreading at the same time. I think that's your next most likely fix.

Just a note: I've had big, beefy servers die with SIG11 on Linux before 
(or course, that was back when a dual athlon 1GHz was considered 'beefy' 
:). Anyway, we tried everything, including hiring BEA consultants for a 
bazillion dollars per hour to help us tune both Weblogic and our VM.

It turned out to be bad hardware. We had six identical machines and two 
of 'em kept crapping out. They just sucked. The only solution was to 
send them back to the manufacturer and ask for more. It turns out that 
not only did those two (production!) machines suck, but two QA machines 
and one dev machine (all the same) sucked, too. They all died when we 
put them under high load. They seemed to do okay under development load 
(about zero).

I'll never buy a machine from Penguin Computing again.

Just wanted to mention that sometimes it's not the software's fault. Do 
you have other similar machines that you can try this on?

-chris

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


Re: How can I count the number of active requests/servlets for Tomcat?

2004-01-15 Thread Christopher Schultz
Tom,

I'm running a web service using Axis with Tomcat.  How can I count 
the number of active requests?
I think you want to use a Filter for your requests:

public class ConnectionCounter
implements javax.servlet.Filter
{
private int _activeConnections = 0;
public void init(FilterConfig fc) { }
public void destroy() { }
public doFilter(ServletRequest req,
ServletResponse rsp,
FilterChain fc)
throws ServletException, IOException
{
synchronized(this) {
++_activeConnections;
}
		fc.doFilter();

synchronized(this) {
--_activeConnections;
}
}
public int getActiveConnectionCount()
{
// Need not be synchronized, int access is atomic
return _activeConnections;
}
}
Of course, you'll need to get a reference to your filter in order to
read the connection count, but that is an exercise left to the reader :)
I used the HttpListener interace but the sessionDestroyed method
doesn't seem to get called until 5 minutes after the servlet ends.
Ouch. You have web services that use sessions? You should probably turn 
off http sessions for those...

-chris

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


Re: org/apache/tomcat/logging/Logger

2004-01-14 Thread Christopher Schultz
Jake,

I got this error in one tomcat application
java.lang.NoClassDefFoundError: org/apache/tomcat/logging/Logger
It looks like you're missing the log4j library for that particular
application.
Where you do you see anything about Log4j here?
Sorry; complete brain fart, here. Yeah, this has nothing to do with 
log4j. I was unable to find that class in the JARs that I have in my 
copy of Tomcat (4.1.29).

-chris

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


Re: Sessions and clients

2004-01-14 Thread Christopher Schultz
Ralph,

Is there any way to have the second servlet have access to the same
session data that the first one has?  

Just include the session id in the request. 
(As query parameter or as form field) 
This will work as long as you are submitting the request to the same 
server; if it's going to another server, you'll have to make sure that 
you use some kind of session replication.

-chris

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


Re: multiple instance mode on Windows

2004-01-14 Thread Christopher Schultz
Venk,

Does running multiple instances of tomcat on the same server running on 
Windows Server 2000, involve running a seperate JVM for each instance?
I would think that one of the only reasons for running separate Tomcat 
instances on the same machine would be for separation of execution 
environment. In that case, does it even make sense to run them in the 
same VM? Why do you want multiple Tomcat instances?

On the other hand, you might want to run two different versions of 
Tomcat in a minimum of memory...

Also, when using tomcat in production environment, does directing all 
System.out statements to tomcat console effect its performance? How can this 
be avoided? Where would I set the JVM options it run the garbage collector in 
incremental mode?
You want to set the CATALINA_OPTS environment variable to include JVM 
options in your startup script. If you're running Tomcat as a service 
(which is probably true in production), you'll need to look into how the 
service actually starts itself (Sorry, I have very little win32/Tomcat 
experience).

-chris

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


Re: problem with arabic in multilanguage jsp

2004-01-14 Thread Christopher Schultz
Thomas,

we are running a tomcat instance that uses common jsps for all languages. If
no encoding is set in the http-header tomcat 4.1.29 sets iso-8859-1 by
default. Arabic users must then configure their browsers themselves
(unacceptable).
(1)
If I set the encoding in the jsp like this:
[EMAIL PROTECTED] contentType=text/html;charset=windows-1256%
everything is fine. But as I told, our jsps are multilingual.
(2)
If I set the encoding in  the jsp like this:
%
response.setContentType(text/html;charset=windows-1256);
%
the results are just question marks. The same thing happens if the arabic
text is not hardcoded in the jsp but comes from a varable.
Have you tried using:
META HTTP-EQUIV=Content-Type CONTENT=text/html;charset=windows-1256 /
Does this trigger the browser to display the text properly? If so, you 
might consider adding this for some languages (like Arabic).

-chris

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


Re: Memory Leaks

2004-01-14 Thread Christopher Schultz
Yoav,

 With JDK
1.4, there's a runtime parameter to ignore System.gc() calls and that
parameter may be on by default in the future.
What is this parameter? I've never seen it before...

-chris

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


Re: Memory Leaks

2004-01-14 Thread Christopher Schultz
Yoav,

With JDK
1.4, there's a runtime parameter to ignore System.gc() calls and that
parameter may be on by default in the future.
What is this parameter? I've never seen it before...
-XX:+DisableExplicitGC is the parameter, which I believe has been
available since JDK 1.4.0.  
Wow, I didn't know that -XX parameters existed. Where can I get more 
information on these, if you don't mind?

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


Re: Vedr.: Re: Memory Leaks

2004-01-14 Thread Christopher Schultz
Thomas,

sorry for interrupting but if you into optimizing your JVM setting as well 
as explorings its options I would recommend:
Perhaps some of the more savvy developers can give more directions.
Thanks for the pointers. Actually, I'm not having any performance 
problems at the moment :)

As always remember the best tests are those carried out by yourself 
profiling you applications  - if I didnt say SOMEONE else would have... 
I've been running OptimizeIt and Tomcat together and quite a while. You 
don't need to convince me!

-chris

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


Re: org/apache/tomcat/logging/Logger

2004-01-13 Thread Christopher Schultz
I got this error in one tomcat application 
java.lang.NoClassDefFoundError: org/apache/tomcat/logging/Logger
It looks like you're missing the log4j library for that particular 
application. Check the WEB-INF/lib directory for a log4j-looking JAR 
file. It's also possible that the code was compiled with a later version 
or log4j, and deployed with an earlier version (the Logger class is 
somewhat new).

-chris

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


Re: mod_jk handling all content (not just dynamic)?

2003-12-22 Thread Christopher Schultz
Chris,

[Sat Dec 20 13:41:33 2003]  [jk_uri_worker_map.c (500)]: Attempting to
map URI '/admin/something.html'
[Sat Dec 20 13:41:33 2003]  [jk_uri_worker_map.c (618)]:
jk_uri_worker_map_t::map_uri_to_worker, done without a match

Even if I comment out all JkMounts in httpd.conf, this problem occurs. 
Is it really a problem?  It seems that jk should not even be seeing
requests for static content.
Did you re-start Apache after making that change? Are you sure you're 
modifying the correct file?

Send us a clip of your configuration.

-chris

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


Re: Fwd: Help, only viewing source of my index.jsp page - Apache 2.0.48 Tomcat 4.1.29 mod_jk_1.2.5_2.0.47.dll

2003-12-22 Thread Christopher Schultz
Lenny,

My problem is that when I enter www.mysite.com the source from my
index.jsp is displayed.
This is almost always a misconfiguration of JkMount directives.

It appears that the virtualhost setup in my
http.conf is finding the mysite directory in Tomcat, but for some
reason cannot display the index page as it should. I have index.jsp
setup in my web.xml as my welcome page.
 VirtualHost www.mysite.com
 ServerName www.mysite.com

 # Static files

DocumentRoot D:/java/Tomcat41/webapps/mysite
Alias /mscarloans D:/java/Tomcat41/webapps/mysite

JkMount /mscarloans/*.jsp  ajp13
This line maps all JSP files in the /mscarloans/ tree to be sent to 
Tomcat for processing. There doesn't appear to be any other JkMount for 
this VirtualHost. I think you want thic changed to something like:

JkMount /*.jsp ajp13

 Location /mysite/WEB-INF/*
 AllowOverride None
 deny from all
 /Location
Good call! Lots of people forget about this!

  Directory D:/java/Tomcat41/webapps/mysite/WEB-INF/
 AllowOverride None
 deny from all
  /Directory
You should generally do the Directory one. That makes it so that, no 
matter what strange location and URL games are played, any request that 
ultimately points to files in this directory are denied. With the 
Directory config, you don't even need the Location config.

Hope that helps,
-chris
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: How can I compile Mod_jdk2 ?

2003-12-19 Thread Christopher Schultz
William,

I use the jakarta-tomcat-connectors-jk2-2.0.2-src and try this:
./configure --with-apxs2=/usr/local/apache2/bin/apxs \
--with-apache2=/usr/local/apache2\
--with-apach2-include=/usr/local/apache2/include\
--with-apache2-lib=/usr/local/apache2/lib \
then in the end of configure process, I received a message:
no apxs given
building connector for apche-2.0 
configure: error: can't locate /usr/local/apache2
Hmmm... do you really need all those options? I would think that:

./configure --with-apxs2=/usr/local/apache2/bin/apxs

would be sufficient. Let's see...

$ tar xzf jakarta-tomcat-connectors-jk2-2.0.2-src.tar.gz
$ cd jakarta-tomcat-connectors-jk2-2.0.2-src/jk/native2
$ ./configure --with-apxs2=/usr/local/apache2/bin/apxs
[completed successfully]

$ make

[completed successfully]

$ ls ../build/jk2/apache2/*.so
../build/jk2/apache2/jkjni.so
../build/jk2/apache2/mod_jk2.so
$
Looks good to me. I also built my Apache 2.0.48 from source. The code, 
etc, is in /usr/local/httpd-2.0.48, and not in /usr/local/apache.

It's funny that the build instructions in the jk directory say Just 
type ant!, and it fails miserably. Too bad. I like the whole 
configure/make/make install. It tends to work well.

Let me know if you are still having problems compiling...

-chris

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


Re: Convert Text to Image [OT]

2003-12-18 Thread Christopher Schultz
Andoni,

Does anyone know of a tool for Converting Text to images so that I
can still have image buttons on my site while having it localised?
PS: I have taken a look at AcmeGif I am looking to see if there is
something better though.  Or tutorial help on AcmeGif.
Back when I was working for a client on a web-based website builder 
(don't ask...), we used a tool called Macromedia Generator would could 
do tons of sexy things like placing text on top of an existing image, 
with other text effects, too.

We paid like a million bucks a day for the licence or something, and we 
never used the tool to it's fullest extent. What a shame.

Anyhow, that tool exists, and it'll do *everything* you want. I guess it 
depends on the amount of money you want to spend. I always wanted to do 
a minimal all-Java re-write of the stuff we needed. It would be faster, 
cheaper, and easier to manage. (MM Generator only ran on WinNT in those 
days... all those Sun boxes and a single WinNT box for this tool).

If I were you, I'd whip up something quick and dirty around the 
following core:

BufferedImage bi = new BufferedImage(-- sizes --);
bi.drawImage(0,0,, etc... if you want to have an image underneath);
bi.drawString(center coords, messages.getString(hello.world));
Then, either use AcmeGif or Java's JAI package or the 
always-there-but-never-supported com.sun.image.codec.jpeg package:

http://java.sun.com/j2se/1.4.2/docs/guide/2d/api-jpeg/overview-summary.html

Good luck,
-chris


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


Re: How can I compile Mod_jdk2 ?

2003-12-18 Thread Christopher Schultz
William,

I trying to compile the mod_jdk from the source version
jakarta-tomcat-connectors-jk2-2.0.2 but everytime an error happens.
Please provide more information. The error message itself, perhaps.

Does anybody know a place where I can get a binary for linux, to connect
my apache 2.0.48 and Tomcat 5.0.16 ?
This does not exist. Binary versions are not available from Jakarta for 
Linux. It's because you need to compile it against your own apache 
version and libc version. Sure, you *can* get one from someone else, but 
it shouldn't be a big deal to compile it.

Or maybe send-me the module by e-mail
That's a dangerous request. Someone could send you a trojan...

I using Fedora Core box and J2sdk 1.4.2

If this is impossible, maybe someone just has passed for the same
troubles ?I have now, and help me with something.
Check the archives for your specific error message. We've beat this to 
death like a million times on this list. If your error mesage is not 
found, just followup your own post with the error and we'll see what we 
can do.

Since you're using Fedora, it's very possible that you are missing some 
required library. Fedora isn't exactly ready for prime time. :)

-chris

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


Re: Benefits of Apache Server

2003-12-17 Thread Christopher Schultz
Yoav,

I would be very careful with a claim like Ms. Smoak's, Apache is...
much faster serving static resources as that's highly qualitative.
Please provide benchmarks or tests that prove your point, because I
don't think it's much faster at serving static resources.
Retraction!  I should have said, Apache is faster at serving static
resources than the Tomcat/connector/Apache combination.  I've never
tested Tomcat alone vs. Apache alone-- Apache was in place here before I
started writing webapps.
I think we can all agree that this statement is true. Certainly adding 
Apache to Tomcat is slower than having Tomcat do the work all by itself.

I don't have benchmarks, and I've made the statement Apache is faster 
for static content tthan Tomcat before, and I still believe it to be 
true. Here's why:

When Apache httpd serves a static resource, it pretty much goes through 
all the processing required to find out where the file actually is, and 
then dumps the bytes to the response. I'm pretty sure that it does all 
this without allocating anything on the heap -- most of the object/data 
structures necesary for the lookup I'm sure already exist, and the 
buffer for the response is probably fixed, and probably on the stack.

For Tomcat to do the same thing, it's got to create a bunch of objects 
which later need to be garbage-collected. I'm guessing that the Tomcat 
devs have streamlined the process so that not all of the ServletRequest 
objects and all that jazz are created every time, but you still have to 
create a lot of stuff on the heap (including every String used, like the 
URL, and maybe some headers, etc.). After that (probably after the 
response has been sent to the client, which is why the numbers are hard 
to track down), the GC has to run. I think that I can make the blanket 
statement that explicit memory management is faster than GC'd memory, 
since the GC actually to do some work to determine if memory can be 
freed, while the explicit scheme needs no such processing.

I am willing to concede that Apache vs. Tomcat in a direct competition 
for serving up static content on the same hardware will probably result 
in timing differences so small as to be insignificant to anyone doing 
reasonable benchmarking.

Lastly, if you have your architecture such that you have crappy machines 
in front of the application servers to serve static content (so that the 
app servers don't waste time serving static content), Apache will run 
must better on them since it requires fewer resources to run nicely. For 
example, Apache can do quite nicely on a 16MB machine as a web server. 
Tomcat can't really do that since the JVM is such a monster.

-chris

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


Re: how to change default SMTP port 25 in java mail?

2003-12-16 Thread Christopher Schultz
Bopanna,

1. This is not related to Tomcat. Please try a JavaMail list next time.

2. RTFM: 
http://java.sun.com/products/javamail/javadocs/overview-summary.html

Search the page for port.

-chris

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


Re: help using JDBCRealm - how to relate a realm with a security constraint

2003-12-15 Thread Christopher Schultz
Pedro,

What i have done:
1. modify the server.xml file to add a Realm tag (Realm 
className=org.apache.catalina.realm.JDBCRealm debug=99 
connectionName=root connectionPassword= 
connectionURL=jdbc:mysql://myserver:3306/mydatabase 
driverName=org.gjt.mm.mysql.Driver roleNameCol=role_name 
userCredCol=user_password userNameCol=user_name 
userRoleTable=user_roles userTable=users /)
Where did you put this declaration? In the Context of your web 
application? I recall that Realm declarations can appear in multiple 
places. Make sure that it appears in the Context where you have:

2. modify the web.xml to add a security-constraint tag ( 
security-constraint
web-resource-collection
web-resource-nameArea de pruebas de 
seguridad/web-resource-name
url-pattern/cosa.jsp/url-pattern
url-pattern/test.jsp/url-pattern
http-methodDELETE/http-method
http-methodGET/http-method
http-methodPOST/http-method
http-methodPUT/http-method
/web-resource-collection
auth-constraint
  descriptionrol de administrador/description
role-nameYYY/role-name
/auth-constraint
/security-constraint
)
This looks good. What is the URL that you expect to be protetced, and is 
not protected? Also, try removing the http-method settings, just in 
case that is complicating things.

-chris

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


Re: Image Viewing

2003-12-12 Thread Christopher Schultz
All,

It would be img src=http://yourserver/yourservlet?param=paramValue;
alt=something
This still doesn't answer the original interpreted question. I don't 
think it's possible to display an image on a page and prevent users from 
browsing to it directly from their browser.

The only thing I can think of is to check the REFERER header to see if 
it came from the page on which you want to display it. That's also not 
foolproof...

-chris

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


Re: Cookies.

2003-12-08 Thread Christopher Schultz
Abdul,

So, I have added the cookies value in servlet, and I can get the cookie
value in jsp. When I work with the same browser fine working. But when close
and open the new browser window I cant get the cookie values.
Setting cookie,
res.addCookie(new Cookie(entID,eID));
res.addCookie(new Cookie(lgnId,lgnId));
I checked the javadoc documentation for the Cookie class, and it doesn't 
seem to mention the default life of a Cookie object once sent to the 
browser. I'm inclined to think that the default is that it will live as 
long as the browser session does (especially because of your evidence).

Try this:

Cookie cookie = new Cookie(entId, eID);
cookie.setMaxAge(cookie_life_in_seconds);
res.addCookie(cookie);

cookie = new Cookie(ognId, ignId);
cookies.setMaxAge(cookie_life_in_seconds);
res.addCookie(cookie);

This is likely to extend the life of your cookies beyond the browser's 
session. Therefore, they will be sent in requests after the browser is 
restarted.

-chris

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


Re: Servlets with JDBC connectivity

2003-12-03 Thread Christopher Schultz
Todd,

SQLUtils.executeQuery(a SQL statement);
SQLUtils.executeUpdate(another one);
Just out of curiosity, what do these methods return? If the former 
returns a ResultSet object, then you're in for a world of trouble. The 
ResultSet will never get closed, or you'll close the connection over 
which the ResultSet communicates, and then you're hosed, 'cause the 
calling code can't access the data.

-chris

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


Re: Global Variables

2003-12-03 Thread Christopher Schultz
Duncan,

and String param = servletContext.getInitParameter(param);

Thanks for the replies, but what do I define servletContext as?
In every JSP, the ServletContext object is implicitly declared with the 
identifier application.

So, you should just be able to do something like this in your JSP:

p
   my_param = %= application.getInitParameter(my_param) %
/p
-chris



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


Re: Optimizeit remote profiler

2003-12-03 Thread Christopher Schultz
Steffen,

I have Windows XP as client running the UI and I want to profile my tomcat
4.1.29 server on debian 3.1 sarge running on sun jvm 1.4.2.
I have basically the same environment, and mine has worked.

The profiler attaches to the server and I do get very few information, but
the list of instances stays completely empty.
Are you sure that it connects? How are you starting Tomcat?

-chris

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


Re: Tomcat 4.x non .jsp suffix for includes?

2003-12-03 Thread Christopher Schultz
Richard,
Does anyone know how to configure tomcat to compile .jnc files in this 
circumstance?

Is there a standard convention for naming jsp include files?
Yeah, .jsp :)

Seriously, though. Check out CATALINA_HOME/conf/web.xml for how they 
configure the .jsp file trnaslator/compiler. You could modify the that 
web.xml file to include the same type of things for .jsp files, or you 
could modify the deployment descriptor for your application.

Unfortunately, modifying your deployment descriptor will make your 
application non-portable. But, you are already making your .jsp files 
called something else, anyway, so you'll have to do some sort of 
re-configuration for every app server you indend to use.

-chris

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


Re: Please Help to compile mod_jk2 on AIX

2003-12-02 Thread Christopher Schultz
Jose,

These all seem to be warnings, not errors. Does the build succed in
creating an object file?

Yes object file is created.
Okay, I think you're safe ignoring those warnings, then.

Are you using apxs to create an Apache DSO? If so, the file 
apache-2.0/mod_jk.la should exist (or apache-1.3/mod_jk.so for Apache 
1.3). You can simply copy it to your Apache modules directory. (Sorry, 
these are for mod_jk... mod_jk2 is likely to have the filenames slightly 
different).

Basically, you're looking for mod_jk.la for Apache 2.0 and mod_jk.so for 
Apache 1.3.

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


Re: Tomcat 4.0.x memory leak (not javac)

2003-12-02 Thread Christopher Schultz
All,

http://www.apache.org/dist/jakarta/tomcat-4/v4.1.29/RELEASE-NOTES
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20758
Uhhh... this looks like standard operating procedure for Java to me...

When you dump a ClassLoader and all of it's object get GC'd, the VM 
almost never GC's the unused classes. The new ClassLoader re-loads all 
those classes, again, and you get new versions of those classes 
loaded into the VM. Even if there are no more instances of those 
classes, I thought they stuck around...

I was not suprised by anything mentioned in that bug. The only thing 
that's a shame is the fact that it's true, and it does interfere with 
the ability of an app server to re-load contexts indefinately. :(

The -Xnoclassgc option still exists for the 1.4.1 VM, so maybe I'm 
completely wrong, here. :)

-chris

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


Re: SessionListener

2003-12-02 Thread Christopher Schultz
Justin,

Won't quite do it, JDBCRealm looks for users in a database, I want to
connect a user TO a database using their credentials, but the code to
do this feat will be quite minimal by comparison.
This will make it hard to use a connection pool (which you mentioned
that you do/want to do).
Is there a particular reason for the database access paranoia? Most apps
connect to the db using the same login regardless of the user actually 
logged in to the application. They use other types of permission 
checking to see if you can perform some action, instead of relying on 
thr database for that kind of checking.

I absolutely agree that having multiple layers of security is great, but 
this one may make your application suck really bad, especially if you 
are using a db like Oracle, where the database connections are anything 
but lightweight.

-chris

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


Re: OutOfMemory Exception initializing page context

2003-12-02 Thread Christopher Schultz
What's with all the OOM questions this week? I've noticed that topics 
tend to come in waves.

I wonder if there are only like 5 people out there that post to the 
newsgroup, but they have all kinds of alias and alternate personalities 
so that the average response is what they use to solve their problems :)

Just an amusing thought to make me smile. :) There. I did it.

-chris

Shapira, Yoav wrote:
Howdy,
Once you're out of memory, the system is in a bad state and must be
restarted.  You will see error messages that are at best meaningless and
at worst misleading, because they will make you look in the wrong
places.  You want to fix the memory issue first, by adding more memory
(via the -Xmx java command-line parameter) or fixing a memory leak if
there's one in your application.
Do not assume, for example, that the IllegalStateException you cite has
anything to do with the OutOfMemory error: it may be a misleading
message thrown by the system after it ran out of memory (even though it
shows up before the OutOfMemoryError in the log) while it was thrashing
to GC stuff by invalidating your sessions.
Yoav Shapira
Millennium ChemInformatics


-Original Message-
From: Rob Wichterman [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 02, 2003 9:57 AM
To: [EMAIL PROTECTED]
Subject: OutOfMemory Exception initializing page context
Hello,

I am having major memory problem that I have been fighting through.
Has

any body ever seen this one.  Here are the errors that always come up
in

my logs.

1.  java.lang.IllegalStateException: getAttribute: Session already
invalidated
2.  JspFactoryImpl: Exception initializing page context
java.lang.IllegalStateException: Cannot create a session after the
response has been committed
3.  JspFactoryImpl: Exception initializing page context
java.lang.OutOfMemoryError
Any help at all would be greatly appreciated.

Thanks,

Rob Wichterman




This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged.  This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender.  Thank you.

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



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


Re: OutOfMemory Exception initializing page context

2003-12-02 Thread Christopher Schultz
Rob,

Well I have had my -Xmx set to as high as 1gb and I still receive these
errors.  The site will stay running for at best 1 day without crashing.
I was just hoping one of these could point me in a direction while I
work on looking at memory leaks.
Sorry for the levity. Try this:

Turn on verbose GCs, and make sure you're sending stdout to a log file 
(Tomcat does this by default, I think). Empty the stdout log file, 
restart Tomcat and then let it run out of memory.

Take a look at the GC output (they are prettty obvious) and see what's 
happening to memory. I've done this in the past, and I even wrote a 
(long lost) Perl script to parse the log file and generate X-Y 
coordinates that I could plot using Excel. We could plainly see that 
there was a memory leak of some kind because the graph kept going up and up.

It does take a long time to find memory leaks but there are a couple of 
things you can check.

First of all, what JSK are you using?

Check some of the following:
- Are you starting any of your own threads? If so, are they dying when 
the context reloads?
- Are you reloading the context a lot?
- Do any of your container objects like hashtables or whatever keep 
references to things like the ServletContext, etc.?
- Do you regularly remove old objects from users' sessions?
- Are you doing any XSLT?
- Are you using a database connection pool or are you creating new 
connections for each user?
- Do you keep any persistent connections like sockets or anything open?

-chris

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


Re: load-on-startup and multiple coyotes

2003-12-02 Thread Christopher Schultz
Steffen,

As soon as I start using 2 coyote connectors together with load-on-startup
tomcat initializes the database pools twice.
Interestingly it keeps initializing things twice even if I add a third
coyote.
In about two minutes, Yoav Shapira is going to tell you this:

Don't use a servlet to initialize your stuff. Instead, use a 
ContextListener. IT's cleaner, more flexible, and only gets loaded when 
it should get loaded.

I used to have InitServlet-style initialization, but now I use 
ContextListeners.

They're pretty easy: create a new class that implements 
javax.servlet.ServletContextListener.

Once you move your code from your old InitServlet, you have to install 
it into the web.xml file like this:

listener
listener-classfully.qualified.InitListener/listener-class
/listener
Put this section right before any servlet definitions but after any 
filter and filter-mapping sections you have.

-chris

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


Re: Tag Handler pool eating up Memory (and enablePooling is set to false)

2003-12-02 Thread Christopher Schultz
Neil,

This is strange.  When I created a heap dump from my server
just now, it does not have any instances of TagHandlerPool
in the heap dump.  That is what I expected before, but I still
had them in my last dump.
That is weird. However, you still have a bunch of tag handler instances, 
I see...

Doing a quick grep on my summary results from the new heap dump,
I get this result:
60256,1076,com/slsideas/pagegen/tags/SetPropertyTag
31296,652,com/slsideas/pagegen/tags/ValueTag
The first column is the total bytes held by the instance inself (not
including references), the second column is the number of instances that
 were present in the heap dump, and the last column is the type of
 the object.
So you have 60k in SetPropertyTag objects? If you use them a lot 
(without pooling), then you'll get a lot of them on the heap at any 
given time. Can you observe that the number keeps going up, and never 
goes down?

I find it very hard to believe that we have over 2500 active instances
of our tags.  This seems to imply they are not being garbage collected.
Not necessarily. It might just be that they are taking a while to get 
GC'd. Again, what do you observe over time?

I don't belive the StringBuffer is the cause of my problems.
Okay, that's good.

-chris

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


Re: Can Tomcat really run cgi scripts?

2003-12-02 Thread Christopher Schultz
Ken,

 But now I'm stuck with this error:
java.io.IOException: CreateProcess: perl
C:\Tomcat4112\webapps\examples\WEB-INF\cgi\exp.cgi
This is likely to be due to the lack of PATH information available to 
the script itself. Try using #!/usr/bin/perl in your script instead of 
#!perl

I've heard some complains about sub-process permissions, but my initial 
reaction is that they are errant complaints.

-chris

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


Re: OutOfMemory Exception initializing page context

2003-12-02 Thread Christopher Schultz
Rob,

I consulted with the developers and they said we don't use or do
anything that you suggested except we do use tomcat's connection pooling
for oracle.
Okay, that's good. Sometimes, people don't use connection pooling or do 
it improperly, and leave Connection objects lying around. SQL Connection 
objects do not clean themselves up nicely, if they even clean themselves 
up...

We are running Sun j2sdk1.4.2_02 with the Concurrent Mark
Sweep GC with -Xmx512m. I currently use the verbose logging for GC
times.  The odd thing is that it does not seem to progressively go up
but rather spike up with high GC times and the full GC will not clean
anything out.
Hmm... that's a little odd. You say you get huge, sudden spikes from 
which the GC cannot recover? That sounds like bad news. Do you have any 
data on which pieces of code (servlets, JSPs, actions) are being 
executed when this happens? Consider adding a request logger filter to 
see what might be causing the spike...

-chris

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


Re: OutOfMemoryError

2003-12-02 Thread Christopher Schultz
Trenton,

Are you using the context reloading feature?  reloadable=true or
using
the tomcat manager app will cause this to happen eventually.
Really?  Prove that please...


Actually, I can't prove it in his instance, but I have proved it time and time
again on ours.  I'm using 4.0.4 right now though so I haven't verified 4.1.x.
But, I heard that this is still the case in 4.1.x.
To reproduce this problem just reload a context over and over.  Depending on
how much memory it uses, it will start throwing OutOfMemory exceptions long
before the -mx JVM parameter value is ever reached.  eg.  I do a ps on linux
and it shows it as using like 140M or something like that and it already
starts throwing out of memory exceptions.
Aah. I think I see a part of the problem. First of all, the amount of 
memory shown by 'ps' is completely irrelevant, except that it shows how 
much memory that the OS has allocated to the Java process. This is 
allowed to be more than the max heap size set for Java.

The heap is not related to the amount of memory the OS allocates, except 
that the OS report will always be larger than the heap report from Java.

You can get an OOM even if you have the heap set to 1GB and yet the 
process only has 50MB used. This is because OOMs usually happen *while 
the GC is doing its work*. I'm not sure if there's another thread that 
increases the actual size of the heap for you, but if so, I'm sure it's 
related to the GC anyway.

So, moving on, what usually happens is that a low memory condition 
triggers a GC (usually a full GC). When the GC runs, it needs some 
memory to work with. If it cannot allocate memory for itself, it will 
die with an OOM. If the heap hasn't increased, yet, then the GC cannot 
allocate more objects on the heap to do it's thing. That can explain why 
you get an OOM when you are way under the heap size in the output of ps.

With our applications that we're running, we can usually get away with roughly
5-10 context reloads.
Do you have any 3rd party containers or such that live outside of the 
context (their JARs would be in CATALINA_HOME/server/lib or 
CATALINA_HOME/common/lib -- someone please confirm that the second of 
these two does *not* get discarded along with the rest of the context 
upon reload). If you are using 3rd party containers like this, they will 
not dump their contents when you re-load the servlet context. If you 
have static singleton instances of these, then you'll likely fill up 
memory all the time.

This could also be related to the Java doesn't GC java.lang.Class 
objects thread that's going around this week, too.

-chris

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


Re: Tomcat reload / classloader / connection pool

2003-12-02 Thread Christopher Schultz
Marcel,

The problems with Tomcat occur upon reload of the web app. The
classloader reloads the whole app and all my DB connections get opened
again. This wouldn't cause much pain if the existing connections were
garbage collected i.e. finalized. This doesn't happen and after a couple
of reloads the DB's max connections limit is reached...
Where do the class files for your DB connection pool live?

Is there a reason to use your own home-brewed CP other than bragging 
rights? :)

First of all, why is this so?
This is likely because of the way you use the singleton. When you have a 
singleton (I use quotes because it's probably not a real singleton 
otherwise we would not be having this discussion) the static data is 
associated with the java.lang.Class object that gets created when your 
class is loaded. When the re-load occurs, that static data sticks 
around. The new classloader used for the new context loads a new copy of 
the singleton and they pile up over time. You need to shutdown the 
connection pool before the context dies.

Second of all, how can I prevent this? Somehow listen for reloads and
react appropriately?
Yes. Consider writing a ServletContextListener and closing the pool 
before the context goes down. It will be run when the new context comes 
up, too.

Check the documentation for javax.servlet.ServletContextListener

Instead of deploying the framework JAR in the web app's WEB-INF/lib
directory I could place somewhere in the regular CLASSPATH, but then all
web apps would have access to the same ConnectionFactory :-((
Yes, and the problem would get worse.

-chris

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


  1   2   3   4   >