I'm using Tomcat 6.0. I found the solution by the way. I executed the
following steps:
1. I created a DataSource (I hope I have the language correct): In META-INF
I added a context.xml, as adding this DataSource to
%TOMCAT_HOME%/conf/server.xml is not the way to go (Changes in the code
would lead to having to restart Tomcat). The context file contained the
following entry:
<Context path="/app15a" docBase="app15a" reloadable="true" debug="8">
<Loader checkInterval="7" reloadable="true"/>
<Resource name="jdbc/myDataSource" auth="Container"
type="javax.sql.DataSource"
factory="org.apache.commons.dbcp.BasicDataSourceFactory" maxActive="100"
maxIdle="30" maxWait="10000" username="root" password=""
driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/test"/>
</Context>
2. I copied a mysql-connector-java-5.1.5-bin.jar to my %TOMCAT_HOME%/lib 
3. I copied commons-dbcp-1.2.2.jar en commons-pool-1.3.jar files to the same
directory (ad I think more applications would benefit from these "Common"
files I preferred to have them in %TOMCAT_HOME%/lib, instead of the apps
lib.)

So the ResourceParams is now indeed part of the Resource element. 

Don't you love learning how it should work from an "old" book. But that is
the risk I run when I buy myself a book and next install software that is
new compared to the the book. I just saw a new version covering Struts 2.0
will come out in March this year. Hopefully I will be knowledgeable enough
at that time not needing that book to learn about 2.0 (only to reference
it).


David Smith-2 wrote:
> 
> ResourceParams doesn't exist in tomcat 5.5, 6.0.  All those parameters 
> became attributes of the <Resource .../> element.  What version of 
> tomcat are you using Abel?
> 
> --David
> 
> Mariano wrote:
> 
>>First of all if you are working with tomcat 5.5 you have to put your jdbc
>>library file in TOMCAT_HOME/common/lib but if you are using Tomcat 6.0 you
>>have to put files in TOMCAT_HOME/lib.
>>
>>I think that ResourceParams is nested to Resource and you have it out of
>>Resource.
>>
>>You must follow guidelines in
>>http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html
>>to create DBCP.
>>
>>I hope this help you.
>>
>>Mariano
>>
>>-----Mensaje original-----
>>De: AbelMacAdam [mailto:[EMAIL PROTECTED]
>>Enviado el: miercoles, 02 de enero de 2008 14:05
>>Para: users@tomcat.apache.org
>>Asunto: NamingException
>>
>>
>>
>>I have a piece of code that should get me a dataSource (from an example
I'm
>>playing with from a Struts book):
>>[code]
>>    try {
>>      logger.info("DAOBase.getConnection: ====== InitialContext ======");
>>      context = new InitialContext();
>>      logger.info("DAOBase.getConnection: ====== context.lookup  ======");
>>      dataSource = (DataSource)
>>context.lookup("java:/comp/env/jdbc/myDataSource");
>>    }
>>    catch (NamingException e) {
>>      logger.info("DAOBase.getConnection: ====== NamingException ======",
>>e.fillInStackTrace());
>>      throw new DAOException();
>>    }
>>[/code]
>>
>>This is a piece of my logging:
>>[logging]
>>13:04:33,449 INFO  app15a.action.CreateCustomerAction - AMc: ++++++
>>getConnection ++++++++
>>13:04:33,449 INFO  app15a.action.CreateCustomerAction -
>>DAOBase.getConnection: ====== InitialContext ======
>>13:04:33,449 INFO  app15a.action.CreateCustomerAction -
>>DAOBase.getConnection: ====== context.lookup  ======
>>13:04:33,449 INFO  app15a.action.CreateCustomerAction -
>>DAOBase.getConnection: ====== NamingException ======
>>javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
>>      at app15a.dao.DAOBase.getConnection(DAOBase.java:34)
>>      at
>>app15a.dao.CustomerDAOMySQLImpl.createCustomer(CustomerDAOMySQLImpl.java:44)
>>      at
app15a.action.CreateCustomerAction.execute(CreateCustomerAction.java:44)
>>      at
>>org.apache.struts.action.RequestProcessor.processActionPerform(RequestProces
>>sor.java:421)
>>      at
>>org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
>>      at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
>>      at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
>>      at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
>>      at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>      at
>>org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
>>FilterChain.java:290)
>>      at
>>org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
>>ain.java:206)
>>      at
>>org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
>>va:233)
>>      at
>>org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
>>va:175)
>>      at
>>org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128
>>)
>>      at
>>org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102
>>)
>>      at
>>org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
>>:109)
>>      at
>>org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
>>      at
>>org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:
>>852)
>>      at
>>org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(H
>>ttp11AprProtocol.java:584)
>>      at
org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1508)
>>      at java.lang.Thread.run(Unknown Source)
>>[/logging]
>>
>>As you might have noticed, I'm fairly new to this part of the
neighborhood.
>>What should I do to remove this error?
>>
>>I was advised to put the JDBC driver in the common/lib directory of my
>>TOMCAT_HOME. I don't have a common directory. I do have a TOMCAT_HOME/lib
>>directory. Am I correct in assuming I put my driver in that directory?
>>
>>I also added the following Context element to my
>>TOMCAT_HOME/conf/server.xml:
>>[code]
>>    <!-- AMc: 02/01/2008: MySQL DataSource Object -->
>>    <Context path="/app15a" docBase="app15a" reloadable="true" debug="8">
>>        <Loader checkInterval="7" reloadable="true" />
>>        <Resource name="jdbc/myDataSource" auth="Container"
>>type="javax.sql.DataSource" />
>>        <ResourceParams name="jdbc/myDataSource">
>>            <parameter>
>>                <name>factory</name>
>>
>><value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
>>            </parameter>
>>            <parameter>
>>                <name>maxActive</name>
>>                <value>100</value>
>>            </parameter>
>>            <parameter>
>>                <name>maxWait</name>
>>                <value>10000</value>
>>            </parameter>
>>            <parameter>
>>                <name>username</name>
>>                <value>root</value>
>>            </parameter>
>>            <parameter>
>>                <name>password</name>
>>                <value></value>
>>            </parameter>
>>            <parameter>
>>                <name>driverClass</name>
>>                <value>com.mysql.jdbc.Driver</value>
>>            </parameter>
>>            <parameter>
>>                <name>url</name>
>>                <value>jdbc:mysql://localhost/test</value>
>>            </parameter>
>>        </ResourceParams>
>>    </Context>
>>  </Service>
>></Server>
>>[/code]
>>Am I correct in assuming this piece of code does not contain a reference
to
>>my JDBC driver?
>>
>>Any help would be appreciated, as I do not see what else I can do.
>>
>>TIA,
>>Abel
>>--
>>View this message in context:
>>http://www.nabble.com/NamingException-tp14578063p14578063.html
>>Sent from the Tomcat - User mailing list archive at Nabble.com.
>>
>>
>>---------------------------------------------------------------------
>>To start a new topic, e-mail: users@tomcat.apache.org
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>---------------------------------------------------------------------
>>To start a new topic, e-mail: users@tomcat.apache.org
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>  
>>
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/NamingException-tp14578063p14598133.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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

Reply via email to