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(RequestProcessor.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(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java: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(Http11AprProtocol.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]