You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Brian Stephens <Br...@theplatform.com> on 2005/07/19 23:11:27 UTC
Tomcat Service isn't reading application specific log4j.properties
Sorry if this is an oft-repeated question. Digging through old archives
of this list and Google haven't turned up anything directly related.
I'm trying to run Tomcat 5.5.9 as a windows service (installed it using
service.bat), but for some unknown reason, it does not pick up the
log4j.properties files located in my applications WEB-INF\classes
directory. As far as I can tell, the java options, classpath and
startup class are identical for both. Is this a limitation/weakness of
the Windows Service or do I have something mis-configured?
Thank You.
Brian
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Connection pool exhausted
Posted by Peddireddy Srikanth <pe...@gmail.com>.
hi,
u have to close the connection, sothat container puts it back in the pool .
as u set maxActive="100" at max only 100 connections will be
maintained in pool and as u r not closing the connection, u would have
ran out of all the connections available in pool (ie 100)
closing the connection should solve ur problem
check this link for more details
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html
regards
Srikanth Peddireddy
On 7/20/05, Tony Smith <qu...@yahoo.com> wrote:
> I am runing tomcat 5.0 + postgresql. I set my
> connection pool in server.xml as:
>
> <Resource
> name="jdbc/mysource"
> type="javax.sql.DataSource"
> password="xxxx"
> driverClassName="org.postgresql.Driver"
> maxIdle="100"
> maxWait="5000"
> validationQuery="select * from test"
> username="xxxx"
> url="jdbc:postgresql://localhost:5432/mydb"
> maxActive="100"/>
>
> I call it from my servlet as:
>
> public Connection getConnection(){
> try{
> Context initCtx = new InitialContext();
> Context envCtx =
> (Context)initCtx.lookup("java:comp/env");
> DataSource ds =
> (DataSource)envCtx.lookup("jdbc/mysource");
> DatabaseManager.initDataSource(ds);
> return ds.getConnection();
> }catch(Exception e){
> e.printStackTrace();
> }
>
> return null;
> }
>
>
> I use the connection as:
>
> Connection connection = getConnection();
>
> ....//jdbc
>
> //I did not call connection.close(). Should I?
>
> Then, I can run my web app. But not for long. I got
> the following exception after browse a few pages:
>
> org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot
> get a connection, pool exhausted
>
>
> How can I fix it?
>
> Thanks,
>
>
>
>
>
> --- skausl <sk...@gmx.de> wrote:
>
> >
> > I have log4j-1.2.11.jar in Tomcat\common\lib and
> > log4j.properties in
> > Tomcat\common\classes\.
> >
> > > -----Original Message-----
> > > Sorry if this is an oft-repeated question.
> > Digging through
> > > old archives
> > > of this list and Google haven't turned up anything
> > directly related.
> > >
> > > I'm trying to run Tomcat 5.5.9 as a windows
> > service
> > > (installed it using
> > > service.bat), but for some unknown reason, it does
> > not pick up the
> > > log4j.properties files located in my applications
> > WEB-INF\classes
> > > directory. As far as I can tell, the java
> > options, classpath and
> > > startup class are identical for both. Is this a
> > > limitation/weakness of
> > > the Windows Service or do I have something
> > mis-configured?
> > >
> > > Thank You.
> > > Brian
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> > tomcat-user-help@jakarta.apache.org
> >
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> 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: Connection pool exhausted
Posted by Alon Belman <al...@gmail.com>.
If you arent closing connections, then exhausting the connection pool
is the expected, eventual result.
Read the document at
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html,
paying special attention to the "example of properly written code
[using] a db connection obtained from a connection pool" near the
bottom of the page.
On 7/19/05, Tony Smith <qu...@yahoo.com> wrote:
> I am runing tomcat 5.0 + postgresql. I set my
> connection pool in server.xml as:
>
> <Resource
> name="jdbc/mysource"
> type="javax.sql.DataSource"
> password="xxxx"
> driverClassName="org.postgresql.Driver"
> maxIdle="100"
> maxWait="5000"
> validationQuery="select * from test"
> username="xxxx"
> url="jdbc:postgresql://localhost:5432/mydb"
> maxActive="100"/>
>
> I call it from my servlet as:
>
> public Connection getConnection(){
> try{
> Context initCtx = new InitialContext();
> Context envCtx =
> (Context)initCtx.lookup("java:comp/env");
> DataSource ds =
> (DataSource)envCtx.lookup("jdbc/mysource");
> DatabaseManager.initDataSource(ds);
> return ds.getConnection();
> }catch(Exception e){
> e.printStackTrace();
> }
>
> return null;
> }
>
>
> I use the connection as:
>
> Connection connection = getConnection();
>
> ....//jdbc
>
> //I did not call connection.close(). Should I?
>
> Then, I can run my web app. But not for long. I got
> the following exception after browse a few pages:
>
> org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot
> get a connection, pool exhausted
>
>
> How can I fix it?
>
> Thanks,
>
>
>
>
>
> --- skausl <sk...@gmx.de> wrote:
>
> >
> > I have log4j-1.2.11.jar in Tomcat\common\lib and
> > log4j.properties in
> > Tomcat\common\classes\.
> >
> > > -----Original Message-----
> > > Sorry if this is an oft-repeated question.
> > Digging through
> > > old archives
> > > of this list and Google haven't turned up anything
> > directly related.
> > >
> > > I'm trying to run Tomcat 5.5.9 as a windows
> > service
> > > (installed it using
> > > service.bat), but for some unknown reason, it does
> > not pick up the
> > > log4j.properties files located in my applications
> > WEB-INF\classes
> > > directory. As far as I can tell, the java
> > options, classpath and
> > > startup class are identical for both. Is this a
> > > limitation/weakness of
> > > the Windows Service or do I have something
> > mis-configured?
> > >
> > > Thank You.
> > > Brian
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> > tomcat-user-help@jakarta.apache.org
> >
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> 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: Connection pool exhausted
Posted by Nikola Milutinovic <Ni...@ev.co.yu>.
Tony Smith wrote:
>I am runing tomcat 5.0 + postgresql. I set my
>connection pool in server.xml as:
>
> <Resource
> name="jdbc/mysource"
> type="javax.sql.DataSource"
> password="xxxx"
> driverClassName="org.postgresql.Driver"
> maxIdle="100"
> maxWait="5000"
> validationQuery="select * from test"
>
>
For PostgreSQL (and MySQL, too), this is better done via "SELECT
version()", just an observation.
> username="xxxx"
> url="jdbc:postgresql://localhost:5432/mydb"
> maxActive="100"/>
>
>
You can add parameters, like "removeAbandoned" to remove hanging
connections.
>I call it from my servlet as:
>
>public Connection getConnection(){
> try{
> Context initCtx = new InitialContext();
> Context envCtx =
>(Context)initCtx.lookup("java:comp/env");
> DataSource ds =
>(DataSource)envCtx.lookup("jdbc/mysource");
> DatabaseManager.initDataSource(ds);
> return ds.getConnection();
> }catch(Exception e){
> e.printStackTrace();
> }
>
> return null;
>}
>
>
>I use the connection as:
>
>Connection connection = getConnection();
>
>....//jdbc
>
>//I did not call connection.close(). Should I?
>
>
YES! The Connection you get from this is a wrapper class, that will
actually return the connection to the pool, when you call "close()" on it.
>Then, I can run my web app. But not for long. I got
>the following exception after browse a few pages:
>
>org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot
>get a connection, pool exhausted
>
>
Always close ResultSets, Statements and Connections - in that order.
This code will illustrate it for you:
PreparedStatement pstat = null;
ResultSet rs = null;
try {
pstat = conn.prepareStatement( "SELECT ..." );
pstat.setInt( 1, x );
...
rs = pstat.execute();
...
} catch (SQLException ex) {
...
} finally {
if (rs != null) {
try {
rs.close();
} catch (SQLException ex1) {}
}
if (pstat != null) {
try {
pstat.close();
} catch (SQLException ex1) {}
}
if (conn != null) {
try {
conn.close();
catch (SQLException ex1) {}
}
}
Nix.
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Connection pool exhausted
Posted by Tony Smith <qu...@yahoo.com>.
I am runing tomcat 5.0 + postgresql. I set my
connection pool in server.xml as:
<Resource
name="jdbc/mysource"
type="javax.sql.DataSource"
password="xxxx"
driverClassName="org.postgresql.Driver"
maxIdle="100"
maxWait="5000"
validationQuery="select * from test"
username="xxxx"
url="jdbc:postgresql://localhost:5432/mydb"
maxActive="100"/>
I call it from my servlet as:
public Connection getConnection(){
try{
Context initCtx = new InitialContext();
Context envCtx =
(Context)initCtx.lookup("java:comp/env");
DataSource ds =
(DataSource)envCtx.lookup("jdbc/mysource");
DatabaseManager.initDataSource(ds);
return ds.getConnection();
}catch(Exception e){
e.printStackTrace();
}
return null;
}
I use the connection as:
Connection connection = getConnection();
....//jdbc
//I did not call connection.close(). Should I?
Then, I can run my web app. But not for long. I got
the following exception after browse a few pages:
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot
get a connection, pool exhausted
How can I fix it?
Thanks,
--- skausl <sk...@gmx.de> wrote:
>
> I have log4j-1.2.11.jar in Tomcat\common\lib and
> log4j.properties in
> Tomcat\common\classes\.
>
> > -----Original Message-----
> > Sorry if this is an oft-repeated question.
> Digging through
> > old archives
> > of this list and Google haven't turned up anything
> directly related.
> >
> > I'm trying to run Tomcat 5.5.9 as a windows
> service
> > (installed it using
> > service.bat), but for some unknown reason, it does
> not pick up the
> > log4j.properties files located in my applications
> WEB-INF\classes
> > directory. As far as I can tell, the java
> options, classpath and
> > startup class are identical for both. Is this a
> > limitation/weakness of
> > the Windows Service or do I have something
> mis-configured?
> >
> > Thank You.
> > Brian
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> tomcat-user-help@jakarta.apache.org
>
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
RE: Tomcat Service isn't reading application specific log4j.properties
Posted by skausl <sk...@gmx.de>.
I have log4j-1.2.11.jar in Tomcat\common\lib and log4j.properties in
Tomcat\common\classes\.
> -----Original Message-----
> Sorry if this is an oft-repeated question. Digging through
> old archives
> of this list and Google haven't turned up anything directly related.
>
> I'm trying to run Tomcat 5.5.9 as a windows service
> (installed it using
> service.bat), but for some unknown reason, it does not pick up the
> log4j.properties files located in my applications WEB-INF\classes
> directory. As far as I can tell, the java options, classpath and
> startup class are identical for both. Is this a
> limitation/weakness of
> the Windows Service or do I have something mis-configured?
>
> Thank You.
> Brian
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org