You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sai Reddy <du...@gmail.com> on 2008/01/22 19:39:50 UTC
Why should we keep
Hi Friends,
I'm using Struts 1.2.7, Tomcat 5.5.25. I'm trying to create a datasource for
my struts application.
This is my struts-config.xml file
########################################################################
<struts-config>
<data-sources>
<data-source type="org.apache.tomcat.dbcp.dbcp.BasicDataSource">
<set-property property="driverClassName"
value="com.mysql.jdbc.Driver" />
<set-property property="url"
value="jdbc:mysql://localhost:3306/test?autoReconnect=true" />
<set-property property="username" value="root" />
<set-property property="password" value="santhosh" />
<set-property property="maxActive" value="10" />
<set-property property="maxWait" value="5000" />
<set-property property="defaultAutoCommit" value="false" />
<set-property property="defaultReadOnly" value="false" />
</data-source>
</data-sources>
.
.
.
.
</struts-config>
########################################################################
When I place "mysql-connector-java-5.0.3-bin.jar" file in "/WEB-INF/lib"
directory, I get an error saying "com.mysql.jdbc.Driver not found". But when
I place "mysql-connector-java-5.0.3-bin.jar" file in
"$CATALINA_HOME/commons/lib" directory, everything works fine!
Why should we must place the .jar file in "$CATALINA_HOME/commons/lib" only
rather than in "/WEB-INF/lib". Why is Tomcat unable to find when I place it
in "/WEB-INF/lib" folder??
D.Sai Reddy
VNR VJIET.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Why should we keep
Posted by Laurie Harper <la...@holoweb.net>.
Also worth mentioning is that configuring data sources in
struts-config.xml has been deprecated for a long, long time. The
preferred way to do it is to configure the data source in your container
and reference it from your Struts app through JNDI. Switching to that
approach should avoid issues like this one.
L.
Alberto A. Flores wrote:
> The "driverClassName" uses reflection to load the driver appropriately,
> so this sounds like a classloading issue. I'm going to guess that you
> are not including the dbcp jar files (you shouldn't be doing this
> anyway), thus the Tomcat classloader is always looking for the jdbc
> driver in the CATALINA/commons/lib (this is where the DBCP jars are
> located by default in Tomcat as per the documentation, see reference).
>
> In general, you want to keep your jdbc drivers maintained by the
> container (and not the application). Depending on the type of
> architecture you have, you may want to reconsider your need to place
> them in WEB-INF/lib to begin with.
>
>
> Reference:
>
> http://fresh.t-systems-sfr.com/unix/www/apache-tomcat-5.5.25.tar.gz:a/apache-tomcat-5.5.25/webapps/tomcat-docs/class-loader-howto.html
>
>
>
> Sai Reddy wrote:
>> Hi Friends,
>> I'm using Struts 1.2.7, Tomcat 5.5.25. I'm trying to create a
>> datasource for
>> my struts application.
>>
>> This is my struts-config.xml file
>>
>> ########################################################################
>> <struts-config>
>> <data-sources>
>> <data-source type="org.apache.tomcat.dbcp.dbcp.BasicDataSource">
>> <set-property property="driverClassName"
>> value="com.mysql.jdbc.Driver" />
>> <set-property property="url"
>>
>> value="jdbc:mysql://localhost:3306/test?autoReconnect=true" />
>> <set-property property="username" value="root" />
>> <set-property property="password" value="santhosh" />
>> <set-property property="maxActive" value="10" />
>> <set-property property="maxWait" value="5000" />
>> <set-property property="defaultAutoCommit" value="false" />
>> <set-property property="defaultReadOnly" value="false" />
>>
>> </data-source>
>> </data-sources> .
>> .
>> .
>> .
>> </struts-config>
>> ########################################################################
>>
>> When I place "mysql-connector-java-5.0.3-bin.jar" file in "/WEB-INF/lib"
>> directory, I get an error saying "com.mysql.jdbc.Driver not found".
>> But when
>> I place "mysql-connector-java-5.0.3-bin.jar" file in
>> "$CATALINA_HOME/commons/lib" directory, everything works fine!
>>
>> Why should we must place the .jar file in "$CATALINA_HOME/commons/lib"
>> only
>> rather than in "/WEB-INF/lib". Why is Tomcat unable to find when I
>> place it
>> in "/WEB-INF/lib" folder??
>>
>> D.Sai Reddy
>> VNR VJIET.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Why should we keep
Posted by "Alberto A. Flores" <aa...@gmail.com>.
The "driverClassName" uses reflection to load the driver appropriately,
so this sounds like a classloading issue. I'm going to guess that you
are not including the dbcp jar files (you shouldn't be doing this
anyway), thus the Tomcat classloader is always looking for the jdbc
driver in the CATALINA/commons/lib (this is where the DBCP jars are
located by default in Tomcat as per the documentation, see reference).
In general, you want to keep your jdbc drivers maintained by the
container (and not the application). Depending on the type of
architecture you have, you may want to reconsider your need to place
them in WEB-INF/lib to begin with.
Reference:
http://fresh.t-systems-sfr.com/unix/www/apache-tomcat-5.5.25.tar.gz:a/apache-tomcat-5.5.25/webapps/tomcat-docs/class-loader-howto.html
Sai Reddy wrote:
> Hi Friends,
> I'm using Struts 1.2.7, Tomcat 5.5.25. I'm trying to create a datasource for
> my struts application.
>
> This is my struts-config.xml file
>
> ########################################################################
> <struts-config>
> <data-sources>
> <data-source type="org.apache.tomcat.dbcp.dbcp.BasicDataSource">
> <set-property property="driverClassName"
> value="com.mysql.jdbc.Driver" />
> <set-property property="url"
> value="jdbc:mysql://localhost:3306/test?autoReconnect=true" />
> <set-property property="username" value="root" />
> <set-property property="password" value="santhosh" />
> <set-property property="maxActive" value="10" />
> <set-property property="maxWait" value="5000" />
> <set-property property="defaultAutoCommit" value="false" />
> <set-property property="defaultReadOnly" value="false" />
>
> </data-source>
> </data-sources>
> .
> .
> .
> .
> </struts-config>
> ########################################################################
>
> When I place "mysql-connector-java-5.0.3-bin.jar" file in "/WEB-INF/lib"
> directory, I get an error saying "com.mysql.jdbc.Driver not found". But when
> I place "mysql-connector-java-5.0.3-bin.jar" file in
> "$CATALINA_HOME/commons/lib" directory, everything works fine!
>
> Why should we must place the .jar file in "$CATALINA_HOME/commons/lib" only
> rather than in "/WEB-INF/lib". Why is Tomcat unable to find when I place it
> in "/WEB-INF/lib" folder??
>
> D.Sai Reddy
> VNR VJIET.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
Alberto A. Flores
http://www.linkedin.com/in/aflores