Re: Struggling with basic database connection
Alan, Did you ever resolve this? I don't have enough information here to help you. Thanks, John Najarian --- Alan Chandler [EMAIL PROTECTED] wrote: On Saturday 23 September 2006 15:23, David Smith wrote: Correction: context.xml belongs in META-INF of the war archive. I have just conducted experiments with Tomcat 5.0 putting a context.xml file in META-INF doesn't appear to work I have not been having success with putting in conf/server.xml - but I have had success with putting the context in conf/Catalina/localhost/akcmoney.xml -- Alan Chandler http://www.chandlerfamily.org.uk - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.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]
Re: Struggling with basic database connection
On Sunday 01 October 2006 17:27, John Najarian wrote: Alan, Did you ever resolve this? I don't have enough information here to help you. ... Sort of ... The WTP plugin for eclipse copies what is in META-INF/context.xml and writes it into CATALINA_BASE/conf/server.xml. So for tomcat5.0, I have relied on testing/debuging like that so far, and achieving the same manually when I come to deploy on the production server. At some stage soon, I will be changing to tomcat 5.5 but I am not sure where to go to make things work then, as I am still not sure there is any definitive guide to where these things go and how tomcat deals with a META-INF/context.xml --- Alan Chandler [EMAIL PROTECTED] wrote: On Saturday 23 September 2006 15:23, David Smith wrote: Correction: context.xml belongs in META-INF of the war archive. I have just conducted experiments with Tomcat 5.0 putting a context.xml file in META-INF doesn't appear to work I have not been having success with putting in conf/server.xml - but I have had success with putting the context in conf/Catalina/localhost/akcmoney.xml -- Alan Chandler http://www.chandlerfamily.org.uk - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.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] -- Alan Chandler http://www.chandlerfamily.org.uk - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struggling with basic database connection
Alan- context.xml identified Naming and Session management items more info available at http://tomcat.apache.org/tomcat-5.0-doc/deployer-howto.html HTH Martin -- * This email message and any files transmitted with it contain confidential information intended only for the person(s) to whom this email message is addressed. If you have received this email message in error, please notify the sender immediately by telephone or email and destroy the original message without making a copy. Thank you. - Original Message - From: Alan Chandler [EMAIL PROTECTED] To: users@tomcat.apache.org Sent: Sunday, October 01, 2006 1:42 PM Subject: Re: Struggling with basic database connection On Sunday 01 October 2006 17:27, John Najarian wrote: Alan, Did you ever resolve this? I don't have enough information here to help you. ... Sort of ... The WTP plugin for eclipse copies what is in META-INF/context.xml and writes it into CATALINA_BASE/conf/server.xml. So for tomcat5.0, I have relied on testing/debuging like that so far, and achieving the same manually when I come to deploy on the production server. At some stage soon, I will be changing to tomcat 5.5 but I am not sure where to go to make things work then, as I am still not sure there is any definitive guide to where these things go and how tomcat deals with a META-INF/context.xml --- Alan Chandler [EMAIL PROTECTED] wrote: On Saturday 23 September 2006 15:23, David Smith wrote: Correction: context.xml belongs in META-INF of the war archive. I have just conducted experiments with Tomcat 5.0 putting a context.xml file in META-INF doesn't appear to work I have not been having success with putting in conf/server.xml - but I have had success with putting the context in conf/Catalina/localhost/akcmoney.xml -- Alan Chandler http://www.chandlerfamily.org.uk - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.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] -- Alan Chandler http://www.chandlerfamily.org.uk - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struggling with basic database connection
On Saturday 23 September 2006 15:23, David Smith wrote: Correction: context.xml belongs in META-INF of the war archive. I have just conducted experiments with Tomcat 5.0 putting a context.xml file in META-INF doesn't appear to work I have not been having success with putting in conf/server.xml - but I have had success with putting the context in conf/Catalina/localhost/akcmoney.xml -- Alan Chandler http://www.chandlerfamily.org.uk - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Struggling with basic database connection
I am struggling to figure out why my Tomcat installation is failing to allow me to connect my java web application to a database. I am looking for ideas as to how to find out what is wrong. I have (what I think) is the same setup on another machine and it works fine. The only difference between these is that the working one in tomcat 5.0 and this machine is tomcat 5.5 (although I am just about and try with a 5.0 setup). I am trying with this simple piece of code - plucked from the tomcat docs. Context initCtx; try { initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup(java:comp/env); DataSource ds = (DataSource) envCtx.lookup(jdbc/akcmoney); Connection conn = ds.getConnection(); } catch (Exception e1) { e1.printStackTrace(); } and with debug, I can see that initCtX, envCtx and ds all are assigned non null values, but the ds.getConnection() results in the following. org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' I have the postgresql jdbc driver jar in $CATALINA.BASE/common/lib Server.xml contains Context docBase=akcmoney path=/akcmoney reloadable=true source=org.eclipse.jst.j2ee.server:akcmoney Resource auth=Container name=jdbc/akcmoney type=javax.sql.DataSource/ ResourceParams name=jdbc/akcmoney parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namedriverClassName/name valueorg.postgresql.Driver/value /parameter parameter nameurl/name valuejdbc:postgresql://127.0.0.1:5432/akcmoney/value /parameter parameter nameusername/name valuetomcat4/value /parameter parameter namepassword/name valuexxx/value /parameter parameter namemaxActive/name value20/value /parameter parameter namemaxIdle/name value10/value /parameter parameter namemaxWait/name value-1/value /parameter /ResourceParams /Context my WEB-INF/web.xml contains this reference. resource-ref descriptionAKCMoney Database/description res-ref-namejdbc/akcmoney/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth res-sharing-scopeShareable/res-sharing-scope /resource-ref Anyone any ideas where I am going wrong, or how to look at the contents of the nitCtX, envCtx and ds variables in the above code snippet to understand how far I have got -- Alan Chandler http://www.chandlerfamily.org.uk - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struggling with basic database connection
Hello, there is a difference between how resources are defined in 5.0 and 5.5. In 5.0 you could provide your resource definitions right in the server.xml, but in 5.5 you need to create a separate context.xml file ($CATALINA_HOME/conf/Catalina/hostname/context.xml) and put resource definitions there. See this link: http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html I also had this problem when migrating from 5.0 to 5.5. After I defined a separate context.xml it started to work again. Regards, -- Andrew Stepanenko, http://unf.tane.edu.ua On 9/23/06, Alan Chandler [EMAIL PROTECTED] wrote: I am struggling to figure out why my Tomcat installation is failing to allow me to connect my java web application to a database. I am looking for ideas as to how to find out what is wrong. I have (what I think) is the same setup on another machine and it works fine. The only difference between these is that the working one in tomcat 5.0 and this machine is tomcat 5.5 (although I am just about and try with a 5.0 setup). I am trying with this simple piece of code - plucked from the tomcat docs. Context initCtx; try { initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup(java:comp/env); DataSource ds = (DataSource) envCtx.lookup(jdbc/akcmoney); Connection conn = ds.getConnection(); } catch (Exception e1) { e1.printStackTrace(); } and with debug, I can see that initCtX, envCtx and ds all are assigned non null values, but the ds.getConnection() results in the following. org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' I have the postgresql jdbc driver jar in $CATALINA.BASE/common/lib Server.xml contains Context docBase=akcmoney path=/akcmoney reloadable=true source=org.eclipse.jst.j2ee.server:akcmoney Resource auth=Container name=jdbc/akcmoney type=javax.sql.DataSource/ ResourceParams name=jdbc/akcmoney parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namedriverClassName/name valueorg.postgresql.Driver/value /parameter parameter nameurl/name valuejdbc:postgresql://127.0.0.1:5432/akcmoney/value /parameter parameter nameusername/name valuetomcat4/value /parameter parameter namepassword/name valuexxx/value /parameter parameter namemaxActive/name value20/value /parameter parameter namemaxIdle/name value10/value /parameter parameter namemaxWait/name value-1/value /parameter /ResourceParams /Context my WEB-INF/web.xml contains this reference. resource-ref descriptionAKCMoney Database/description res-ref-namejdbc/akcmoney/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth res-sharing-scopeShareable/res-sharing-scope /resource-ref Anyone any ideas where I am going wrong, or how to look at the contents of the nitCtX, envCtx and ds variables in the above code snippet to understand how far I have got -- Alan Chandler http://www.chandlerfamily.org.uk - 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]
Re: Struggling with basic database connection
On Saturday 23 September 2006 09:57, Andrew Stepanenko wrote: Hello, there is a difference between how resources are defined in 5.0 and 5.5. In 5.0 you could provide your resource definitions right in the server.xml, but in 5.5 you need to create a separate context.xml file ($CATALINA_HOME/conf/Catalina/hostname/context.xml) and put resource definitions there. See this link: http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html I also had this problem when migrating from 5.0 to 5.5. After I defined a separate context.xml it started to work again. The docs seem very vague on this issue, but it does imply that I could still use $CATALINA_HOME/conf/server.xml One question that isn't answered in the docs is what the root element should be - the best seems to be the example for accessing a database, and even there it puts Context ... I tried with context.xml in the directory you mentioned and it said it couldn't find the webapp context, so I renamed it to my application and tried again. But it didn't work. So still stumped -- Alan Chandler http://www.chandlerfamily.org.uk - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struggling with basic database connection
Hello, looks like the docs I gave a link to describe the old approach, sorry. Here is what I have in my context.xml: ## !-- The contents of this file will be loaded for each web application -- Context path= docBase=/export/home/andrews/dev/unfas/web debug=1 reloadable=true !-- Default set of monitored resources -- WatchedResourceWEB-INF/web.xml/WatchedResource Resource name=jdbc/unfasHB auth=Container scope=Shareable type=javax.sql.DataSource factory=org.apache.commons.dbcp.BasicDataSourceFactory url=jdbc:mysql://localhost:3306/unfas?useUnicode=trueamp;characterEncoding=UTF-8amp;characterSetResults=UTF-8 driverClassName=com.mysql.jdbc.Driver username=andrews password=xxx maxIdle=5 maxActive=50 autoReconnect=true / /Context # also, the format of Resource has been changed. Now, all configuration data should be provided as attributes and not nested tags. Regards, Andrew Stepanenko, http://unf.tane.edu.ua On 9/23/06, Alan Chandler [EMAIL PROTECTED] wrote: On Saturday 23 September 2006 09:57, Andrew Stepanenko wrote: Hello, there is a difference between how resources are defined in 5.0 and 5.5. In 5.0 you could provide your resource definitions right in the server.xml, but in 5.5 you need to create a separate context.xml file ($CATALINA_HOME/conf/Catalina/hostname/context.xml) and put resource definitions there. See this link: http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html I also had this problem when migrating from 5.0 to 5.5. After I defined a separate context.xml it started to work again. The docs seem very vague on this issue, but it does imply that I could still use $CATALINA_HOME/conf/server.xml One question that isn't answered in the docs is what the root element should be - the best seems to be the example for accessing a database, and even there it puts Context ... I tried with context.xml in the directory you mentioned and it said it couldn't find the webapp context, so I renamed it to my application and tried again. But it didn't work. So still stumped -- Alan Chandler http://www.chandlerfamily.org.uk - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Andrew Stepanenko, Ph.D. student, Dept. of Information Computing Systems and Control, Web: http://www.tanet.edu.te.ua/icsc/ Software engineer, Ukrainian-Dutch Faculty of Economics and Management Ternopil State Economic University Shevchenko Street 9, Office 24-25 Ternopil, 46000 UKRAINE Tel: +38 (0352) 43 52 41 fax: +38 (0352) 43 52 45 Web: http://unf.tane.edu.ua - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struggling with basic database connection
Correction: context.xml belongs in META-INF of the war archive. --David Henry McClain wrote: There are two pieces of information about the Context file while deploying your application as a WAR that the Tomcat documentation fails to make absolutely clear: 1) the Context file name must be context.xml; do not attempt to name it anything else. 2) put the file in the /WEB-INF folder of the WAR The file will be extracted and the name changed automatically by the Tomcat engine. Other than that, what Mr. Stepanenko gave you is relatively identical to what I have in my Context file. H On 9/23/06, Andrew Stepanenko [EMAIL PROTECTED] wrote: Hello, looks like the docs I gave a link to describe the old approach, sorry. Here is what I have in my context.xml: ## !-- The contents of this file will be loaded for each web application -- Context path= docBase=/export/home/andrews/dev/unfas/web debug=1 reloadable=true !-- Default set of monitored resources -- WatchedResourceWEB-INF/web.xml/WatchedResource Resource name=jdbc/unfasHB auth=Container scope=Shareable type=javax.sql.DataSource factory=org.apache.commons.dbcp.BasicDataSourceFactory url=jdbc:mysql://localhost:3306/unfas?useUnicode=trueamp;characterEncoding=UTF-8amp;characterSetResults=UTF-8 driverClassName=com.mysql.jdbc.Driver username=andrews password=xxx maxIdle=5 maxActive=50 autoReconnect=true / /Context # also, the format of Resource has been changed. Now, all configuration data should be provided as attributes and not nested tags. Regards, Andrew Stepanenko, http://unf.tane.edu.ua On 9/23/06, Alan Chandler [EMAIL PROTECTED] wrote: On Saturday 23 September 2006 09:57, Andrew Stepanenko wrote: Hello, there is a difference between how resources are defined in 5.0 and 5.5. In 5.0 you could provide your resource definitions right in the server.xml, but in 5.5 you need to create a separate context.xml file ($CATALINA_HOME/conf/Catalina/hostname/context.xml) and put resource definitions there. See this link: http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html I also had this problem when migrating from 5.0 to 5.5. After I defined a separate context.xml it started to work again. The docs seem very vague on this issue, but it does imply that I could still use $CATALINA_HOME/conf/server.xml One question that isn't answered in the docs is what the root element should be - the best seems to be the example for accessing a database, and even there it puts Context ... I tried with context.xml in the directory you mentioned and it said it couldn't find the webapp context, so I renamed it to my application and tried again. But it didn't work. So still stumped -- Alan Chandler http://www.chandlerfamily.org.uk - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Andrew Stepanenko, Ph.D. student, Dept. of Information Computing Systems and Control, Web: http://www.tanet.edu.te.ua/icsc/ Software engineer, Ukrainian-Dutch Faculty of Economics and Management Ternopil State Economic University Shevchenko Street 9, Office 24-25 Ternopil, 46000 UKRAINE Tel: +38 (0352) 43 52 41 fax: +38 (0352) 43 52 45 Web: http://unf.tane.edu.ua - 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]
Re: Struggling with basic database connection
On Saturday 23 September 2006 15:23, David Smith wrote: Correction: context.xml belongs in META-INF of the war archive. OK, I am begining to comprehend - and knowledge about the context.xml in the META-INF file for a WAR archive is good. I was looking for a way to wrap all the info about the application in one directory structure - for my version control. Does this work with Tomcat 5.0 - thats my current production environment? HOWEVER, in the short term I am not working with WAR files - instead I am trying to deploy the application inside Eclipse. I tried creating a directory etc under eclipse's (probably WTP plugin's) server configuration, but it doesn't publish that to the conf directory inside it's CATALINA_HOME. So still not sure how to proceed. -- Alan Chandler http://www.chandlerfamily.org.uk - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struggling with basic database connection
you may very well be publishing to your own webapp context.xml i.e $TOMCAT_HOME/webapps/YourWebApp/META-INF/context.xml Until you feel comfortable with the reliability of deployment ..in the meanwhile I would create your war by hand (and then let the IDE automate only after you have already established a reliable manual deployment environment) *Most IDE's* support the capability to export build command which will produce a build.xml you can work with this presupposes you have downloaded ANT and set ANT_HOME to the location where you installed Ant M- * This email message and any files transmitted with it contain confidential information intended only for the person(s) to whom this email message is addressed. If you have received this email message in error, please notify the sender immediately by telephone or email and destroy the original message without making a copy. Thank you. - Original Message - From: Alan Chandler [EMAIL PROTECTED] To: users@tomcat.apache.org Sent: Saturday, September 23, 2006 12:48 PM Subject: Re: Struggling with basic database connection On Saturday 23 September 2006 15:23, David Smith wrote: Correction: context.xml belongs in META-INF of the war archive. OK, I am begining to comprehend - and knowledge about the context.xml in the META-INF file for a WAR archive is good. I was looking for a way to wrap all the info about the application in one directory structure - for my version control. Does this work with Tomcat 5.0 - thats my current production environment? HOWEVER, in the short term I am not working with WAR files - instead I am trying to deploy the application inside Eclipse. I tried creating a directory etc under eclipse's (probably WTP plugin's) server configuration, but it doesn't publish that to the conf directory inside it's CATALINA_HOME. So still not sure how to proceed. -- Alan Chandler http://www.chandlerfamily.org.uk - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]