You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Patrick Gelin <pa...@rpn.ch> on 2005/07/11 10:38:16 UTC
How to create a MySQL datasource (DBCP) into TOMCAT 4.1.31...
Hi,
I succeded to create a datasource for TOMCAT 5.5.7 and 5.5.9 but I have to
deploy my webapp into TOMCAT 4.1.31 and it's not the same configuration
parameters...
It seems to be all right but if I debug with Eclipse IDE my DataSource is
null...
I followed TOMCAT 4.1 JNDI DataSource how-to documentation, so now I really
need your help...:
1. I copied mysql-connector-java-3.1.10-bin.jar to [TOMCAT]/common/lib
2. This is my server.xml conf file:
////////////////////////////////////////////////////////////////////
(...)
<Context path="/webapp_newsevent" docBase="webapp_newsevent"
debug="5" reloadable="true" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="rpn_database_log." suffix=".txt"
timestamp="true"/>
<Resource name="jdbc/rpn_database"
auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/rpn_database">
<parameter>
<name>factory</name>
<value>org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory</value>
</parameter>
<!-- Maximum number of dB connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
all of your db connections. Set to 0 for no limit.
-->
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
<!-- Maximum number of idle dB connections to retain in pool.
Set to 0 for no limit.
-->
<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>
<!-- Maximum time to wait for a dB connection to become available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded. Set to -1 to wait indefinitely.
-->
<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>
<!-- MySQL dB username and password for dB connections -->
<parameter>
<name>username</name>
<value>root</value>
</parameter>
<parameter>
<name>password</name>
<value>#####</value>
</parameter>
<!-- Class name for mm.mysql JDBC driver -->
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<!-- The JDBC connection url for connecting to your MySQL dB.
The autoReconnect=true argument to the url makes sure that the
mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
connection. mysqld by default closes idle connections after 8 hours.
-->
<parameter>
<name>url</name>
<value>jdbc:mysql://www.rpn.ch:3306/rpn?autoReconnect=true</value>
</parameter>
</ResourceParams>
</Context>
</Host>
</Engine>
</Service>
</Server>
////////////////////////////////////////////////////////////////////
3. This is my webapp_newsevent/WEB-INF/web.xml
////////////////////////////////////////////////////////////////////
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>j2EE news and events for RPN</display-name>
(...)
<welcome-file-list>
<welcome-file>CollectionView</welcome-file>
</welcome-file-list>
<resource-ref>
<description>RPN DataBase</description>
<res-ref-name>jdbc/rpn_database</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<security-role>
<role-name>moderator</role-name>
</security-role>
</web-app>
////////////////////////////////////////////////////////////////////
This is my rpn_database_log.txt file
////////////////////////////////////////////////////////////////////
(...)
2005-07-08 11:06:52 StandardContext[/webapp_newsevent]: Starting
2005-07-08 11:06:52 StandardContext[/webapp_newsevent]: Processing start(),
current available=false
2005-07-08 11:06:52 StandardContext[/webapp_newsevent]: Configuring default
Resources
2005-07-08 11:06:52 StandardContext[/webapp_newsevent]: Configuring
non-privileged default Loader
2005-07-08 11:06:52 StandardContext[/webapp_newsevent]: Configuring default
Manager
2005-07-08 11:06:52 StandardContext[/webapp_newsevent]: Processing standard
container startup
2005-07-08 11:06:52 WebappLoader[/webapp_newsevent]: Deploying class
repositories to work
directory /opt/jahia4.1.0_01_b6070/tomcat/work/Standalone/localhost/webapp_newsevent
2005-07-08 11:06:52 WebappLoader[/webapp_newsevent]: Deploy class
files /WEB-INF/classes
to /opt/jahia4.1.0_01_b6070/tomcat/webapps/webapp_newsevent/WEB-INF/classes
2005-07-08 11:06:52 WebappLoader[/webapp_newsevent]: Deploy
JAR /WEB-INF/lib/displaytag-1.0.jar
to /opt/jahia4.1.0_01_b6070/tomcat/webapps/webapp_newsevent/WEB-INF/lib/displaytag-1.0.jar
2005-07-08 11:06:52 WebappLoader[/webapp_newsevent]: Reloading checks are
enabled for this Context
2005-07-08 11:06:52 ContextConfig[/webapp_newsevent]: "ContextConfig":
Traitement du "START"
2005-07-08 11:06:52 StandardContext[/webapp_newsevent]: Setting deployment
descriptor public ID to '-//Sun Microsystems, Inc.//DTD Web Application
2.3//EN'
2005-07-08 11:06:53 StandardContext[/webapp_newsevent]: Setting deployment
descriptor public ID to '-//Sun Microsystems, Inc.//DTD Web Application
2.3//EN'
2005-07-08 11:06:54 ContextConfig[/webapp_newsevent]: Accumulating TLD
resource paths
2005-07-08 11:06:54 ContextConfig[/webapp_newsevent]: Scanning <taglib>
elements in web.xml
2005-07-08 11:06:54 ContextConfig[/webapp_newsevent]: Scanning TLDs
in /WEB-INF subdirectory
2005-07-08 11:06:54 ContextConfig[/webapp_newsevent]: Scanning JARs
in /WEB-INF/lib subdirectory
2005-07-08 11:06:54 ContextConfig[/webapp_newsevent]: Adding path
'/WEB-INF/lib/displaytag-1.0.jar'
2005-07-08 11:06:54 ContextConfig[/webapp_newsevent]: Scanning JAR at
resource path '/WEB-INF/lib/displaytag-1.0.jar'
2005-07-08 11:06:54 ContextConfig[/webapp_newsevent]: Processing TLD at
'META-INF/displaytag-11.tld'
2005-07-08 11:06:54 ContextConfig[/webapp_newsevent]: Processing TLD at
'META-INF/displaytag-12.tld'
2005-07-08 11:06:54 ContextConfig[/webapp_newsevent]: Processing TLD at
'META-INF/displaytag-el-12.tld'
2005-07-08 11:06:55 ContextConfig[/webapp_newsevent]: Pipline Configuration:
2005-07-08 11:06:55 ContextConfig[/webapp_newsevent]:
org.apache.catalina.core.StandardContextValve/1.0
2005-07-08 11:06:55 ContextConfig[/webapp_newsevent]: ======================
2005-07-08 11:06:55
NamingContextListener[/Standalone/localhost/webapp_newsevent]: Creating
JNDI naming context
2005-07-08 11:06:55
NamingContextListener[/Standalone/localhost/webapp_newsevent]: Resource
parameters for jdbc/rpn_database = ResourceParams[name=jdbc/rpn_database,
parameters={url=jdbc:mysql://www.rpn.ch:3306/rpn?autoReconnect=true,
validationQuery=select 1, maxIdle=30, maxActive=100,
driverClassName=com.mysql.jdbc.Driver, maxWait=10000, username=root,
factory=org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory,
password=mybd07}]
2005-07-08 11:06:55
NamingContextListener[/Standalone/localhost/webapp_newsevent]: Adding
resource ref jdbc/rpn_database
2005-07-08 11:06:55
NamingContextListener[/Standalone/localhost/webapp_newsevent]:
ResourceRef[className=javax.sql.DataSource,factoryClassLocation=null,factoryClassName=org.apache.naming.factory.ResourceFactory
{type=scope,content=Shareable},{type=auth,content=Container}
{type=url,content=jdbc:mysql://www.rpn.ch:3306/rpn?autoReconnect=true}
{type=validationQuery,content=select 1},{type=maxIdle,content=30}
{type=maxActive,content=100}
{type=driverClassName,content=com.mysql.jdbc.Driver}
{type=maxWait,content=10000},{type=username,content=root}
{type=factory,content=org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory}
{type=password,content=mybd07}]
2005-07-08 11:06:55
NamingContextListener[/Standalone/localhost/webapp_newsevent]: Resource
parameters for UserTransaction = null
2005-07-08 11:06:55 StandardManager[/webapp_newsevent]: Alimentation de la
classe du générateur de nombre aléatoire java.security.SecureRandom
2005-07-08 11:06:55 StandardManager[/webapp_newsevent]: L'alimentation du
générateur de nombre aléatoire est terminé
2005-07-08 11:06:55 StandardContext[/webapp_newsevent]: Posting standard
context attributes
2005-07-08 11:06:55 StandardContext[/webapp_newsevent]: Configuring
application event listeners
2005-07-08 11:06:55 StandardContext[/webapp_newsevent]: Sending application
start events
2005-07-08 11:06:55 StandardContext[/webapp_newsevent]: Starting filters
2005-07-08 11:06:55 StandardContext[/webapp_newsevent]: Starting completed
2005-07-08 11:06:55 StandardWrapper[/webapp_newsevent:default]: Chargement
du conteneur (container) de servlet default
2005-07-08 11:06:55 StandardWrapper[/webapp_newsevent:invoker]: Chargement
du conteneur (container) de servlet invoker
2005-07-08 11:10:56 StandardContext[/webapp_newsevent]: Mapping
contextPath='/webapp_newsevent' with requestURI='/webapp_newsevent' and
relativeURI=''
2005-07-08 11:10:56 StandardContext[/webapp_newsevent]: Trying exact match
2005-07-08 11:10:56 StandardContext[/webapp_newsevent]: Trying prefix
match
2005-07-08 11:10:56 StandardContext[/webapp_newsevent]: Trying extension
match
2005-07-08 11:10:56 StandardContext[/webapp_newsevent]: Trying default
match
2005-07-08 11:10:56 StandardContext[/webapp_newsevent]: Mapped to servlet
'default' with servlet path '' and path info 'null' and update=true
2005-07-08 11:10:56 StandardContext[/webapp_newsevent]: Mapping
contextPath='/webapp_newsevent' with requestURI='/webapp_newsevent/' and
relativeURI='/'
2005-07-08 11:10:56 StandardContext[/webapp_newsevent]: Trying exact match
2005-07-08 11:10:56 StandardContext[/webapp_newsevent]: Trying prefix
match
2005-07-08 11:10:56 StandardContext[/webapp_newsevent]: Trying extension
match
2005-07-08 11:10:56 StandardContext[/webapp_newsevent]: Trying default
match
2005-07-08 11:10:56 StandardContext[/webapp_newsevent]: Mapped to servlet
'default' with servlet path '/' and path info 'null' and update=true
2005-07-08 11:11:04 StandardContext[/webapp_newsevent]: Mapping
contextPath='/webapp_newsevent' with
requestURI='/webapp_newsevent/CollectionCtrl/CollectionView' and
relativeURI='/CollectionCtrl/CollectionView'
2005-07-08 11:11:04 StandardContext[/webapp_newsevent]: Trying exact match
2005-07-08 11:11:04 StandardContext[/webapp_newsevent]: Trying prefix
match
2005-07-08 11:11:04 StandardContext[/webapp_newsevent]: Mapped to servlet
'CollectionCtrl' with servlet path '/CollectionCtrl' and path info
'/CollectionView' and update=true
2005-07-08 11:11:20 CollectionCtrl: Exception in ElmtCtrl.doGet()
2005-07-08 11:11:20 CollectionCtrl: Exception in CollectionCtrl.doGet()
////////////////////////////////////////////////////////////////////
And this is my catalina.out:
////////////////////////////////////////////////////////////////////
Listening for transport dt_socket at address: 8000
8 juil. 2005 11:06:50 org.apache.coyote.http11.Http11Protocol init
INFO: Initialisation de Coyote HTTP/1.1 sur http-8080
Démarrage du service Tomcat-Standalone
Apache Tomcat/4.1.31
8 juil. 2005 11:07:00 org.apache.struts.util.PropertyMessageResources <init>
INFO: Initializing, config='org.apache.struts.util.LocalStrings',
returnNull=true
8 juil. 2005 11:07:00 org.apache.struts.util.PropertyMessageResources <init>
INFO: Initializing, config='org.apache.struts.action.ActionResources',
returnNull=true
8 juil. 2005 11:07:01 org.apache.struts.util.PropertyMessageResources <init>
INFO: Initializing, config='org.apache.webapp.admin.ApplicationResources',
returnNull=true
____.
__/\ ______| |__/\. _______
__ .____| | \ | +----+ \
_______| /--| | | - \ _ | : - \_________
\\______: :---| : : | : | \________>
|__\---\_____________:______: :____|____:_____\
/_____|
. . . s t a r t i n g j a h i a b u i l d 6 0 7 0 . . .
Copyright 2002-2005 - jahia http://www.jahia.org - all rights reserved
**************************************************************************
* The contents of this file, or the files included with this file, are *
* subject to the current version of JAHIA Community Source License for *
* the Jahia Portal Server (the "License"); You may not use this file *
* except in compliance with the License. You may obtain a copy of the *
* License at http://www.jahia.org. See the License for the rights, *
* obligations and limitations governing use of the contents of the file. *
* The Original and Upgraded Code is the Jahia Portal Server. The *
* developer of the Original and Upgraded Code is JAHIA Ltd. JAHIA Ltd. *
* owns the copyrights in the portions it created. All Rights Reserved. *
**************************************************************************
8 juil. 2005 11:07:24 org.apache.coyote.http11.Http11Protocol start
INFO: Démarrage de Coyote HTTP/1.1 sur http-8080
8 juil. 2005 11:07:24 org.apache.jk.common.ChannelSocket init
INFO: JK2: ajp13 listening on /0.0.0.0:8009
8 juil. 2005 11:07:24 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/137
config=/opt/jahia4.1.0_01_b6070/tomcat/conf/jk2.properties
Listening for transport dt_socket at address: 8000
////////////////////////////////////////////////////////////////////
Any help is welcome...
Thanks.
--
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: How to create a MySQL datasource (DBCP) into TOMCAT 4.1.31...
Posted by Hassan Schroeder <ha...@webtuitive.com>.
Patrick Gelin wrote:
> I succeded to create a datasource for TOMCAT 5.5.7 and 5.5.9 but I have to
> deploy my webapp into TOMCAT 4.1.31 and it's not the same configuration
> parameters...
> 2. This is my server.xml conf file:
> <ResourceParams name="jdbc/rpn_database">
> <parameter>
> <name>factory</name>
> <value>org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory</value>
> </parameter>
I believe that's 5.5.x-specific -- commons-dbcp contains:
org.apache.tomcat.dbcp.BasicDataSourceFactory
:: (note only one '.dbcp'). Change that, make sure commons-dbcp is
in your 4.1.31 $CATALINA_HOME/common/lib and give it a try.
HTH!
--
Hassan Schroeder ----------------------------- hassan@webtuitive.com
Webtuitive Design === (+1) 408-938-0567 === http://webtuitive.com
dream. code.
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org