You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Adam Buglass <ad...@ncl.ac.uk> on 2004/03/10 13:52:10 UTC
Tomcat 4.1 hangs on File Reading
I've got a website which members can log in and out of
(by way of a form which connects to a JSP).
I've created a simple method in a Java class to write to
a text format log file to tell me stuff like who they are,
when they logged in etc.
So far so good.
I'm now trying to write a JSP to analyse this log but
when I try and access the page, tomcat usually hangs
indefinitely. Occassionally it will display something I jtas ask
for, say, the Strings of IDs. Tomcat will then slow right down
(approximately 4-6x slower) and eventually need restarting.
I've tried with a smaller test file.
I'm closing the file connection which I open in Java.
There doesn't appear to be anything in the logs, in fact
neither Tomcat nor Apache appear to recognise the page request
at all.
Any ideas / thoughts / suggestions !?
Thanks,
Adam.
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Tomcat 4.1 hangs on File Reading
Posted by Adam Buglass <ad...@ncl.ac.uk>.
Yes, I use a few while loops a bit like...
while (there's stuff in the file)
while (there isn't a separator)
while (to skip whitespace)
...etc.
Thanks, I'll try and substitute with
equivalent for loops and let you know
how I get on.
Adam.
On Wed, 2004-03-10 at 13:05, Parsons Technical Services wrote:
> Adam,
>
> Sound very similar to a problem I had a couple of days ago. Are you using
> any loops in your code? Specifically while or do-while or endless for loops.
> If so try changing them to a for loop with a high count say 10k-100k and see
> what happens. I had a sort method that under the right conditions would
> bring down my IDE and hog all the processor.
>
> Doug
> www.parsonstechnical.com
>
> ----- Original Message -----
> From: "Adam Buglass" <ad...@ncl.ac.uk>
> To: "Tomcat Users List" <to...@jakarta.apache.org>
> Sent: Wednesday, March 10, 2004 7:52 AM
> Subject: Tomcat 4.1 hangs on File Reading
>
>
> > I've got a website which members can log in and out of
> > (by way of a form which connects to a JSP).
> >
> > I've created a simple method in a Java class to write to
> > a text format log file to tell me stuff like who they are,
> > when they logged in etc.
> >
> > So far so good.
> >
> > I'm now trying to write a JSP to analyse this log but
> > when I try and access the page, tomcat usually hangs
> > indefinitely. Occassionally it will display something I jtas ask
> > for, say, the Strings of IDs. Tomcat will then slow right down
> > (approximately 4-6x slower) and eventually need restarting.
> >
> > I've tried with a smaller test file.
> > I'm closing the file connection which I open in Java.
> > There doesn't appear to be anything in the logs, in fact
> > neither Tomcat nor Apache appear to recognise the page request
> > at all.
> >
> > Any ideas / thoughts / suggestions !?
> >
> > Thanks,
> > Adam.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
RE: Tomcat 4.1 hangs on File Reading
Posted by Adam Buglass <ad...@ncl.ac.uk>.
Currently I use readline() to get a line
and then I parse the resulting String (character by character)
to get the bits I want.
I then read the different parts into a class and return it
to a calling method which reads the class into a Vector and
returns the Vector.
This is the first method:
public static LoginLog[] readLog()throws FileNotFoundException
{
Vector log = new Vector();
try {
FileReader inFile = new FileReader( "/var/log/GFWlogin.log" );
BufferedReader bfFile = new BufferedReader( inFile );
while ( bfFile.ready() ) {
LoginLog logentry = getLogentry( bfFile );
log.add( logentry );
}
bfFile.close();
} catch ( IOException e ) {} ;
return (LoginLog[])log.toArray( new LoginLog[log.size()] );
}
The method "getLogentry( bfFile )" simply reads the
line, parses the String and returns the class as I described
at the top.
Adam.
On Wed, 2004-03-10 at 13:15, Peter Guyatt wrote:
> Hi There,
>
> This read of the file? are you doing it a character at a time (ie via the
> read() method?)
>
> If so try reading more than one charcter at a time.
>
> Ie.
>
> public void readFile (String filename) {
> try {
> File f = new File(filename);
> FileReader fr = new FileReader(f);
> char data[] = new char[4096];
> int line = 0, read, i;
> //loop until all the data is read from the stream
> while ((read = fr.read(data, 0, 4096)) != -1) {
> //do somthing with the data read
> }
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
>
> This will dramatically improve performance and hopefully stop your problem
>
> Thanks
>
> Pete
>
> -----Original Message-----
> From: Parsons Technical Services [mailto:parsonstechnical@earthlink.net]
> Sent: 10 March 2004 13:06
> To: Tomcat Users List
> Subject: Re: Tomcat 4.1 hangs on File Reading
>
>
> Adam,
>
> Sound very similar to a problem I had a couple of days ago. Are you using
> any loops in your code? Specifically while or do-while or endless for loops.
> If so try changing them to a for loop with a high count say 10k-100k and see
> what happens. I had a sort method that under the right conditions would
> bring down my IDE and hog all the processor.
>
> Doug
> www.parsonstechnical.com
>
> ----- Original Message -----
> From: "Adam Buglass" <ad...@ncl.ac.uk>
> To: "Tomcat Users List" <to...@jakarta.apache.org>
> Sent: Wednesday, March 10, 2004 7:52 AM
> Subject: Tomcat 4.1 hangs on File Reading
>
>
> > I've got a website which members can log in and out of
> > (by way of a form which connects to a JSP).
> >
> > I've created a simple method in a Java class to write to
> > a text format log file to tell me stuff like who they are,
> > when they logged in etc.
> >
> > So far so good.
> >
> > I'm now trying to write a JSP to analyse this log but
> > when I try and access the page, tomcat usually hangs
> > indefinitely. Occassionally it will display something I jtas ask
> > for, say, the Strings of IDs. Tomcat will then slow right down
> > (approximately 4-6x slower) and eventually need restarting.
> >
> > I've tried with a smaller test file.
> > I'm closing the file connection which I open in Java.
> > There doesn't appear to be anything in the logs, in fact
> > neither Tomcat nor Apache appear to recognise the page request
> > at all.
> >
> > Any ideas / thoughts / suggestions !?
> >
> > Thanks,
> > Adam.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
--
Adam Buglass, ><>
The Golden Freeway,
Department of Child Health,
University of Newcastle-upon-Tyne.
Royal Victoria Infirmary.
(0191) 2023062
"Democracy is two wolves and a lamb voting on what to have for lunch.
Liberty is a well-armed lamb contesting the vote."
~Benjamin Franklin, 1759
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
RE: Tomcat 4.1 hangs on File Reading
Posted by Peter Guyatt <pg...@telesoft-technologies.com>.
Hi There,
This read of the file? are you doing it a character at a time (ie via the
read() method?)
If so try reading more than one charcter at a time.
Ie.
public void readFile (String filename) {
try {
File f = new File(filename);
FileReader fr = new FileReader(f);
char data[] = new char[4096];
int line = 0, read, i;
//loop until all the data is read from the stream
while ((read = fr.read(data, 0, 4096)) != -1) {
//do somthing with the data read
}
} catch (Exception e) {
e.printStackTrace();
}
}
This will dramatically improve performance and hopefully stop your problem
Thanks
Pete
-----Original Message-----
From: Parsons Technical Services [mailto:parsonstechnical@earthlink.net]
Sent: 10 March 2004 13:06
To: Tomcat Users List
Subject: Re: Tomcat 4.1 hangs on File Reading
Adam,
Sound very similar to a problem I had a couple of days ago. Are you using
any loops in your code? Specifically while or do-while or endless for loops.
If so try changing them to a for loop with a high count say 10k-100k and see
what happens. I had a sort method that under the right conditions would
bring down my IDE and hog all the processor.
Doug
www.parsonstechnical.com
----- Original Message -----
From: "Adam Buglass" <ad...@ncl.ac.uk>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Wednesday, March 10, 2004 7:52 AM
Subject: Tomcat 4.1 hangs on File Reading
> I've got a website which members can log in and out of
> (by way of a form which connects to a JSP).
>
> I've created a simple method in a Java class to write to
> a text format log file to tell me stuff like who they are,
> when they logged in etc.
>
> So far so good.
>
> I'm now trying to write a JSP to analyse this log but
> when I try and access the page, tomcat usually hangs
> indefinitely. Occassionally it will display something I jtas ask
> for, say, the Strings of IDs. Tomcat will then slow right down
> (approximately 4-6x slower) and eventually need restarting.
>
> I've tried with a smaller test file.
> I'm closing the file connection which I open in Java.
> There doesn't appear to be anything in the logs, in fact
> neither Tomcat nor Apache appear to recognise the page request
> at all.
>
> Any ideas / thoughts / suggestions !?
>
> Thanks,
> Adam.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Tomcat 4.1 hangs on File Reading
Posted by Parsons Technical Services <pa...@earthlink.net>.
Adam,
Sound very similar to a problem I had a couple of days ago. Are you using
any loops in your code? Specifically while or do-while or endless for loops.
If so try changing them to a for loop with a high count say 10k-100k and see
what happens. I had a sort method that under the right conditions would
bring down my IDE and hog all the processor.
Doug
www.parsonstechnical.com
----- Original Message -----
From: "Adam Buglass" <ad...@ncl.ac.uk>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Wednesday, March 10, 2004 7:52 AM
Subject: Tomcat 4.1 hangs on File Reading
> I've got a website which members can log in and out of
> (by way of a form which connects to a JSP).
>
> I've created a simple method in a Java class to write to
> a text format log file to tell me stuff like who they are,
> when they logged in etc.
>
> So far so good.
>
> I'm now trying to write a JSP to analyse this log but
> when I try and access the page, tomcat usually hangs
> indefinitely. Occassionally it will display something I jtas ask
> for, say, the Strings of IDs. Tomcat will then slow right down
> (approximately 4-6x slower) and eventually need restarting.
>
> I've tried with a smaller test file.
> I'm closing the file connection which I open in Java.
> There doesn't appear to be anything in the logs, in fact
> neither Tomcat nor Apache appear to recognise the page request
> at all.
>
> Any ideas / thoughts / suggestions !?
>
> Thanks,
> Adam.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org