Re: crontab problems
For jdk1.4 you should be able to set the networkaddress.cache.negative.ttl system property to control this. (Assuming the lookups are made using the java.net.* sub-system) http://java.sun.com/j2se/1.4/docs/guide/net/properties.html http://java.sun.com/j2se/1.4.1/networking-relnotes.html We're still on 1.3.x in production :( Oscar Carrillo wrote: How bizarre. AFAIK, this is the same problem MS Windows has with it's DNS implementation. That's why IE never can re-connect after it gets a bad DNS lookup. Oscar On Wed, 26 Feb 2003, Ralph Einfeldt wrote: Because the underlying classes sometimes cache a negative response, so you have to restart tomcat to enable a new lookup. (That's not specific to tomcat) -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 3:02 AM To: Tomcat Users List Subject: Re: crontab problems Regarding your problem: I don't understand why bouncing Tomcat would resolve a DNS problem. The UnknownHostException is a indication that something is wrong with DNS or the resolver library. - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: crontab problems
I would consider two monitors: - One local that restarts tomcat if the process is not alife anymore. For this monitor ps can be enough. More sophisticated checks should only be done if you are shure that you want to automatically restart tomcat if this checks fail. - One remote that calls/mails the service if tomcat is not working. What exactly 'not working' means and which checks you have to implement to verify that depends on the application and the requirements. -Original Message- From: Turner, John [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 9:42 PM To: 'Tomcat Users List' Subject: RE: crontab problems Well, to be paranoid, it would have to be on a remote machine. If it wasn't, a network outage would take your app down, but your monitor would keep right on merrily testing your web app. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: crontab problems
Because the underlying classes sometimes cache a negative response, so you have to restart tomcat to enable a new lookup. (That's not specific to tomcat) -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 3:02 AM To: Tomcat Users List Subject: Re: crontab problems Regarding your problem: I don't understand why bouncing Tomcat would resolve a DNS problem. The UnknownHostException is a indication that something is wrong with DNS or the resolver library. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: crontab problems
Do you know which class cache the negative response -Original Message- From: Ralph Einfeldt [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 2:07 AM To: Tomcat Users List Subject: RE: crontab problems Because the underlying classes sometimes cache a negative response, so you have to restart tomcat to enable a new lookup. (That's not specific to tomcat) -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 3:02 AM To: Tomcat Users List Subject: Re: crontab problems Regarding your problem: I don't understand why bouncing Tomcat would resolve a DNS problem. The UnknownHostException is a indication that something is wrong with DNS or the resolver library. - 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: crontab problems
The attachment must have been stripped by something ... import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; /** * @author Hannes Schmidt. */ public class UrlWatchdog { private static int sleepSeconds = 60; private final static String watchedURL = http://put.your.url/here;; private final static String expectedContent = your text too look for in the response; private final static String restartCommand = your restart command; public static void main( String[] args ) { try { URL url = new URL( watchedURL ); for(;;) { boolean success = false; try { URLConnection con = url.openConnection(); con.setUseCaches( false ); try { con.connect(); if( parseResponse( con ) ) { success = true; } } catch( IOException e ) { e.printStackTrace(); } } catch( IOException e ) { e.printStackTrace(); } if( ! success ) { restart(); } try { Thread.sleep( sleepSeconds * 1000 ); } catch( InterruptedException e ) { e.printStackTrace(); } } } catch( MalformedURLException e ) { e.printStackTrace(); } } private static boolean parseResponse( URLConnection con ) { InputStream is = null; InputStreamReader isr = null; BufferedReader br = null; boolean success = false; try { try { is = con.getInputStream(); isr = new InputStreamReader( is ); br = new BufferedReader( isr ); String line; while( null != ( line = br.readLine() ) ) { if( -1 != line.indexOf( expectedContent ) ) { success = true; } } } finally { if( br != null ) br.close(); if( isr != null ) isr.close(); if( is != null ) is.close(); } } catch( Exception e ) { e.printStackTrace(); } return success; } private static void restart() { try { Runtime.getRuntime().exec( restartCommand ); } catch( IOException e ) { e.printStackTrace(); } } } - Original Message - From: Ron Day [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 3:59 AM Subject: RE: crontab problems No Code attached ??? -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 8:02 PM To: Tomcat Users List Subject: Re: crontab problems I attached a version of my sample code that actually works (JDK used 1.4.1). Regarding your problem: I don't understand why bouncing Tomcat would resolve a DNS problem. The UnknownHostException is a indication that something is wrong with DNS or the resolver library. - Original Message - From: Ron Day [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 1:37 AM Subject: RE: crontab problems I have code very similar to this that does work... except whenever I get an unknowHostException, it seems to be cached somewhere until I bounce Tomcat. My code actually pulses another website (in a thread every 3 minutes)that is on the network, rather than check Tomcat. In place of your streams, I actually set the request method to HEAD, and interrogate the Response Code. This is easy to do in HTTPURLConnection. I instantiate the URL outside the loop (and hence only once), and I am wondering if this is the source of my problem. I plan to test it ASAP. ron - 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: crontab problems
It doesn't matter. Its a JDK issue. (IIRC) Successful (and unsucessful?) DNS lookups are cached forever during the life of the JVM. So if you start tomcat on Jan 1, 2003 and tomcat looks up foo.com that day - the lookup (across the network) is not done again. So if the address changes Jan 2 tomcat will have the wrong answer. And continue to have the wrong answer until the JVM is restarted. Yes - this stinks for long running servers. I do not know if this is still an issue in JDK 1.4. Once way to get around this is to find a class which re-implements the DNS protocols. (ICK) -Tim Ron Day wrote: Do you know which class cache the negative response -Original Message- From: Ralph Einfeldt [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 2:07 AM To: Tomcat Users List Subject: RE: crontab problems Because the underlying classes sometimes cache a negative response, so you have to restart tomcat to enable a new lookup. (That's not specific to tomcat) -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 3:02 AM To: Tomcat Users List Subject: Re: crontab problems Regarding your problem: I don't understand why bouncing Tomcat would resolve a DNS problem. The UnknownHostException is a indication that something is wrong with DNS or the resolver library. - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: crontab problems
Good morning! When I deliberately use a non-existing hostname in order to force the lookup to fail, the exception is thrown in a method indirectly called by HttpURLConnection.connect(). This means that the lookup is not done in the URL class, which in turn means that moving the URL instantiation into the loop won't help anything. java.net.UnknownHostException: swww.hannesschmidt.de at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:153) at java.net.Socket.connect(Socket.java:426) at java.net.Socket.connect(Socket.java:376) at sun.net.NetworkClient.doConnect(NetworkClient.java:139) at sun.net.www.http.HttpClient.openServer(HttpClient.java:386) at sun.net.www.http.HttpClient.openServer(HttpClient.java:602) at sun.net.www.http.HttpClient.init(HttpClient.java:303) at sun.net.www.http.HttpClient.init(HttpClient.java:264) at sun.net.www.http.HttpClient.New(HttpClient.java:336) at sun.net.www.http.HttpClient.New(HttpClient.java:317) at sun.net.www.http.HttpClient.New(HttpClient.java:312) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.j ava:481) at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:4 72) at UrlWatchdog.main(UrlWatchdog.java:31) Where do you get your excepetion? My guts is telling me that the lookup result is cached by the operating system rather than a Java class. On the other hand, caching a negative result should never be done by anything. So the behaviour you illustrated is really strange. What platform does your webapp run on? - Original Message - From: Ron Day [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 9:27 AM Subject: RE: crontab problems Do you know which class cache the negative response -Original Message- From: Ralph Einfeldt [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 2:07 AM To: Tomcat Users List Subject: RE: crontab problems Because the underlying classes sometimes cache a negative response, so you have to restart tomcat to enable a new lookup. (That's not specific to tomcat) -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 3:02 AM To: Tomcat Users List Subject: Re: crontab problems Regarding your problem: I don't understand why bouncing Tomcat would resolve a DNS problem. The UnknownHostException is a indication that something is wrong with DNS or the resolver library. - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: crontab problems
It's the java implementation that does the caching, as java implements the lookup on it's own and doesn't use the operating system functions for that. (That doesn't mean that the operating system or the resolver lib is not caching, but that is independent of the java problem.) The lookup behaviour can be configured, have a look at: http://java.sun.com/j2se/1.4/docs/guide/net/properties.html#nct http://java.sun.com/j2se/1.4/docs/guide/net/properties.html#ncnt -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 1:01 PM To: Tomcat Users List Subject: Re: crontab problems Where do you get your excepetion? My guts is telling me that the lookup result is cached by the operating system rather than a Java class. On the other hand, caching a negative result should never be done by anything. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: crontab problems
Agreed. I put it there because some commercial monitoring apps I've worked with in the past got cranky if the response was malformed. Wget and other homegrown methods don't care. John -Original Message- From: Ralph Einfeldt [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 2:46 AM To: Tomcat Users List Subject: RE: crontab problems Just a side note: If the sole reason for this jsp is the automatic check then your example can be stripped down to: SUCCESS The rest is just to be a little bit more friendly to a browser. -Original Message- From: Turner, John [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 9:17 PM To: 'Tomcat Users List' Subject: RE: crontab problems html head titleAPP Monitor/title /head body % String myMonitor = SUCCESS; out.println(myMonitor); % /body /html - 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: crontab problems
Yikes, that really stinks. That's an incorrect implementation of the DNS protocol...the TTL should be honored at all times. John -Original Message- From: Tim Funk [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 6:57 AM To: Tomcat Users List Subject: Re: crontab problems It doesn't matter. Its a JDK issue. (IIRC) Successful (and unsucessful?) DNS lookups are cached forever during the life of the JVM. So if you start tomcat on Jan 1, 2003 and tomcat looks up foo.com that day - the lookup (across the network) is not done again. So if the address changes Jan 2 tomcat will have the wrong answer. And continue to have the wrong answer until the JVM is restarted. Yes - this stinks for long running servers. I do not know if this is still an issue in JDK 1.4. Once way to get around this is to find a class which re-implements the DNS protocols. (ICK) -Tim Ron Day wrote: Do you know which class cache the negative response -Original Message- From: Ralph Einfeldt [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 2:07 AM To: Tomcat Users List Subject: RE: crontab problems Because the underlying classes sometimes cache a negative response, so you have to restart tomcat to enable a new lookup. (That's not specific to tomcat) -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 3:02 AM To: Tomcat Users List Subject: Re: crontab problems Regarding your problem: I don't understand why bouncing Tomcat would resolve a DNS problem. The UnknownHostException is a indication that something is wrong with DNS or the resolver library. - 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] - 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: crontab problems
Better, but still not correct. That's a shame...it's not up to the client to determine how long a DNS response should be cached, its up to the zone file on the server doing the replying. Thanks for the pointers, this really bothers me for some reason, I want to investigate the rationale behind this, as it doesn't make any sense. I'm surprised Sun would do this. John -Original Message- From: Ralph Einfeldt [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 7:36 AM To: Tomcat Users List Subject: RE: crontab problems It's the java implementation that does the caching, as java implements the lookup on it's own and doesn't use the operating system functions for that. (That doesn't mean that the operating system or the resolver lib is not caching, but that is independent of the java problem.) The lookup behaviour can be configured, have a look at: http://java.sun.com/j2se/1.4/docs/guide/net/properties.html#nct http://java.sun.com/j2se/1.4/docs/guide/net/properties.html#ncnt -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 1:01 PM To: Tomcat Users List Subject: Re: crontab problems Where do you get your excepetion? My guts is telling me that the lookup result is cached by the operating system rather than a Java class. On the other hand, caching a negative result should never be done by anything. - 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: crontab problems
I second that. Only the setting for networkaddress.cache.negative.ttl makes sense as there is no ttl if you don't get a valid response. -Original Message- From: Turner, John [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 2:17 PM To: 'Tomcat Users List' Subject: RE: crontab problems That's a shame...it's not up to the client to determine how long a DNS response should be cached, its up to the zone file on the server doing the replying. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: crontab problems
Good Morning (bad weather here in Dallas) Thanks for the detailed look at this.. The exception is thrown by the getResponseCode() method of HttpURLConnection. Running Linux (2.4 kernel,redhat 7.2) and Sun jdk (1.4.0). R -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 6:01 AM To: Tomcat Users List Subject: Re: crontab problems Good morning! When I deliberately use a non-existing hostname in order to force the lookup to fail, the exception is thrown in a method indirectly called by HttpURLConnection.connect(). This means that the lookup is not done in the URL class, which in turn means that moving the URL instantiation into the loop won't help anything. java.net.UnknownHostException: swww.hannesschmidt.de at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:153) at java.net.Socket.connect(Socket.java:426) at java.net.Socket.connect(Socket.java:376) at sun.net.NetworkClient.doConnect(NetworkClient.java:139) at sun.net.www.http.HttpClient.openServer(HttpClient.java:386) at sun.net.www.http.HttpClient.openServer(HttpClient.java:602) at sun.net.www.http.HttpClient.init(HttpClient.java:303) at sun.net.www.http.HttpClient.init(HttpClient.java:264) at sun.net.www.http.HttpClient.New(HttpClient.java:336) at sun.net.www.http.HttpClient.New(HttpClient.java:317) at sun.net.www.http.HttpClient.New(HttpClient.java:312) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.j ava:481) at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:4 72) at UrlWatchdog.main(UrlWatchdog.java:31) Where do you get your excepetion? My guts is telling me that the lookup result is cached by the operating system rather than a Java class. On the other hand, caching a negative result should never be done by anything. So the behaviour you illustrated is really strange. What platform does your webapp run on? - Original Message - From: Ron Day [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 9:27 AM Subject: RE: crontab problems Do you know which class cache the negative response -Original Message- From: Ralph Einfeldt [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 2:07 AM To: Tomcat Users List Subject: RE: crontab problems Because the underlying classes sometimes cache a negative response, so you have to restart tomcat to enable a new lookup. (That's not specific to tomcat) -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 3:02 AM To: Tomcat Users List Subject: Re: crontab problems Regarding your problem: I don't understand why bouncing Tomcat would resolve a DNS problem. The UnknownHostException is a indication that something is wrong with DNS or the resolver library. - 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] - 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: crontab problems
I checked the properties file and I am using defaults, so cache on unsuccessful should be 10 secs. Mine is sure acting like it is Forever (until new jvm is started) ron -Original Message- From: Ralph Einfeldt [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 6:36 AM To: Tomcat Users List Subject: RE: crontab problems It's the java implementation that does the caching, as java implements the lookup on it's own and doesn't use the operating system functions for that. (That doesn't mean that the operating system or the resolver lib is not caching, but that is independent of the java problem.) The lookup behaviour can be configured, have a look at: http://java.sun.com/j2se/1.4/docs/guide/net/properties.html#nct http://java.sun.com/j2se/1.4/docs/guide/net/properties.html#ncnt -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 1:01 PM To: Tomcat Users List Subject: Re: crontab problems Where do you get your excepetion? My guts is telling me that the lookup result is cached by the operating system rather than a Java class. On the other hand, caching a negative result should never be done by anything. - 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]
JDK DNS cache (was Re: crontab problems)
On Wed, Feb 26, 2003 at 06:57:11AM -0500, Tim Funk wrote: Ron Day wrote: Do you know which class cache the negative response Its a JDK issue. (IIRC) Successful (and unsucessful?) DNS lookups are cached forever during the life of the JVM. The web application developer I'm supporting has instructed me to ask: Would this be true if the jsp or session didn't have application scope? If it isn't true for session scope then it's a design not JDK issue.. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: JDK DNS cache (was Re: crontab problems)
I do not understand this question at all ? jsp has page scope, session has session scope ??? -Original Message- From: Michael Micek [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 12:54 PM To: Tomcat Users List Subject: JDK DNS cache (was Re: crontab problems) On Wed, Feb 26, 2003 at 06:57:11AM -0500, Tim Funk wrote: Ron Day wrote: Do you know which class cache the negative response Its a JDK issue. (IIRC) Successful (and unsucessful?) DNS lookups are cached forever during the life of the JVM. The web application developer I'm supporting has instructed me to ask: Would this be true if the jsp or session didn't have application scope? If it isn't true for session scope then it's a design not JDK issue.. - 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: JDK DNS cache (was Re: crontab problems)
From: Michael Micek [EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 10:54 AM Subject: JDK DNS cache (was Re: crontab problems) The web application developer I'm supporting has instructed me to ask: Would this be true if the jsp or session didn't have application scope? If it isn't true for session scope then it's a design not JDK issue.. It's a JDK issue, so it's super duper global scope. It's an interesting nit. It's a shame that they buried this implementation deep into the JDK. Regards, Will Hartung ([EMAIL PROTECTED]) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: crontab problems
How bizarre. AFAIK, this is the same problem MS Windows has with it's DNS implementation. That's why IE never can re-connect after it gets a bad DNS lookup. Oscar On Wed, 26 Feb 2003, Ralph Einfeldt wrote: Because the underlying classes sometimes cache a negative response, so you have to restart tomcat to enable a new lookup. (That's not specific to tomcat) -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 3:02 AM To: Tomcat Users List Subject: Re: crontab problems Regarding your problem: I don't understand why bouncing Tomcat would resolve a DNS problem. The UnknownHostException is a indication that something is wrong with DNS or the resolver library. - 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]
[OT] DNS Fun (was Re: crontab problems)
Windows caches DNS too. But it can be flushed: c:\ ipconfig /flushdns -Tim Oscar Carrillo wrote: How bizarre. AFAIK, this is the same problem MS Windows has with it's DNS implementation. That's why IE never can re-connect after it gets a bad DNS lookup. Oscar On Wed, 26 Feb 2003, Ralph Einfeldt wrote: Because the underlying classes sometimes cache a negative response, so you have to restart tomcat to enable a new lookup. (That's not specific to tomcat) -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 3:02 AM To: Tomcat Users List Subject: Re: crontab problems Regarding your problem: I don't understand why bouncing Tomcat would resolve a DNS problem. The UnknownHostException is a indication that something is wrong with DNS or the resolver library. - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: crontab problems
You have to make shure that your script retstart_tomcat sets and exports all needed environment variables before calling ./startup.sh: JAVA_HOME=/usr/local/java/jdk1.3.1 CATALINA_HOME=path to tomcat installation CATALINA_BASE=path to tomcat instance or $CATALINA_HOME # JAVA_OPTS='-client -v' export JAVA_HOME CATALINA_HOME CATALINA_BASE JAVA_OPTS ./startup.sh -Original Message- From: Ayhan Peker [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 10:30 AM To: [EMAIL PROTECTED] Subject: crontab problems but the last two lines returns / The JAVA_HOME environment variable is not defined message.. / my retstart_tomcat scrip is #!/bin/sh cd /usr/local/tomcat/bin ./startup.sh - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: crontab problems
Right, you might also just put JAVA_HOME=... at the beginning of your crontab. I assume you have good reasons to use a Java program to watch Tomcat. Personally, I would have written a shell script. If you really want to use Java, you might want to use a different, more reliable approach to detect (un)availability of Tomcat, something like import java.net.*; URL url = new URL( http://localhost:8080/examples; ); URLConnection con = url.openConnection(); con.setUseCaches( false ); con.connect(); if( con.getContentLength() 0 ) { // restart tomcat } But I just wrote this out of my head ... - Original Message - From: Ralph Einfeldt [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 10:43 AM Subject: RE: crontab problems You have to make shure that your script retstart_tomcat sets and exports all needed environment variables before calling ./startup.sh: JAVA_HOME=/usr/local/java/jdk1.3.1 CATALINA_HOME=path to tomcat installation CATALINA_BASE=path to tomcat instance or $CATALINA_HOME # JAVA_OPTS='-client -v' export JAVA_HOME CATALINA_HOME CATALINA_BASE JAVA_OPTS ./startup.sh -Original Message- From: Ayhan Peker [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 10:30 AM To: [EMAIL PROTECTED] Subject: crontab problems but the last two lines returns / The JAVA_HOME environment variable is not defined message.. / my retstart_tomcat scrip is #!/bin/sh cd /usr/local/tomcat/bin ./startup.sh - 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: crontab problems
Agreed...using a Java program to watch Tomcat seems a little circular. Plus, I don't see any sort of delay or sleep in the poster's JAva code...it looks like it just keeps hammering at Tomcat, as the cron job is * * * * *. Creating all those Runtime objects over and over can't be helping performance any. A simple shell script using wget would be fine...sure, you can watch the output of ps -ef, but that doesn't tell you if Tomcat is accepting requests or not. There could be an entry for Tomcat in the process table, but Tomcat could be refusing requests. I just write a simple JSP page that outputs the contents of a variable, like ***SUCCESS*** or something like that, then use wget to grab that page every so often and check for the string in the output...if it's there, things should be OK (there are no guarantees). If it's not, you have a problem. This way, the JSP page is compiled and cached by Tomcat, it uses very little memory, and doesn't bog down the server. There are plenty of other alternatives much more robust than a simple shell script...you could use Netsaint/Nagios, Big Brother, and a whole bunch of others. John -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 6:29 AM To: Tomcat Users List Subject: Re: crontab problems Right, you might also just put JAVA_HOME=... at the beginning of your crontab. I assume you have good reasons to use a Java program to watch Tomcat. Personally, I would have written a shell script. If you really want to use Java, you might want to use a different, more reliable approach to detect (un)availability of Tomcat, something like import java.net.*; URL url = new URL( http://localhost:8080/examples; ); URLConnection con = url.openConnection(); con.setUseCaches( false ); con.connect(); if( con.getContentLength() 0 ) { // restart tomcat } But I just wrote this out of my head ... - Original Message - From: Ralph Einfeldt [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 10:43 AM Subject: RE: crontab problems You have to make shure that your script retstart_tomcat sets and exports all needed environment variables before calling ./startup.sh: JAVA_HOME=/usr/local/java/jdk1.3.1 CATALINA_HOME=path to tomcat installation CATALINA_BASE=path to tomcat instance or $CATALINA_HOME # JAVA_OPTS='-client -v' export JAVA_HOME CATALINA_HOME CATALINA_BASE JAVA_OPTS ./startup.sh -Original Message- From: Ayhan Peker [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 10:30 AM To: [EMAIL PROTECTED] Subject: crontab problems but the last two lines returns / The JAVA_HOME environment variable is not defined message.. / my retstart_tomcat scrip is #!/bin/sh cd /usr/local/tomcat/bin ./startup.sh - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: crontab problems
Yes, using wget is probably the second best solution. The best one is to find the reason why Tomcat crashes at all, since it generally is a stable and reliable product. Cron doesn't execute more than once a minute (at least mine doesn't) which still is quite often. 5 or 10 minutes would be ok too. But that's a matter of taste, really. - Original Message - From: Turner, John [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 3:00 PM Subject: RE: crontab problems Agreed...using a Java program to watch Tomcat seems a little circular. Plus, I don't see any sort of delay or sleep in the poster's JAva code...it looks like it just keeps hammering at Tomcat, as the cron job is * * * * *. Creating all those Runtime objects over and over can't be helping performance any. A simple shell script using wget would be fine...sure, you can watch the output of ps -ef, but that doesn't tell you if Tomcat is accepting requests or not. There could be an entry for Tomcat in the process table, but Tomcat could be refusing requests. I just write a simple JSP page that outputs the contents of a variable, like ***SUCCESS*** or something like that, then use wget to grab that page every so often and check for the string in the output...if it's there, things should be OK (there are no guarantees). If it's not, you have a problem. This way, the JSP page is compiled and cached by Tomcat, it uses very little memory, and doesn't bog down the server. There are plenty of other alternatives much more robust than a simple shell script...you could use Netsaint/Nagios, Big Brother, and a whole bunch of others. John -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 6:29 AM To: Tomcat Users List Subject: Re: crontab problems Right, you might also just put JAVA_HOME=... at the beginning of your crontab. I assume you have good reasons to use a Java program to watch Tomcat. Personally, I would have written a shell script. If you really want to use Java, you might want to use a different, more reliable approach to detect (un)availability of Tomcat, something like import java.net.*; URL url = new URL( http://localhost:8080/examples; ); URLConnection con = url.openConnection(); con.setUseCaches( false ); con.connect(); if( con.getContentLength() 0 ) { // restart tomcat } But I just wrote this out of my head ... - Original Message - From: Ralph Einfeldt [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 10:43 AM Subject: RE: crontab problems You have to make shure that your script retstart_tomcat sets and exports all needed environment variables before calling ./startup.sh: JAVA_HOME=/usr/local/java/jdk1.3.1 CATALINA_HOME=path to tomcat installation CATALINA_BASE=path to tomcat instance or $CATALINA_HOME # JAVA_OPTS='-client -v' export JAVA_HOME CATALINA_HOME CATALINA_BASE JAVA_OPTS ./startup.sh -Original Message- From: Ayhan Peker [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 10:30 AM To: [EMAIL PROTECTED] Subject: crontab problems but the last two lines returns / The JAVA_HOME environment variable is not defined message.. / my retstart_tomcat scrip is #!/bin/sh cd /usr/local/tomcat/bin ./startup.sh - 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] - 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: crontab problems
Yes, Tomcat is generally very stable. But: Trust, but verify. ;) John -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 9:23 AM To: Tomcat Users List Subject: Re: crontab problems Yes, using wget is probably the second best solution. The best one is to find the reason why Tomcat crashes at all, since it generally is a stable and reliable product. Cron doesn't execute more than once a minute (at least mine doesn't) which still is quite often. 5 or 10 minutes would be ok too. But that's a matter of taste, really. - Original Message - From: Turner, John [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 3:00 PM Subject: RE: crontab problems Agreed...using a Java program to watch Tomcat seems a little circular. Plus, I don't see any sort of delay or sleep in the poster's JAva code...it looks like it just keeps hammering at Tomcat, as the cron job is * * * * *. Creating all those Runtime objects over and over can't be helping performance any. A simple shell script using wget would be fine...sure, you can watch the output of ps -ef, but that doesn't tell you if Tomcat is accepting requests or not. There could be an entry for Tomcat in the process table, but Tomcat could be refusing requests. I just write a simple JSP page that outputs the contents of a variable, like ***SUCCESS*** or something like that, then use wget to grab that page every so often and check for the string in the output...if it's there, things should be OK (there are no guarantees). If it's not, you have a problem. This way, the JSP page is compiled and cached by Tomcat, it uses very little memory, and doesn't bog down the server. There are plenty of other alternatives much more robust than a simple shell script...you could use Netsaint/Nagios, Big Brother, and a whole bunch of others. John -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 6:29 AM To: Tomcat Users List Subject: Re: crontab problems Right, you might also just put JAVA_HOME=... at the beginning of your crontab. I assume you have good reasons to use a Java program to watch Tomcat. Personally, I would have written a shell script. If you really want to use Java, you might want to use a different, more reliable approach to detect (un)availability of Tomcat, something like import java.net.*; URL url = new URL( http://localhost:8080/examples; ); URLConnection con = url.openConnection(); con.setUseCaches( false ); con.connect(); if( con.getContentLength() 0 ) { // restart tomcat } But I just wrote this out of my head ... - Original Message - From: Ralph Einfeldt [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 10:43 AM Subject: RE: crontab problems You have to make shure that your script retstart_tomcat sets and exports all needed environment variables before calling ./startup.sh: JAVA_HOME=/usr/local/java/jdk1.3.1 CATALINA_HOME=path to tomcat installation CATALINA_BASE=path to tomcat instance or $CATALINA_HOME # JAVA_OPTS='-client -v' export JAVA_HOME CATALINA_HOME CATALINA_BASE JAVA_OPTS ./startup.sh -Original Message- From: Ayhan Peker [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 10:30 AM To: [EMAIL PROTECTED] Subject: crontab problems but the last two lines returns / The JAVA_HOME environment variable is not defined message.. / my retstart_tomcat scrip is #!/bin/sh cd /usr/local/tomcat/bin ./startup.sh - 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] - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: crontab problems
I have no problems with tomcat... But sometimes under heavy load jvm 1.4 crashes... see the links: Ok this is the bug: http://developer.java.sun.com/developer/bugParade/bugs/4779653.html unfortunately it is closed, affects 1.4.1 and will not apparently be fixed. It oiccurs in large apps under load.on Linux and Solaris ( and most likely Windows ) It is related to / a copy of the following bug which http://developer.java.sun.com/developer/bugParade/bugs/4724356.html what is the best suggestion? just trying to determine if tomcat is running.. if not i will restart it .. (jvm just crashed last saturday nightI did not know anything until the sunday evening).. At 09:29 AM 2/25/03 -0500, you wrote: Yes, Tomcat is generally very stable. But: Trust, but verify. ;) John -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 9:23 AM To: Tomcat Users List Subject: Re: crontab problems Yes, using wget is probably the second best solution. The best one is to find the reason why Tomcat crashes at all, since it generally is a stable and reliable product. Cron doesn't execute more than once a minute (at least mine doesn't) which still is quite often. 5 or 10 minutes would be ok too. But that's a matter of taste, really. - Original Message - From: Turner, John [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 3:00 PM Subject: RE: crontab problems Agreed...using a Java program to watch Tomcat seems a little circular. Plus, I don't see any sort of delay or sleep in the poster's JAva code...it looks like it just keeps hammering at Tomcat, as the cron job is * * * * *. Creating all those Runtime objects over and over can't be helping performance any. A simple shell script using wget would be fine...sure, you can watch the output of ps -ef, but that doesn't tell you if Tomcat is accepting requests or not. There could be an entry for Tomcat in the process table, but Tomcat could be refusing requests. I just write a simple JSP page that outputs the contents of a variable, like ***SUCCESS*** or something like that, then use wget to grab that page every so often and check for the string in the output...if it's there, things should be OK (there are no guarantees). If it's not, you have a problem. This way, the JSP page is compiled and cached by Tomcat, it uses very little memory, and doesn't bog down the server. There are plenty of other alternatives much more robust than a simple shell script...you could use Netsaint/Nagios, Big Brother, and a whole bunch of others. John -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 6:29 AM To: Tomcat Users List Subject: Re: crontab problems Right, you might also just put JAVA_HOME=... at the beginning of your crontab. I assume you have good reasons to use a Java program to watch Tomcat. Personally, I would have written a shell script. If you really want to use Java, you might want to use a different, more reliable approach to detect (un)availability of Tomcat, something like import java.net.*; URL url = new URL( http://localhost:8080/examples; ); URLConnection con = url.openConnection(); con.setUseCaches( false ); con.connect(); if( con.getContentLength() 0 ) { // restart tomcat } But I just wrote this out of my head ... - Original Message - From: Ralph Einfeldt [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 10:43 AM Subject: RE: crontab problems You have to make shure that your script retstart_tomcat sets and exports all needed environment variables before calling ./startup.sh: JAVA_HOME=/usr/local/java/jdk1.3.1 CATALINA_HOME=path to tomcat installation CATALINA_BASE=path to tomcat instance or $CATALINA_HOME # JAVA_OPTS='-client -v' export JAVA_HOME CATALINA_HOME CATALINA_BASE JAVA_OPTS ./startup.sh -Original Message- From: Ayhan Peker [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 10:30 AM To: [EMAIL PROTECTED] Subject: crontab problems but the last two lines returns / The JAVA_HOME environment variable is not defined message.. / my retstart_tomcat scrip is #!/bin/sh cd /usr/local/tomcat/bin ./startup.sh - 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: crontab problems
Well, if the JVM is crashed, how can a program or application written in Java help you manage Tomcat? That was the point. John -Original Message- From: Ayhan Peker [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 9:43 AM To: Tomcat Users List Subject: RE: crontab problems I have no problems with tomcat... But sometimes under heavy load jvm 1.4 crashes... see the links: Ok this is the bug: http://developer.java.sun.com/developer/bugParade/bugs/4779653.html unfortunately it is closed, affects 1.4.1 and will not apparently be fixed. It oiccurs in large apps under load.on Linux and Solaris ( and most likely Windows ) It is related to / a copy of the following bug which http://developer.java.sun.com/developer/bugParade/bugs/4724356.html what is the best suggestion? just trying to determine if tomcat is running.. if not i will restart it .. (jvm just crashed last saturday nightI did not know anything until the sunday evening).. At 09:29 AM 2/25/03 -0500, you wrote: Yes, Tomcat is generally very stable. But: Trust, but verify. ;) John -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 9:23 AM To: Tomcat Users List Subject: Re: crontab problems Yes, using wget is probably the second best solution. The best one is to find the reason why Tomcat crashes at all, since it generally is a stable and reliable product. Cron doesn't execute more than once a minute (at least mine doesn't) which still is quite often. 5 or 10 minutes would be ok too. But that's a matter of taste, really. - Original Message - From: Turner, John [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 3:00 PM Subject: RE: crontab problems Agreed...using a Java program to watch Tomcat seems a little circular. Plus, I don't see any sort of delay or sleep in the poster's JAva code...it looks like it just keeps hammering at Tomcat, as the cron job is * * * * *. Creating all those Runtime objects over and over can't be helping performance any. A simple shell script using wget would be fine...sure, you can watch the output of ps -ef, but that doesn't tell you if Tomcat is accepting requests or not. There could be an entry for Tomcat in the process table, but Tomcat could be refusing requests. I just write a simple JSP page that outputs the contents of a variable, like ***SUCCESS*** or something like that, then use wget to grab that page every so often and check for the string in the output...if it's there, things should be OK (there are no guarantees). If it's not, you have a problem. This way, the JSP page is compiled and cached by Tomcat, it uses very little memory, and doesn't bog down the server. There are plenty of other alternatives much more robust than a simple shell script...you could use Netsaint/Nagios, Big Brother, and a whole bunch of others. John -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 6:29 AM To: Tomcat Users List Subject: Re: crontab problems Right, you might also just put JAVA_HOME=... at the beginning of your crontab. I assume you have good reasons to use a Java program to watch Tomcat. Personally, I would have written a shell script. If you really want to use Java, you might want to use a different, more reliable approach to detect (un)availability of Tomcat, something like import java.net.*; URL url = new URL( http://localhost:8080/examples; ); URLConnection con = url.openConnection(); con.setUseCaches( false ); con.connect(); if( con.getContentLength() 0 ) { // restart tomcat } But I just wrote this out of my head ... - Original Message - From: Ralph Einfeldt [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 10:43 AM Subject: RE: crontab problems You have to make shure that your script retstart_tomcat sets and exports all needed environment variables before calling ./startup.sh: JAVA_HOME=/usr/local/java/jdk1.3.1 CATALINA_HOME=path to tomcat installation CATALINA_BASE=path to tomcat instance or $CATALINA_HOME # JAVA_OPTS='-client -v' export JAVA_HOME CATALINA_HOME CATALINA_BASE JAVA_OPTS ./startup.sh -Original Message- From: Ayhan Peker [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 10:30 AM To: [EMAIL PROTECTED] Subject: crontab problems but the last two lines returns
RE: crontab problems
Am I right to think that if jvm crashes...Once writing to core file is finished, jvm can be restarted..(that is what we have been doing--jvm crashes, of course tomcat too) AND crontab say 5 min later..launches this java programme, which will restart tomcat..this is not a thread..just a java programme...that is the reason I am trying to launch it from crontab... When jvm crashes it writes its report..and goes away from the memory..You can still launch a java programme after this crash (like launching tomcat again after the crash).. .. --tomcat running --jvm crashes.. --crontab launches my watcher (written in java) --my application checks if tomcat is running...and restarts is necessary.. --if my programme is running at the time of crash..my programme crashes too...but 5 min later my programme is activated by crontab again.. Am I missing something here? Take care.. Ayhan At 10:12 AM 2/25/03 -0500, you wrote: Well, if the JVM is crashed, how can a program or application written in Java help you manage Tomcat? That was the point. John -Original Message- From: Ayhan Peker [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 9:43 AM To: Tomcat Users List Subject: RE: crontab problems I have no problems with tomcat... But sometimes under heavy load jvm 1.4 crashes... see the links: Ok this is the bug: http://developer.java.sun.com/developer/bugParade/bugs/4779653.html unfortunately it is closed, affects 1.4.1 and will not apparently be fixed. It oiccurs in large apps under load.on Linux and Solaris ( and most likely Windows ) It is related to / a copy of the following bug which http://developer.java.sun.com/developer/bugParade/bugs/4724356.html what is the best suggestion? just trying to determine if tomcat is running.. if not i will restart it .. (jvm just crashed last saturday nightI did not know anything until the sunday evening).. At 09:29 AM 2/25/03 -0500, you wrote: Yes, Tomcat is generally very stable. But: Trust, but verify. ;) John -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 9:23 AM To: Tomcat Users List Subject: Re: crontab problems Yes, using wget is probably the second best solution. The best one is to find the reason why Tomcat crashes at all, since it generally is a stable and reliable product. Cron doesn't execute more than once a minute (at least mine doesn't) which still is quite often. 5 or 10 minutes would be ok too. But that's a matter of taste, really. - Original Message - From: Turner, John [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 3:00 PM Subject: RE: crontab problems Agreed...using a Java program to watch Tomcat seems a little circular. Plus, I don't see any sort of delay or sleep in the poster's JAva code...it looks like it just keeps hammering at Tomcat, as the cron job is * * * * *. Creating all those Runtime objects over and over can't be helping performance any. A simple shell script using wget would be fine...sure, you can watch the output of ps -ef, but that doesn't tell you if Tomcat is accepting requests or not. There could be an entry for Tomcat in the process table, but Tomcat could be refusing requests. I just write a simple JSP page that outputs the contents of a variable, like ***SUCCESS*** or something like that, then use wget to grab that page every so often and check for the string in the output...if it's there, things should be OK (there are no guarantees). If it's not, you have a problem. This way, the JSP page is compiled and cached by Tomcat, it uses very little memory, and doesn't bog down the server. There are plenty of other alternatives much more robust than a simple shell script...you could use Netsaint/Nagios, Big Brother, and a whole bunch of others. John -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 6:29 AM To: Tomcat Users List Subject: Re: crontab problems Right, you might also just put JAVA_HOME=... at the beginning of your crontab. I assume you have good reasons to use a Java program to watch Tomcat. Personally, I would have written a shell script. If you really want to use Java, you might want to use a different, more reliable approach to detect (un)availability of Tomcat, something like import java.net.*; URL url = new URL( http://localhost:8080/examples; ); URLConnection con = url.openConnection(); con.setUseCaches( false ); con.connect(); if( con.getContentLength() 0 ) { // restart tomcat } But I just wrote this out
RE: crontab problems
No, I guess that would work. It just seems to be needlessly complicated and resource intensive. You normally don't consider a program crashing as normal behavior. The point of a monitoring application is for it to NEVER crash, and continually check some other application. Think about itcron launches your program to see if Tomcat is started. Well, Tomcat isn't. That's a given, considering that the JVM just crashed. A circle. See? Your application is Tomcat, not the JVM. My point is that if you can successfully retrieve output from Tomcat, generated by either a servlet or a JSP, all is well. Tomcat is happy, the JVM is happy, all is well. If you can't, something is wrong, and you have to restart anyway. Seems simpler to me, but I guess there will always be different ways to do things. Heck, if this happens alot, you'd probably just be better off profiling your application, finding out WHY it happens (maybe something could be rewritten or re-architected to avoid triggering those bugs), and possibly just determining that a restart every other day or something is sufficient. In that case, just set up a cron job to run at 4 AM your time 3 times a week that restarts Tomcat, without even bothering to check status. The typcial goal for a monitoring application is to alert you that something is wrong...not to treat something that goes wrong as a normal event. John -Original Message- From: Ayhan Peker [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 12:06 PM To: Tomcat Users List Subject: RE: crontab problems Am I right to think that if jvm crashes...Once writing to core file is finished, jvm can be restarted..(that is what we have been doing--jvm crashes, of course tomcat too) AND crontab say 5 min later..launches this java programme, which will restart tomcat..this is not a thread..just a java programme...that is the reason I am trying to launch it from crontab... When jvm crashes it writes its report..and goes away from the memory..You can still launch a java programme after this crash (like launching tomcat again after the crash).. .. --tomcat running --jvm crashes.. --crontab launches my watcher (written in java) --my application checks if tomcat is running...and restarts is necessary.. --if my programme is running at the time of crash..my programme crashes too...but 5 min later my programme is activated by crontab again.. Am I missing something here? Take care.. Ayhan At 10:12 AM 2/25/03 -0500, you wrote: Well, if the JVM is crashed, how can a program or application written in Java help you manage Tomcat? That was the point. John -Original Message- From: Ayhan Peker [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 9:43 AM To: Tomcat Users List Subject: RE: crontab problems I have no problems with tomcat... But sometimes under heavy load jvm 1.4 crashes... see the links: Ok this is the bug: http://developer.java.sun.com/developer/bugParade/bugs/4779653.html unfortunately it is closed, affects 1.4.1 and will not apparently be fixed. It oiccurs in large apps under load.on Linux and Solaris ( and most likely Windows ) It is related to / a copy of the following bug which http://developer.java.sun.com/developer/bugParade/bugs/4724356.html what is the best suggestion? just trying to determine if tomcat is running.. if not i will restart it .. (jvm just crashed last saturday nightI did not know anything until the sunday evening).. At 09:29 AM 2/25/03 -0500, you wrote: Yes, Tomcat is generally very stable. But: Trust, but verify. ;) John -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 9:23 AM To: Tomcat Users List Subject: Re: crontab problems Yes, using wget is probably the second best solution. The best one is to find the reason why Tomcat crashes at all, since it generally is a stable and reliable product. Cron doesn't execute more than once a minute (at least mine doesn't) which still is quite often. 5 or 10 minutes would be ok too. But that's a matter of taste, really. - Original Message - From: Turner, John [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 3:00 PM Subject: RE: crontab problems Agreed...using a Java program to watch Tomcat seems a little circular. Plus, I don't see any sort of delay or sleep in the poster's JAva code...it looks like it just keeps hammering at Tomcat, as the cron job is * * * * *. Creating all those Runtime objects over and over can't be helping performance any. A simple shell script using wget would be fine...sure
Re: crontab problems
There's not a single JVM per machine. Even if the JVM running Tomcat inside it is crashed, it's prefectly ok to start another one testing for the existence or availability of Tomcat and/or a webapp. That will work. It's just that this solution is a little awkward. Let me summarize the alternatives: 1) A cronjob shell script using wget as John suggested. 2) A Java Thread running in a different UNIX process, i.e. JVM which repeatedly tests the webapp's availability like I suggested in my first posting. That thread runs in a loop and is NOT started regularly by cron but once when the system starts (aka. init script). Aside from that, your primary goal should be to get rid of the crash. Ever tried downgrading to a 1.3 JDK? - Original Message - From: Turner, John [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 6:16 PM Subject: RE: crontab problems No, I guess that would work. It just seems to be needlessly complicated and resource intensive. You normally don't consider a program crashing as normal behavior. The point of a monitoring application is for it to NEVER crash, and continually check some other application. Think about itcron launches your program to see if Tomcat is started. Well, Tomcat isn't. That's a given, considering that the JVM just crashed. A circle. See? Your application is Tomcat, not the JVM. My point is that if you can successfully retrieve output from Tomcat, generated by either a servlet or a JSP, all is well. Tomcat is happy, the JVM is happy, all is well. If you can't, something is wrong, and you have to restart anyway. Seems simpler to me, but I guess there will always be different ways to do things. Heck, if this happens alot, you'd probably just be better off profiling your application, finding out WHY it happens (maybe something could be rewritten or re-architected to avoid triggering those bugs), and possibly just determining that a restart every other day or something is sufficient. In that case, just set up a cron job to run at 4 AM your time 3 times a week that restarts Tomcat, without even bothering to check status. The typcial goal for a monitoring application is to alert you that something is wrong...not to treat something that goes wrong as a normal event. John -Original Message- From: Ayhan Peker [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 12:06 PM To: Tomcat Users List Subject: RE: crontab problems Am I right to think that if jvm crashes...Once writing to core file is finished, jvm can be restarted..(that is what we have been doing--jvm crashes, of course tomcat too) AND crontab say 5 min later..launches this java programme, which will restart tomcat..this is not a thread..just a java programme...that is the reason I am trying to launch it from crontab... When jvm crashes it writes its report..and goes away from the memory..You can still launch a java programme after this crash (like launching tomcat again after the crash).. .. --tomcat running --jvm crashes.. --crontab launches my watcher (written in java) --my application checks if tomcat is running...and restarts is necessary.. --if my programme is running at the time of crash..my programme crashes too...but 5 min later my programme is activated by crontab again.. Am I missing something here? Take care.. Ayhan At 10:12 AM 2/25/03 -0500, you wrote: Well, if the JVM is crashed, how can a program or application written in Java help you manage Tomcat? That was the point. John -Original Message- From: Ayhan Peker [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 9:43 AM To: Tomcat Users List Subject: RE: crontab problems I have no problems with tomcat... But sometimes under heavy load jvm 1.4 crashes... see the links: Ok this is the bug: http://developer.java.sun.com/developer/bugParade/bugs/4779653.html unfortunately it is closed, affects 1.4.1 and will not apparently be fixed. It oiccurs in large apps under load.on Linux and Solaris ( and most likely Windows ) It is related to / a copy of the following bug which http://developer.java.sun.com/developer/bugParade/bugs/4724356.html what is the best suggestion? just trying to determine if tomcat is running.. if not i will restart it .. (jvm just crashed last saturday nightI did not know anything until the sunday evening).. At 09:29 AM 2/25/03 -0500, you wrote: Yes, Tomcat is generally very stable. But: Trust, but verify. ;) John -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 9:23 AM To: Tomcat Users List Subject: Re: crontab problems Yes, using wget is probably
RE: crontab problems
Would you expand on option 2. Why is this a thread rather than a java app that is started on system startup ? Ron -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 12:50 PM To: Tomcat Users List Subject: Re: crontab problems There's not a single JVM per machine. Even if the JVM running Tomcat inside it is crashed, it's prefectly ok to start another one testing for the existence or availability of Tomcat and/or a webapp. That will work. It's just that this solution is a little awkward. Let me summarize the alternatives: 1) A cronjob shell script using wget as John suggested. 2) A Java Thread running in a different UNIX process, i.e. JVM which repeatedly tests the webapp's availability like I suggested in my first posting. That thread runs in a loop and is NOT started regularly by cron but once when the system starts (aka. init script). Aside from that, your primary goal should be to get rid of the crash. Ever tried downgrading to a 1.3 JDK? - Original Message - From: Turner, John [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 6:16 PM Subject: RE: crontab problems No, I guess that would work. It just seems to be needlessly complicated and resource intensive. You normally don't consider a program crashing as normal behavior. The point of a monitoring application is for it to NEVER crash, and continually check some other application. Think about itcron launches your program to see if Tomcat is started. Well, Tomcat isn't. That's a given, considering that the JVM just crashed. A circle. See? Your application is Tomcat, not the JVM. My point is that if you can successfully retrieve output from Tomcat, generated by either a servlet or a JSP, all is well. Tomcat is happy, the JVM is happy, all is well. If you can't, something is wrong, and you have to restart anyway. Seems simpler to me, but I guess there will always be different ways to do things. Heck, if this happens alot, you'd probably just be better off profiling your application, finding out WHY it happens (maybe something could be rewritten or re-architected to avoid triggering those bugs), and possibly just determining that a restart every other day or something is sufficient. In that case, just set up a cron job to run at 4 AM your time 3 times a week that restarts Tomcat, without even bothering to check status. The typcial goal for a monitoring application is to alert you that something is wrong...not to treat something that goes wrong as a normal event. John -Original Message- From: Ayhan Peker [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 12:06 PM To: Tomcat Users List Subject: RE: crontab problems Am I right to think that if jvm crashes...Once writing to core file is finished, jvm can be restarted..(that is what we have been doing--jvm crashes, of course tomcat too) AND crontab say 5 min later..launches this java programme, which will restart tomcat..this is not a thread..just a java programme...that is the reason I am trying to launch it from crontab... When jvm crashes it writes its report..and goes away from the memory..You can still launch a java programme after this crash (like launching tomcat again after the crash).. .. --tomcat running --jvm crashes.. --crontab launches my watcher (written in java) --my application checks if tomcat is running...and restarts is necessary.. --if my programme is running at the time of crash..my programme crashes too...but 5 min later my programme is activated by crontab again.. Am I missing something here? Take care.. Ayhan At 10:12 AM 2/25/03 -0500, you wrote: Well, if the JVM is crashed, how can a program or application written in Java help you manage Tomcat? That was the point. John -Original Message- From: Ayhan Peker [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 9:43 AM To: Tomcat Users List Subject: RE: crontab problems I have no problems with tomcat... But sometimes under heavy load jvm 1.4 crashes... see the links: Ok this is the bug: http://developer.java.sun.com/developer/bugParade/bugs/4779653.html unfortunately it is closed, affects 1.4.1 and will not apparently be fixed. It oiccurs in large apps under load.on Linux and Solaris ( and most likely Windows ) It is related to / a copy of the following bug which http://developer.java.sun.com/developer/bugParade/bugs/4724356.html what is the best suggestion? just trying to determine if tomcat is running.. if not i will restart it .. (jvm just crashed last saturday nightI did not know anything until the sunday evening).. At 09:29 AM 2/25/03 -0500, you wrote: Yes, Tomcat is generally very stable
Re: crontab problems
- Original Message - From: Ayhan Peker [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 1:29 AM Subject: crontab problems Hi everybody , I have a problem..I am trying to write an application , which will run from cronatb on linux... My application runs without a problem when i try it from the command line..BUT NOT FROM CRONTAB... The challenge is: if jvm crashes i want to restart tomcat If you simply want to restart Tomcat every time it crashes, then you might want to look at http://cr.yp.to/daemontools.html This is a service management framework that does exactly that (among other things) on UNIX boxes. Dredge the archives, as I've posted the instructions for doing this before. Regards, Will Hartung ([EMAIL PROTECTED]) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: crontab problems
Would you expand on option 2. A Java thread is a sequence of execution of Java bytecode on a JVM. Obviously, there can be multiple threads per JVM. A JVM is a native operating system process interpreting (sometimes compiling on the fly) the bytecode of at least one Java thread. Since there can be multiple processes per machine, there can be multiple JVMs per machine. Ideally, these JVMs are completely separated, at least their address space (memory) is. Sometimes an operating system provides native threads. These are threads of execution of machine instructions on the real machine. There can be multiple native threads per native process. Thus, it is possible to map native threads to Java threads: the JVM process contains multiple real threads, each executing one thread of bytecode. I don't think the Sun's JVM does that, but I'm not sure. You just have to make sure that the monitoring thread is not executed inside the same JVM that runs the application to be monitored. Why is this a thread rather than a java app that is started on system startup ? Option 2 IS a Java application. It consists of a single Java thread (the one running the main() method). But it is started only once and it repeats internally - note the infinite while() loop. A cronjob is a Unix process that is repeated externally. I use the term externally, because it is started all over again periodically by an 'higher power', i.e. CRON. Cronjobs don't usually contain infinite loops. Whether to use internal or external repetition depends on the situation: external repetetion is more time consuming but it releases all resources, e.g. memory after each iteration. Internal repetition is fast but it blocks resources forever, basically. So if something needs to be executed once every minute I would strongly suggest internal repetition. If it needs to run once a day only, I would suggest external repetition. import java.net.*; public class Main { public void main( String[] args ) { while(true) { URL url = new URL( http://localhost:8080/examples; ); URLConnection con = url.openConnection(); con.setUseCaches( false ); con.connect(); if( con.getContentLength() 0 ) { // restart tomcat } // cleanup Thread.getCurrentThread().sleep( 100 ); // or so, I'm not sure } } } - Original Message - From: Ron Day [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 8:00 PM Subject: RE: crontab problems Ron -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 12:50 PM To: Tomcat Users List Subject: Re: crontab problems There's not a single JVM per machine. Even if the JVM running Tomcat inside it is crashed, it's prefectly ok to start another one testing for the existence or availability of Tomcat and/or a webapp. That will work. It's just that this solution is a little awkward. Let me summarize the alternatives: 1) A cronjob shell script using wget as John suggested. 2) A Java Thread running in a different UNIX process, i.e. JVM which repeatedly tests the webapp's availability like I suggested in my first posting. That thread runs in a loop and is NOT started regularly by cron but once when the system starts (aka. init script). Aside from that, your primary goal should be to get rid of the crash. Ever tried downgrading to a 1.3 JDK? - Original Message - From: Turner, John [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 6:16 PM Subject: RE: crontab problems No, I guess that would work. It just seems to be needlessly complicated and resource intensive. You normally don't consider a program crashing as normal behavior. The point of a monitoring application is for it to NEVER crash, and continually check some other application. Think about itcron launches your program to see if Tomcat is started. Well, Tomcat isn't. That's a given, considering that the JVM just crashed. A circle. See? Your application is Tomcat, not the JVM. My point is that if you can successfully retrieve output from Tomcat, generated by either a servlet or a JSP, all is well. Tomcat is happy, the JVM is happy, all is well. If you can't, something is wrong, and you have to restart anyway. Seems simpler to me, but I guess there will always be different ways to do things. Heck, if this happens alot, you'd probably just be better off profiling your application, finding out WHY it happens (maybe something could be rewritten or re-architected to avoid triggering those bugs), and possibly just determining that a restart every other day or something is sufficient. In that case, just set up a cron job to run at 4 AM your time 3 times a week that restarts Tomcat, without even bothering to check status. The typcial
RE: crontab problems
Sorry to be pedantic, but that example doesn't do anything at all. I think first that you would want ContentLength() to be less than or equal to zero, and even then it doesn't test the availability of your app, because a 404 or 500 Internal Server error will have a content length greater than zero and be a valid answer to the request as far as the monitor is concerned. If your app uses a database, and you want to monitor that your app is up, you must create a JSP page that queries a database for a known value, and either returns that value as the response (preferred) or determines if the value is correct and instead returns the value of a constant as the response, such as a string like SUCCESS or OK or APP UP or something else. The monitor must then check for that value. Anything else is not a test of your web app, and even then it is only a partial test, since a true test would be to emulate a user session exactly with some sort of robot script. If your web app does not use a database or other remote data source, you can get away with a servlet or JSP that does something like: html head titleAPP Monitor/title /head body % String myMonitor = SUCCESS; out.println(myMonitor); % /body /html Then your monitor needs to determine if the contents of the response contain SUCCESS or not. If yes, everything is OK. If not, something is wrong. John -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 3:06 PM To: Tomcat Users List Subject: Re: crontab problems Would you expand on option 2. A Java thread is a sequence of execution of Java bytecode on a JVM. Obviously, there can be multiple threads per JVM. A JVM is a native operating system process interpreting (sometimes compiling on the fly) the bytecode of at least one Java thread. Since there can be multiple processes per machine, there can be multiple JVMs per machine. Ideally, these JVMs are completely separated, at least their address space (memory) is. Sometimes an operating system provides native threads. These are threads of execution of machine instructions on the real machine. There can be multiple native threads per native process. Thus, it is possible to map native threads to Java threads: the JVM process contains multiple real threads, each executing one thread of bytecode. I don't think the Sun's JVM does that, but I'm not sure. You just have to make sure that the monitoring thread is not executed inside the same JVM that runs the application to be monitored. Why is this a thread rather than a java app that is started on system startup ? Option 2 IS a Java application. It consists of a single Java thread (the one running the main() method). But it is started only once and it repeats internally - note the infinite while() loop. A cronjob is a Unix process that is repeated externally. I use the term externally, because it is started all over again periodically by an 'higher power', i.e. CRON. Cronjobs don't usually contain infinite loops. Whether to use internal or external repetition depends on the situation: external repetetion is more time consuming but it releases all resources, e.g. memory after each iteration. Internal repetition is fast but it blocks resources forever, basically. So if something needs to be executed once every minute I would strongly suggest internal repetition. If it needs to run once a day only, I would suggest external repetition. import java.net.*; public class Main { public void main( String[] args ) { while(true) { URL url = new URL( http://localhost:8080/examples; ); URLConnection con = url.openConnection(); con.setUseCaches( false ); con.connect(); if( con.getContentLength() 0 ) { // restart tomcat } // cleanup Thread.getCurrentThread().sleep( 100 ); // or so, I'm not sure } } } - Original Message - From: Ron Day [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 8:00 PM Subject: RE: crontab problems Ron -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 12:50 PM To: Tomcat Users List Subject: Re: crontab problems There's not a single JVM per machine. Even if the JVM running Tomcat inside it is crashed, it's prefectly ok to start another one testing for the existence or availability of Tomcat and/or a webapp. That will work. It's just that this solution is a little awkward. Let me summarize the alternatives: 1) A cronjob shell script using wget as John suggested. 2) A Java Thread running in a different UNIX process, i.e. JVM which repeatedly tests the webapp's availability like I suggested in my first posting. That thread runs in a loop and is NOT started
RE: crontab problems
Good points. Where would you suggest putting this script? On the machine itself, or on another machine that has to get to it through the internet? I think this is a great idea for many widely deployed application. Oscar On Tue, 25 Feb 2003, Turner, John wrote: Sorry to be pedantic, but that example doesn't do anything at all. I think first that you would want ContentLength() to be less than or equal to zero, and even then it doesn't test the availability of your app, because a 404 or 500 Internal Server error will have a content length greater than zero and be a valid answer to the request as far as the monitor is concerned. If your app uses a database, and you want to monitor that your app is up, you must create a JSP page that queries a database for a known value, and either returns that value as the response (preferred) or determines if the value is correct and instead returns the value of a constant as the response, such as a string like SUCCESS or OK or APP UP or something else. The monitor must then check for that value. Anything else is not a test of your web app, and even then it is only a partial test, since a true test would be to emulate a user session exactly with some sort of robot script. If your web app does not use a database or other remote data source, you can get away with a servlet or JSP that does something like: html head titleAPP Monitor/title /head body % String myMonitor = SUCCESS; out.println(myMonitor); % /body /html Then your monitor needs to determine if the contents of the response contain SUCCESS or not. If yes, everything is OK. If not, something is wrong. John -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 3:06 PM To: Tomcat Users List Subject: Re: crontab problems Would you expand on option 2. A Java thread is a sequence of execution of Java bytecode on a JVM. Obviously, there can be multiple threads per JVM. A JVM is a native operating system process interpreting (sometimes compiling on the fly) the bytecode of at least one Java thread. Since there can be multiple processes per machine, there can be multiple JVMs per machine. Ideally, these JVMs are completely separated, at least their address space (memory) is. Sometimes an operating system provides native threads. These are threads of execution of machine instructions on the real machine. There can be multiple native threads per native process. Thus, it is possible to map native threads to Java threads: the JVM process contains multiple real threads, each executing one thread of bytecode. I don't think the Sun's JVM does that, but I'm not sure. You just have to make sure that the monitoring thread is not executed inside the same JVM that runs the application to be monitored. Why is this a thread rather than a java app that is started on system startup ? Option 2 IS a Java application. It consists of a single Java thread (the one running the main() method). But it is started only once and it repeats internally - note the infinite while() loop. A cronjob is a Unix process that is repeated externally. I use the term externally, because it is started all over again periodically by an 'higher power', i.e. CRON. Cronjobs don't usually contain infinite loops. Whether to use internal or external repetition depends on the situation: external repetetion is more time consuming but it releases all resources, e.g. memory after each iteration. Internal repetition is fast but it blocks resources forever, basically. So if something needs to be executed once every minute I would strongly suggest internal repetition. If it needs to run once a day only, I would suggest external repetition. import java.net.*; public class Main { public void main( String[] args ) { while(true) { URL url = new URL( http://localhost:8080/examples; ); URLConnection con = url.openConnection(); con.setUseCaches( false ); con.connect(); if( con.getContentLength() 0 ) { // restart tomcat } // cleanup Thread.getCurrentThread().sleep( 100 ); // or so, I'm not sure } } } - Original Message - From: Ron Day [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 8:00 PM Subject: RE: crontab problems Ron -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 12:50 PM To: Tomcat Users List Subject: Re: crontab problems There's not a single JVM per machine. Even if the JVM running Tomcat inside it is crashed, it's prefectly ok to start another one testing for the existence or availability
RE: crontab problems
Well, to be paranoid, it would have to be on a remote machine. If it wasn't, a network outage would take your app down, but your monitor would keep right on merrily testing your web app. If you can't use a remote machine, then you have to get creative with your JSP, and have it make a connection to the world and look for an external website (Yahoo, Google, whatever). A dirty test would be a ping, but pings are unreliable because of firewalls and other restrictions that might be in the way. Even then its only a test of OUTBOUND network access, not INBOUND, which is what the users do. I have one machine that is my monitor. It's also my MRTG host, my web log processor, and other batch-type processing server. Any PC capable of running Linux will do. It monitors all my servers, and I have it setup so that it creates a single status page that I can reach via HTTP, in addition to sending out alerts. Truly paranoid is a separate monitoring server on a network completely distinct from your application's network (like across the country), and with a dial-out POTS line and a modem to use for sending pager alerts. You can also contract with third-party monitoring services, but my experience with those is that they irritate server admins like myself pretty quickly, as they always tend to err on the side of alert, which means the slightest delay (like net congestion out of your control) in getting a response triggers an alert, which in turn means lots of flapping, where the admin gets up/down alerts repeatedly, even though there is nothing wrong. John -Original Message- From: Oscar Carrillo [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 4:00 AM To: Tomcat Users List Subject: RE: crontab problems Good points. Where would you suggest putting this script? On the machine itself, or on another machine that has to get to it through the internet? I think this is a great idea for many widely deployed application. Oscar On Tue, 25 Feb 2003, Turner, John wrote: Sorry to be pedantic, but that example doesn't do anything at all. I think first that you would want ContentLength() to be less than or equal to zero, and even then it doesn't test the availability of your app, because a 404 or 500 Internal Server error will have a content length greater than zero and be a valid answer to the request as far as the monitor is concerned. If your app uses a database, and you want to monitor that your app is up, you must create a JSP page that queries a database for a known value, and either returns that value as the response (preferred) or determines if the value is correct and instead returns the value of a constant as the response, such as a string like SUCCESS or OK or APP UP or something else. The monitor must then check for that value. Anything else is not a test of your web app, and even then it is only a partial test, since a true test would be to emulate a user session exactly with some sort of robot script. If your web app does not use a database or other remote data source, you can get away with a servlet or JSP that does something like: html head titleAPP Monitor/title /head body % String myMonitor = SUCCESS; out.println(myMonitor); % /body /html Then your monitor needs to determine if the contents of the response contain SUCCESS or not. If yes, everything is OK. If not, something is wrong. John -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 3:06 PM To: Tomcat Users List Subject: Re: crontab problems Would you expand on option 2. A Java thread is a sequence of execution of Java bytecode on a JVM. Obviously, there can be multiple threads per JVM. A JVM is a native operating system process interpreting (sometimes compiling on the fly) the bytecode of at least one Java thread. Since there can be multiple processes per machine, there can be multiple JVMs per machine. Ideally, these JVMs are completely separated, at least their address space (memory) is. Sometimes an operating system provides native threads. These are threads of execution of machine instructions on the real machine. There can be multiple native threads per native process. Thus, it is possible to map native threads to Java threads: the JVM process contains multiple real threads, each executing one thread of bytecode. I don't think the Sun's JVM does that, but I'm not sure. You just have to make sure that the monitoring thread is not executed inside the same JVM that runs the application to be monitored. Why is this a thread rather than a java app that is started on system startup ? Option 2 IS a Java application. It consists of a single Java thread (the one running the main() method
RE: crontab problems
Thanks , two questions... 1) Does the URL creation have to be inside the while loop ? 2) Shouldn't the if statement test be: (! con.getContentLength() 0) rather than (con.getContentLength() 0) Ron -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 2:06 PM To: Tomcat Users List Subject: Re: crontab problems Would you expand on option 2. A Java thread is a sequence of execution of Java bytecode on a JVM. Obviously, there can be multiple threads per JVM. A JVM is a native operating system process interpreting (sometimes compiling on the fly) the bytecode of at least one Java thread. Since there can be multiple processes per machine, there can be multiple JVMs per machine. Ideally, these JVMs are completely separated, at least their address space (memory) is. Sometimes an operating system provides native threads. These are threads of execution of machine instructions on the real machine. There can be multiple native threads per native process. Thus, it is possible to map native threads to Java threads: the JVM process contains multiple real threads, each executing one thread of bytecode. I don't think the Sun's JVM does that, but I'm not sure. You just have to make sure that the monitoring thread is not executed inside the same JVM that runs the application to be monitored. Why is this a thread rather than a java app that is started on system startup ? Option 2 IS a Java application. It consists of a single Java thread (the one running the main() method). But it is started only once and it repeats internally - note the infinite while() loop. A cronjob is a Unix process that is repeated externally. I use the term externally, because it is started all over again periodically by an 'higher power', i.e. CRON. Cronjobs don't usually contain infinite loops. Whether to use internal or external repetition depends on the situation: external repetetion is more time consuming but it releases all resources, e.g. memory after each iteration. Internal repetition is fast but it blocks resources forever, basically. So if something needs to be executed once every minute I would strongly suggest internal repetition. If it needs to run once a day only, I would suggest external repetition. import java.net.*; public class Main { public void main( String[] args ) { while(true) { URL url = new URL( http://localhost:8080/examples; ); URLConnection con = url.openConnection(); con.setUseCaches( false ); con.connect(); if( con.getContentLength() 0 ) { // restart tomcat } // cleanup Thread.getCurrentThread().sleep( 100 ); // or so, I'm not sure } } } - Original Message - From: Ron Day [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 8:00 PM Subject: RE: crontab problems Ron -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 12:50 PM To: Tomcat Users List Subject: Re: crontab problems There's not a single JVM per machine. Even if the JVM running Tomcat inside it is crashed, it's prefectly ok to start another one testing for the existence or availability of Tomcat and/or a webapp. That will work. It's just that this solution is a little awkward. Let me summarize the alternatives: 1) A cronjob shell script using wget as John suggested. 2) A Java Thread running in a different UNIX process, i.e. JVM which repeatedly tests the webapp's availability like I suggested in my first posting. That thread runs in a loop and is NOT started regularly by cron but once when the system starts (aka. init script). Aside from that, your primary goal should be to get rid of the crash. Ever tried downgrading to a 1.3 JDK? - Original Message - From: Turner, John [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 6:16 PM Subject: RE: crontab problems No, I guess that would work. It just seems to be needlessly complicated and resource intensive. You normally don't consider a program crashing as normal behavior. The point of a monitoring application is for it to NEVER crash, and continually check some other application. Think about itcron launches your program to see if Tomcat is started. Well, Tomcat isn't. That's a given, considering that the JVM just crashed. A circle. See? Your application is Tomcat, not the JVM. My point is that if you can successfully retrieve output from Tomcat, generated by either a servlet or a JSP, all is well. Tomcat is happy, the JVM is happy, all is well. If you can't, something is wrong, and you have to restart anyway. Seems simpler to me, but I guess there will always be different ways to do things. Heck, if this happens alot
RE: crontab problems
Still won't work. A 404, 500, or other error will have a content length greater than 0. That's bad. John -Original Message- From: Ron Day [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 3:43 PM To: Tomcat Users List Subject: RE: crontab problems Thanks , two questions... 1) Does the URL creation have to be inside the while loop ? 2) Shouldn't the if statement test be: (! con.getContentLength() 0) rather than (con.getContentLength() 0) Ron -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 2:06 PM To: Tomcat Users List Subject: Re: crontab problems Would you expand on option 2. A Java thread is a sequence of execution of Java bytecode on a JVM. Obviously, there can be multiple threads per JVM. A JVM is a native operating system process interpreting (sometimes compiling on the fly) the bytecode of at least one Java thread. Since there can be multiple processes per machine, there can be multiple JVMs per machine. Ideally, these JVMs are completely separated, at least their address space (memory) is. Sometimes an operating system provides native threads. These are threads of execution of machine instructions on the real machine. There can be multiple native threads per native process. Thus, it is possible to map native threads to Java threads: the JVM process contains multiple real threads, each executing one thread of bytecode. I don't think the Sun's JVM does that, but I'm not sure. You just have to make sure that the monitoring thread is not executed inside the same JVM that runs the application to be monitored. Why is this a thread rather than a java app that is started on system startup ? Option 2 IS a Java application. It consists of a single Java thread (the one running the main() method). But it is started only once and it repeats internally - note the infinite while() loop. A cronjob is a Unix process that is repeated externally. I use the term externally, because it is started all over again periodically by an 'higher power', i.e. CRON. Cronjobs don't usually contain infinite loops. Whether to use internal or external repetition depends on the situation: external repetetion is more time consuming but it releases all resources, e.g. memory after each iteration. Internal repetition is fast but it blocks resources forever, basically. So if something needs to be executed once every minute I would strongly suggest internal repetition. If it needs to run once a day only, I would suggest external repetition. import java.net.*; public class Main { public void main( String[] args ) { while(true) { URL url = new URL( http://localhost:8080/examples; ); URLConnection con = url.openConnection(); con.setUseCaches( false ); con.connect(); if( con.getContentLength() 0 ) { // restart tomcat } // cleanup Thread.getCurrentThread().sleep( 100 ); // or so, I'm not sure } } } - Original Message - From: Ron Day [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 8:00 PM Subject: RE: crontab problems Ron -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 12:50 PM To: Tomcat Users List Subject: Re: crontab problems There's not a single JVM per machine. Even if the JVM running Tomcat inside it is crashed, it's prefectly ok to start another one testing for the existence or availability of Tomcat and/or a webapp. That will work. It's just that this solution is a little awkward. Let me summarize the alternatives: 1) A cronjob shell script using wget as John suggested. 2) A Java Thread running in a different UNIX process, i.e. JVM which repeatedly tests the webapp's availability like I suggested in my first posting. That thread runs in a loop and is NOT started regularly by cron but once when the system starts (aka. init script). Aside from that, your primary goal should be to get rid of the crash. Ever tried downgrading to a 1.3 JDK? - Original Message - From: Turner, John [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 6:16 PM Subject: RE: crontab problems No, I guess that would work. It just seems to be needlessly complicated and resource intensive. You normally don't consider a program crashing as normal behavior. The point of a monitoring application is for it to NEVER crash, and continually check some other application. Think about itcron launches your program to see if Tomcat is started. Well, Tomcat isn't. That's a given
Re: crontab problems
Right. My sample code wasn't meant to be 100% correct. I wanted to show the big picture. Yes, it should be (! con.getContentLength() 0) an yes even that wouldn't work as John explained. So this is my second guess: import java.net.*; import java.io.*; public class Main { public void main( String[] args ) { while(true) { URL url = new URL( http://localhost:8080/mywebapp/ping.jsp; ); URLConnection con = url.openConnection(); con.setUseCaches( false ); con.connect(); try { InputStream is = con.getInputStream(); InputStreamReader isr = new InputStreamReader( is ); BufferedReader br = new BuffererdReader( isr ); String line; boolean success = false; while( null != ( line = br.readLine() ) { if( -1 != line.indexOf( !!!SUCCESS!!! ) { success = true; } } // ... close streams etc. if( ! success ) { // restart tomcat } } catch( Exception e ) { // handle exceptions } // ... cleanup Thread.currentThread().sleep( 60 * 1000 ); } } } - Original Message - From: Turner, John [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 9:53 PM Subject: RE: crontab problems Still won't work. A 404, 500, or other error will have a content length greater than 0. That's bad. John -Original Message- From: Ron Day [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 3:43 PM To: Tomcat Users List Subject: RE: crontab problems Thanks , two questions... 1) Does the URL creation have to be inside the while loop ? 2) Shouldn't the if statement test be: (! con.getContentLength() 0) rather than (con.getContentLength() 0) Ron -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 2:06 PM To: Tomcat Users List Subject: Re: crontab problems Would you expand on option 2. A Java thread is a sequence of execution of Java bytecode on a JVM. Obviously, there can be multiple threads per JVM. A JVM is a native operating system process interpreting (sometimes compiling on the fly) the bytecode of at least one Java thread. Since there can be multiple processes per machine, there can be multiple JVMs per machine. Ideally, these JVMs are completely separated, at least their address space (memory) is. Sometimes an operating system provides native threads. These are threads of execution of machine instructions on the real machine. There can be multiple native threads per native process. Thus, it is possible to map native threads to Java threads: the JVM process contains multiple real threads, each executing one thread of bytecode. I don't think the Sun's JVM does that, but I'm not sure. You just have to make sure that the monitoring thread is not executed inside the same JVM that runs the application to be monitored. Why is this a thread rather than a java app that is started on system startup ? Option 2 IS a Java application. It consists of a single Java thread (the one running the main() method). But it is started only once and it repeats internally - note the infinite while() loop. A cronjob is a Unix process that is repeated externally. I use the term externally, because it is started all over again periodically by an 'higher power', i.e. CRON. Cronjobs don't usually contain infinite loops. Whether to use internal or external repetition depends on the situation: external repetetion is more time consuming but it releases all resources, e.g. memory after each iteration. Internal repetition is fast but it blocks resources forever, basically. So if something needs to be executed once every minute I would strongly suggest internal repetition. If it needs to run once a day only, I would suggest external repetition. import java.net.*; public class Main { public void main( String[] args ) { while(true) { URL url = new URL( http://localhost:8080/examples; ); URLConnection con = url.openConnection(); con.setUseCaches( false ); con.connect(); if( con.getContentLength() 0 ) { // restart tomcat } // cleanup Thread.getCurrentThread().sleep( 100 ); // or so, I'm not sure } } } - Original Message - From: Ron Day [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 8:00 PM Subject: RE: crontab problems
RE: crontab problems
Does the URL instantiation have to be inside the while loop ?? -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 3:56 PM To: Tomcat Users List Subject: Re: crontab problems Right. My sample code wasn't meant to be 100% correct. I wanted to show the big picture. Yes, it should be (! con.getContentLength() 0) an yes even that wouldn't work as John explained. So this is my second guess: import java.net.*; import java.io.*; public class Main { public void main( String[] args ) { while(true) { URL url = new URL( http://localhost:8080/mywebapp/ping.jsp; ); URLConnection con = url.openConnection(); con.setUseCaches( false ); con.connect(); try { InputStream is = con.getInputStream(); InputStreamReader isr = new InputStreamReader( is ); BufferedReader br = new BuffererdReader( isr ); String line; boolean success = false; while( null != ( line = br.readLine() ) { if( -1 != line.indexOf( !!!SUCCESS!!! ) { success = true; } } // ... close streams etc. if( ! success ) { // restart tomcat } } catch( Exception e ) { // handle exceptions } // ... cleanup Thread.currentThread().sleep( 60 * 1000 ); } } } - Original Message - From: Turner, John [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 9:53 PM Subject: RE: crontab problems Still won't work. A 404, 500, or other error will have a content length greater than 0. That's bad. John -Original Message- From: Ron Day [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 3:43 PM To: Tomcat Users List Subject: RE: crontab problems Thanks , two questions... 1) Does the URL creation have to be inside the while loop ? 2) Shouldn't the if statement test be: (! con.getContentLength() 0) rather than (con.getContentLength() 0) Ron -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 2:06 PM To: Tomcat Users List Subject: Re: crontab problems Would you expand on option 2. A Java thread is a sequence of execution of Java bytecode on a JVM. Obviously, there can be multiple threads per JVM. A JVM is a native operating system process interpreting (sometimes compiling on the fly) the bytecode of at least one Java thread. Since there can be multiple processes per machine, there can be multiple JVMs per machine. Ideally, these JVMs are completely separated, at least their address space (memory) is. Sometimes an operating system provides native threads. These are threads of execution of machine instructions on the real machine. There can be multiple native threads per native process. Thus, it is possible to map native threads to Java threads: the JVM process contains multiple real threads, each executing one thread of bytecode. I don't think the Sun's JVM does that, but I'm not sure. You just have to make sure that the monitoring thread is not executed inside the same JVM that runs the application to be monitored. Why is this a thread rather than a java app that is started on system startup ? Option 2 IS a Java application. It consists of a single Java thread (the one running the main() method). But it is started only once and it repeats internally - note the infinite while() loop. A cronjob is a Unix process that is repeated externally. I use the term externally, because it is started all over again periodically by an 'higher power', i.e. CRON. Cronjobs don't usually contain infinite loops. Whether to use internal or external repetition depends on the situation: external repetetion is more time consuming but it releases all resources, e.g. memory after each iteration. Internal repetition is fast but it blocks resources forever, basically. So if something needs to be executed once every minute I would strongly suggest internal repetition. If it needs to run once a day only, I would suggest external repetition. import java.net.*; public class Main { public void main( String[] args ) { while(true) { URL url = new URL( http://localhost:8080/examples; ); URLConnection con = url.openConnection(); con.setUseCaches( false ); con.connect(); if( con.getContentLength() 0 ) { // restart tomcat } // cleanup Thread.getCurrentThread().sleep( 100 ); // or so, I'm
Re: crontab problems
Probably not. But the connection does have to be inside the loop. Keep in mind that this is a concept. I have never compiled or tested that code ... - Original Message - From: Ron Day [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 11:09 PM Subject: RE: crontab problems Does the URL instantiation have to be inside the while loop ?? -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 3:56 PM To: Tomcat Users List Subject: Re: crontab problems Right. My sample code wasn't meant to be 100% correct. I wanted to show the big picture. Yes, it should be (! con.getContentLength() 0) an yes even that wouldn't work as John explained. So this is my second guess: import java.net.*; import java.io.*; public class Main { public void main( String[] args ) { while(true) { URL url = new URL( http://localhost:8080/mywebapp/ping.jsp; ); URLConnection con = url.openConnection(); con.setUseCaches( false ); con.connect(); try { InputStream is = con.getInputStream(); InputStreamReader isr = new InputStreamReader( is ); BufferedReader br = new BuffererdReader( isr ); String line; boolean success = false; while( null != ( line = br.readLine() ) { if( -1 != line.indexOf( !!!SUCCESS!!! ) { success = true; } } // ... close streams etc. if( ! success ) { // restart tomcat } } catch( Exception e ) { // handle exceptions } // ... cleanup Thread.currentThread().sleep( 60 * 1000 ); } } } - Original Message - From: Turner, John [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 9:53 PM Subject: RE: crontab problems Still won't work. A 404, 500, or other error will have a content length greater than 0. That's bad. John -Original Message- From: Ron Day [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 3:43 PM To: Tomcat Users List Subject: RE: crontab problems Thanks , two questions... 1) Does the URL creation have to be inside the while loop ? 2) Shouldn't the if statement test be: (! con.getContentLength() 0) rather than (con.getContentLength() 0) Ron -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 2:06 PM To: Tomcat Users List Subject: Re: crontab problems Would you expand on option 2. A Java thread is a sequence of execution of Java bytecode on a JVM. Obviously, there can be multiple threads per JVM. A JVM is a native operating system process interpreting (sometimes compiling on the fly) the bytecode of at least one Java thread. Since there can be multiple processes per machine, there can be multiple JVMs per machine. Ideally, these JVMs are completely separated, at least their address space (memory) is. Sometimes an operating system provides native threads. These are threads of execution of machine instructions on the real machine. There can be multiple native threads per native process. Thus, it is possible to map native threads to Java threads: the JVM process contains multiple real threads, each executing one thread of bytecode. I don't think the Sun's JVM does that, but I'm not sure. You just have to make sure that the monitoring thread is not executed inside the same JVM that runs the application to be monitored. Why is this a thread rather than a java app that is started on system startup ? Option 2 IS a Java application. It consists of a single Java thread (the one running the main() method). But it is started only once and it repeats internally - note the infinite while() loop. A cronjob is a Unix process that is repeated externally. I use the term externally, because it is started all over again periodically by an 'higher power', i.e. CRON. Cronjobs don't usually contain infinite loops. Whether to use internal or external repetition depends on the situation: external repetetion is more time consuming but it releases all resources, e.g. memory after each iteration. Internal repetition is fast but it blocks resources forever, basically. So if something needs to be executed once every minute I would strongly suggest internal repetition. If it needs to run once a day only, I would suggest external repetition. import java.net.*; public class
RE: crontab problems
I have code very similar to this that does work... except whenever I get an unknowHostException, it seems to be cached somewhere until I bounce Tomcat. My code actually pulses another website (in a thread every 3 minutes)that is on the network, rather than check Tomcat. In place of your streams, I actually set the request method to HEAD, and interrogate the Response Code. This is easy to do in HTTPURLConnection. I instantiate the URL outside the loop (and hence only once), and I am wondering if this is the source of my problem. I plan to test it ASAP. ron -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 6:27 PM To: Tomcat Users List Subject: Re: crontab problems Probably not. But the connection does have to be inside the loop. Keep in mind that this is a concept. I have never compiled or tested that code ... - Original Message - From: Ron Day [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 11:09 PMnstantiate the URL outside my loop Subject: RE: crontab problems Does the URL instantiation have to be inside the while loop ?? -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 3:56 PM To: Tomcat Users List Subject: Re: crontab problems Right. My sample code wasn't meant to be 100% correct. I wanted to show the big picture. Yes, it should be (! con.getContentLength() 0) an yes even that wouldn't work as John explained. So this is my second guess: import java.net.*; import java.io.*; public class Main { public void main( String[] args ) { while(true) { URL url = new URL( http://localhost:8080/mywebapp/ping.jsp; ); URLConnection con = url.openConnection(); con.setUseCaches( false ); con.connect(); try { InputStream is = con.getInputStream(); InputStreamReader isr = new InputStreamReader( is ); BufferedReader br = new BuffererdReader( isr ); String line; boolean success = false; while( null != ( line = br.readLine() ) { if( -1 != line.indexOf( !!!SUCCESS!!! ) { success = true; } } // ... close streams etc. if( ! success ) { // restart tomcat } } catch( Exception e ) { // handle exceptions } // ... cleanup Thread.currentThread().sleep( 60 * 1000 ); } } } - Original Message - From: Turner, John [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 9:53 PM Subject: RE: crontab problems Still won't work. A 404, 500, or other error will have a content length greater than 0. That's bad. John -Original Message- From: Ron Day [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 3:43 PM To: Tomcat Users List Subject: RE: crontab problems Thanks , two questions... 1) Does the URL creation have to be inside the while loop ? 2) Shouldn't the if statement test be: (! con.getContentLength() 0) rather than (con.getContentLength() 0) Ron -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 2:06 PM To: Tomcat Users List Subject: Re: crontab problems Would you expand on option 2. A Java thread is a sequence of execution of Java bytecode on a JVM. Obviously, there can be multiple threads per JVM. A JVM is a native operating system process interpreting (sometimes compiling on the fly) the bytecode of at least one Java thread. Since there can be multiple processes per machine, there can be multiple JVMs per machine. Ideally, these JVMs are completely separated, at least their address space (memory) is. Sometimes an operating system provides native threads. These are threads of execution of machine instructions on the real machine. There can be multiple native threads per native process. Thus, it is possible to map native threads to Java threads: the JVM process contains multiple real threads, each executing one thread of bytecode. I don't think the Sun's JVM does that, but I'm not sure. You just have to make sure that the monitoring thread is not executed inside the same JVM that runs the application to be monitored. Why is this a thread rather than a java app that is started on system startup ? Option 2 IS a Java application. It consists of a single Java thread (the one running the main() method). But it is started only once
Re: crontab problems
I attached a version of my sample code that actually works (JDK used 1.4.1). Regarding your problem: I don't understand why bouncing Tomcat would resolve a DNS problem. The UnknownHostException is a indication that something is wrong with DNS or the resolver library. - Original Message - From: Ron Day [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 1:37 AM Subject: RE: crontab problems I have code very similar to this that does work... except whenever I get an unknowHostException, it seems to be cached somewhere until I bounce Tomcat. My code actually pulses another website (in a thread every 3 minutes)that is on the network, rather than check Tomcat. In place of your streams, I actually set the request method to HEAD, and interrogate the Response Code. This is easy to do in HTTPURLConnection. I instantiate the URL outside the loop (and hence only once), and I am wondering if this is the source of my problem. I plan to test it ASAP. ron - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: crontab problems
Sorry, I wasn't very clear. I have a Struts application. My heartbeat thread that checks the other server, is spawned from the init method of the controller servlet, so bouncing tomcat restarts the heartbeat thread. My issue is, once the heartbeat program gets an UnknownHostException , for some reason. The heartbeat program keeps thinking there is a UnknownHostException until it is restarted (by bouncing Tomcat), just like it was cached somewhere. I was thinking that getting the URL object every time though the loop may solve this. I'm not sure what else would cause it. The DNS issue clears up , but the heartbeat still thinks there is an exception. -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 8:02 PM To: Tomcat Users List Subject: Re: crontab problems I attached a version of my sample code that actually works (JDK used 1.4.1). Regarding your problem: I don't understand why bouncing Tomcat would resolve a DNS problem. The UnknownHostException is a indication that something is wrong with DNS or the resolver library. - Original Message - From: Ron Day [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 1:37 AM Subject: RE: crontab problems I have code very similar to this that does work... except whenever I get an unknowHostException, it seems to be cached somewhere until I bounce Tomcat. My code actually pulses another website (in a thread every 3 minutes)that is on the network, rather than check Tomcat. In place of your streams, I actually set the request method to HEAD, and interrogate the Response Code. This is easy to do in HTTPURLConnection. I instantiate the URL outside the loop (and hence only once), and I am wondering if this is the source of my problem. I plan to test it ASAP. ron - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: crontab problems
No Code attached ??? -Original Message- From: Hannes Schmidt [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 8:02 PM To: Tomcat Users List Subject: Re: crontab problems I attached a version of my sample code that actually works (JDK used 1.4.1). Regarding your problem: I don't understand why bouncing Tomcat would resolve a DNS problem. The UnknownHostException is a indication that something is wrong with DNS or the resolver library. - Original Message - From: Ron Day [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 1:37 AM Subject: RE: crontab problems I have code very similar to this that does work... except whenever I get an unknowHostException, it seems to be cached somewhere until I bounce Tomcat. My code actually pulses another website (in a thread every 3 minutes)that is on the network, rather than check Tomcat. In place of your streams, I actually set the request method to HEAD, and interrogate the Response Code. This is easy to do in HTTPURLConnection. I instantiate the URL outside the loop (and hence only once), and I am wondering if this is the source of my problem. I plan to test it ASAP. ron - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: crontab problems
Just a side note: If the sole reason for this jsp is the automatic check then your example can be stripped down to: SUCCESS The rest is just to be a little bit more friendly to a browser. -Original Message- From: Turner, John [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 9:17 PM To: 'Tomcat Users List' Subject: RE: crontab problems html head titleAPP Monitor/title /head body % String myMonitor = SUCCESS; out.println(myMonitor); % /body /html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]