You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Kirchhoff, Florian" <Fl...@qwest.com> on 2008/02/22 17:50:19 UTC

JDBC driver JARs in a shared production environment

Hi everybody,

Question: if you cannot place the JDBC driver jars in
CATALINA_HOME/commons/lib, where can you put them?

Here is the context of my question:

* A production environment where each application runs in a separate
instance of Tomcat
* Each application has it's own $CATALINA_BASE and pointing to same
$CATALINA_HOME.
* OS is RH Red Hat Enterprise Linux 4
* Tomcat 5.5.* is used as bundled by RH.

Last but not least:
* Deploying the JDCB drivers used by each applications to
$CATALINA_HOME/commons/lib is not possible.

So my question is, what is the better alternative:

1) Place the JDBC jars in $CATALINA_BASE/jdbc and modify the start-up
script to include these jars on the CLASSPATH?
2) Deploy the JDBC jars in the WAR file (e.g. WEB-INF/lib/jdbc) and
modify the start-up script to include these jar on the CLASSPATH?
3) Deploy the JDBC jars and commons-dbcp.jar in the WAR in WEB-INF/lib?
4) other?

This is a real problem we're faced with and I would really appreciate
some input on the best possible alternative.

Thanks,

Florian



This communication is the property of Qwest and may contain confidential or
privileged information. Unauthorized use of this communication is strictly 
prohibited and may be unlawful.  If you have received this communication 
in error, please immediately notify the sender by reply e-mail and destroy 
all copies of the communication and any attachments.

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


RE: JDBC driver JARs in a shared production environment

Posted by "Katilie, John" <Jo...@softwareagusa.com>.
Florian, Thanks for the feedback. I'll give it a try!

jfk

-----Original Message-----
From: Kirchhoff, Florian [mailto:Florian.Kirchhoff@qwest.com] 
Sent: Friday, February 22, 2008 2:52 PM
To: Tomcat Users List
Subject: RE: JDBC driver JARs in a shared production environment

jfk, thank you for the feedback. 

What I found out is that the only way to get the JDBC driver in
WEB-INF/lib to be found by the classloader is if you also place a copy
of commons-dbcp.jar in your WAR AND you modify your context.xml to
include this attribute:

factory="org.apache.commons.dbcp.BasicDataSourceFactory"

I guess this scenario is exactly why the Tomcat dev team has to
repackage the DBCP code into naming-factory-dbcp.jar.

BTW the RH distribution of Tomcat also omits naming-factory-dbcp.jar,
forcing you to use the factory attribute above, even when you
don't include commons-dbcp.jar in your WAR.

Florian

-----Original Message-----
From: Katilie, John [mailto:John.Katilie@softwareagusa.com] 
Sent: Friday, February 22, 2008 2:20 PM
To: Tomcat Users List
Subject: RE: JDBC driver JARs in a shared production environment

It makes sense to put the JDBC driver jars in the war but I had problems
when I had a resource like the following in my context.xml:

<Resource
      name="jdbc/database"
      url="jdbc:mysql://localhost:3306/art"
      driverClassName="com.mysql.jdbc.Driver"
      username="art"
      password="art"
      validationQuery="select 1"
      type="javax.sql.DataSource"
      maxIdle="2"
      maxWait="5000"
      maxActive="4"
  />

And doing a JNDI lookup for the Datasource. I ended up getting Class Not
Found exceptions until I moved the Jar files into the Common Tomcat Lib
directory. This was with Tomcat 6.0.14 and it was about 4-6 months ago.
I've never got back into looking at it closer.

Just food for thought.

jfk 

-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com]
Sent: Friday, February 22, 2008 12:30 PM
To: Tomcat Users List
Subject: RE: JDBC driver JARs in a shared production environment

> From: Kirchhoff, Florian [mailto:Florian.Kirchhoff@qwest.com]
> Subject: JDBC driver JARs in a shared production environment
> 
> Question: if you cannot place the JDBC driver jars in 
> CATALINA_HOME/commons/lib, where can you put them?
> 
> 1) Place the JDBC jars in $CATALINA_BASE/jdbc and modify the start-up 
> script to include these jars on the CLASSPATH?
> 2) Deploy the JDBC jars in the WAR file (e.g. WEB-INF/lib/jdbc) and 
> modify the start-up script to include these jar on the CLASSPATH?

NEVER, NEVER, NEVER set CLASSPATH for use with Tomcat.

> 3) Deploy the JDBC jars and commons-dbcp.jar in the WAR in 
> WEB-INF/lib?

Yes.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

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


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


This communication is the property of Qwest and may contain confidential
or
privileged information. Unauthorized use of this communication is
strictly 
prohibited and may be unlawful.  If you have received this communication

in error, please immediately notify the sender by reply e-mail and
destroy 
all copies of the communication and any attachments.

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


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


RE: JDBC driver JARs in a shared production environment

Posted by "Kirchhoff, Florian" <Fl...@qwest.com>.
jfk, thank you for the feedback. 

What I found out is that the only way to get the JDBC driver in
WEB-INF/lib to be found by the classloader is if you also place a copy
of commons-dbcp.jar in your WAR AND you modify your context.xml to
include this attribute:

factory="org.apache.commons.dbcp.BasicDataSourceFactory"

I guess this scenario is exactly why the Tomcat dev team has to
repackage the DBCP code into naming-factory-dbcp.jar.

BTW the RH distribution of Tomcat also omits naming-factory-dbcp.jar,
forcing you to use the factory attribute above, even when you
don't include commons-dbcp.jar in your WAR.

Florian

-----Original Message-----
From: Katilie, John [mailto:John.Katilie@softwareagusa.com] 
Sent: Friday, February 22, 2008 2:20 PM
To: Tomcat Users List
Subject: RE: JDBC driver JARs in a shared production environment

It makes sense to put the JDBC driver jars in the war but I had problems
when I had a resource like the following in my context.xml:

<Resource
      name="jdbc/database"
      url="jdbc:mysql://localhost:3306/art"
      driverClassName="com.mysql.jdbc.Driver"
      username="art"
      password="art"
      validationQuery="select 1"
      type="javax.sql.DataSource"
      maxIdle="2"
      maxWait="5000"
      maxActive="4"
  />

And doing a JNDI lookup for the Datasource. I ended up getting Class Not
Found exceptions until I moved the Jar files into the Common Tomcat Lib
directory. This was with Tomcat 6.0.14 and it was about 4-6 months ago.
I've never got back into looking at it closer.

Just food for thought.

jfk 

-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com]
Sent: Friday, February 22, 2008 12:30 PM
To: Tomcat Users List
Subject: RE: JDBC driver JARs in a shared production environment

> From: Kirchhoff, Florian [mailto:Florian.Kirchhoff@qwest.com]
> Subject: JDBC driver JARs in a shared production environment
> 
> Question: if you cannot place the JDBC driver jars in 
> CATALINA_HOME/commons/lib, where can you put them?
> 
> 1) Place the JDBC jars in $CATALINA_BASE/jdbc and modify the start-up 
> script to include these jars on the CLASSPATH?
> 2) Deploy the JDBC jars in the WAR file (e.g. WEB-INF/lib/jdbc) and 
> modify the start-up script to include these jar on the CLASSPATH?

NEVER, NEVER, NEVER set CLASSPATH for use with Tomcat.

> 3) Deploy the JDBC jars and commons-dbcp.jar in the WAR in 
> WEB-INF/lib?

Yes.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

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


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


This communication is the property of Qwest and may contain confidential or
privileged information. Unauthorized use of this communication is strictly 
prohibited and may be unlawful.  If you have received this communication 
in error, please immediately notify the sender by reply e-mail and destroy 
all copies of the communication and any attachments.

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


RE: JDBC driver JARs in a shared production environment

Posted by "Katilie, John" <Jo...@softwareagusa.com>.
It makes sense to put the JDBC driver jars in the war but I had problems
when I had a resource like the following in my context.xml:

<Resource
      name="jdbc/database"
      url="jdbc:mysql://localhost:3306/art"
      driverClassName="com.mysql.jdbc.Driver"
      username="art"
      password="art"
      validationQuery="select 1"
      type="javax.sql.DataSource"
      maxIdle="2"
      maxWait="5000"
      maxActive="4"
  />

And doing a JNDI lookup for the Datasource. I ended up getting Class Not
Found exceptions until I moved the Jar files into the Common Tomcat Lib
directory. This was with Tomcat 6.0.14 and it was about 4-6 months ago.
I've never got back into looking at it closer.

Just food for thought.

jfk 

-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com] 
Sent: Friday, February 22, 2008 12:30 PM
To: Tomcat Users List
Subject: RE: JDBC driver JARs in a shared production environment

> From: Kirchhoff, Florian [mailto:Florian.Kirchhoff@qwest.com] 
> Subject: JDBC driver JARs in a shared production environment
> 
> Question: if you cannot place the JDBC driver jars in
> CATALINA_HOME/commons/lib, where can you put them?
> 
> 1) Place the JDBC jars in $CATALINA_BASE/jdbc and modify the start-up
> script to include these jars on the CLASSPATH?
> 2) Deploy the JDBC jars in the WAR file (e.g. WEB-INF/lib/jdbc) and
> modify the start-up script to include these jar on the CLASSPATH?

NEVER, NEVER, NEVER set CLASSPATH for use with Tomcat.

> 3) Deploy the JDBC jars and commons-dbcp.jar in the WAR in 
> WEB-INF/lib?

Yes.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

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


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


RE: JDBC driver JARs in a shared production environment

Posted by "Kirchhoff, Florian" <Fl...@qwest.com>.
Chuck,

thank you for your prompt feedback. I have a couple of follow-up
questions below:
 
>> 3) Deploy the JDBC jars and commons-dbcp.jar in the WAR in 
>> WEB-INF/lib?>
>
>Yes.

Great, that's what'll do. But is there anything one must be careful
about 
in this case? For example should a particular version of DBCP be used
for a 
given version of Tomcat?

>> Question: if you cannot place the JDBC driver jars in 
>> CATALINA_HOME/commons/lib, where can you put them?
>> 
>> 1) Place the JDBC jars in $CATALINA_BASE/jdbc and modify the start-up

>> script to include these jars on the CLASSPATH?
>> 2) Deploy the JDBC jars in the WAR file (e.g. WEB-INF/lib/jdbc) and 
>> modify the start-up script to include these jar on the CLASSPATH?
>
>NEVER, NEVER, NEVER set CLASSPATH for use with Tomcat.

Although I know this to be a bad idea; I've seen many post telling
users NOT to change the CP, however I want to be able to justify why 
this shouldn't be done (convince ops folks). Do you know of any
documented discussion (the classpath how-to doesn't seem to address
this).

Thanks,

Florian


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

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


This communication is the property of Qwest and may contain confidential or
privileged information. Unauthorized use of this communication is strictly 
prohibited and may be unlawful.  If you have received this communication 
in error, please immediately notify the sender by reply e-mail and destroy 
all copies of the communication and any attachments.

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


RE: JDBC driver JARs in a shared production environment

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Kirchhoff, Florian [mailto:Florian.Kirchhoff@qwest.com] 
> Subject: JDBC driver JARs in a shared production environment
> 
> Question: if you cannot place the JDBC driver jars in
> CATALINA_HOME/commons/lib, where can you put them?
> 
> 1) Place the JDBC jars in $CATALINA_BASE/jdbc and modify the start-up
> script to include these jars on the CLASSPATH?
> 2) Deploy the JDBC jars in the WAR file (e.g. WEB-INF/lib/jdbc) and
> modify the start-up script to include these jar on the CLASSPATH?

NEVER, NEVER, NEVER set CLASSPATH for use with Tomcat.

> 3) Deploy the JDBC jars and commons-dbcp.jar in the WAR in 
> WEB-INF/lib?

Yes.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

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