You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Charles P. Killmer" <ch...@netgaintechnology.com> on 2005/10/25 22:04:43 UTC

Tracking

I have a bunch of JSP files that all instantiate a single class file.
Is there a way for the class file to log which file called it and
ideally from which line the call was made?

 

My bigger problem is that I am using Connection pooling.  And if I don't
close every connection when I am down with it, the server stops
responding.  Restart Tomcat and everything is back to normal.  Is there
a setting to have Tomcat close all connections for me when a request
finishes?

 

Thank you for any thoughts.

Charles

 

 


Re: Tracking

Posted by Larry Meadors <lm...@apache.org>.
Man, this feels like telling someone how to shoot their foot off, but this
would be shorter:

new Exception().printStackTrace();

Larry


On 10/25/05, Steve Stearns <st...@bigbrother.net> wrote:
>
> Charles P. Killmer wrote:
>
> >I have a bunch of JSP files that all instantiate a single class file.
> >Is there a way for the class file to log which file called it and
> >ideally from which line the call was made?
> >
> There might be a better way to do this but off the top of my head I
> should think this would work if you added it to your JSP pages:
>
> <%
> try {
> throw new RuntimeException("Log call");
> }
> catch (RuntimeException e) {
> e.printStackTrace();
> }
> %>
>
> ---Steve
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Tracking

Posted by Steve Stearns <st...@bigbrother.net>.
Charles P. Killmer wrote:

>I have a bunch of JSP files that all instantiate a single class file.
>Is there a way for the class file to log which file called it and
>ideally from which line the call was made?
>
There might be a better way to do this but off the top of my head I 
should think this would work if you added it to your JSP pages:

<%
try {
    throw new RuntimeException("Log call");
}
catch (RuntimeException e) {
    e.printStackTrace();
}
%>

---Steve

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


RE: Tracking

Posted by Richard Mixon <rn...@qwest.net>.
You do not say which version of Tomcat you are using. But in general you can
set the removeAbandoned* parameters to mitigate the problem (i.e. it will
take longer to stop responding).

If using 5.5.x look for the heading "Preventing dB connection pool leaks"
at:
 
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html

HTH - Richard

-----Original Message-----
From: Charles P. Killmer [mailto:charlesk@netgaintechnology.com] 
Sent: Tuesday, October 25, 2005 1:05 PM
To: Tomcat Users List
Subject: Tracking

I have a bunch of JSP files that all instantiate a single class file.
Is there a way for the class file to log which file called it and ideally
from which line the call was made?

 

My bigger problem is that I am using Connection pooling.  And if I don't
close every connection when I am down with it, the server stops responding.
Restart Tomcat and everything is back to normal.  Is there a setting to have
Tomcat close all connections for me when a request finishes?

 

Thank you for any thoughts.

Charles

 

 



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


RE: Tracking

Posted by Steve Kirk <to...@web-startup.co.uk>.
Charles, see also my reply to Nanda Kumar's thread "Cannot get a connection,
pool exhausted" for a coding example.  HTH :)

> -----Original Message-----
> From: Steve Kirk [mailto:tomcat-user@web-startup.co.uk] 
> Sent: Wednesday 26 October 2005 14:01
> To: 'Tomcat Users List'
> Subject: RE: Tracking
> 
> 
> 
> Charles, I don't know of a way to have TC clear up conns for 
> you, but you
> really should clear up connections explicitly.  To some 
> extent DBCP will
> clear up "abandoned" connections (to which you had a variable 
> reference,
> which goes out of scope when you have finished processing the 
> request), but
> this is bad style rally and you should not rely on it.
> 
> The "standard" way to clear up connections is to use a 
> try/catch/finally
> structure in your code.
> 
> eg
> (I'm assuming that you are using DBCP)
> 
> Connection c = MyClass.getConnection();	// or however 
> you get a conn from
> the pool
> try
> {
> 	// use the connection to do whatever
> }
> catch(Exception e)
> {
> 	// handle exceptions
> }
> finally
> {
> 	c.close();
> }
> 
> > -----Original Message-----
> > From: Charles P. Killmer [mailto:charlesk@netgaintechnology.com] 
> > Sent: Tuesday 25 October 2005 21:05
> > To: Tomcat Users List
> > Subject: Tracking
> > 
> > My bigger problem is that I am using Connection pooling.  And 
> > if I don't
> > close every connection when I am down with it, the server stops
> > responding.  Restart Tomcat and everything is back to normal. 
> >  Is there
> > a setting to have Tomcat close all connections for me when a request
> > finishes?
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 



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


RE: Tracking

Posted by Steve Kirk <to...@web-startup.co.uk>.
Charles, I don't know of a way to have TC clear up conns for you, but you
really should clear up connections explicitly.  To some extent DBCP will
clear up "abandoned" connections (to which you had a variable reference,
which goes out of scope when you have finished processing the request), but
this is bad style rally and you should not rely on it.

The "standard" way to clear up connections is to use a try/catch/finally
structure in your code.

eg
(I'm assuming that you are using DBCP)

Connection c = MyClass.getConnection();	// or however you get a conn from
the pool
try
{
	// use the connection to do whatever
}
catch(Exception e)
{
	// handle exceptions
}
finally
{
	c.close();
}

> -----Original Message-----
> From: Charles P. Killmer [mailto:charlesk@netgaintechnology.com] 
> Sent: Tuesday 25 October 2005 21:05
> To: Tomcat Users List
> Subject: Tracking
> 
> My bigger problem is that I am using Connection pooling.  And 
> if I don't
> close every connection when I am down with it, the server stops
> responding.  Restart Tomcat and everything is back to normal. 
>  Is there
> a setting to have Tomcat close all connections for me when a request
> finishes?



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