RE: JNDI References To Tomcat 4.1
Thanks, Yoav. I really could not tell what the question was. At 03:27 PM 8/15/2003 -0700, Yoav Shapira wrote: Howdy, I believe he was referring to external access to tomcat's JNDI provider, which is tricky. In-memory is easy and you're right a JDBC resource can be configured (just like any other JNDI resource). Of course, if tomcat's JNDI provider moves into its own jakarta-commons component as we've been discussing, I bet you'd have standalone JNDI very soon ;) Yoav Shapira On Fri, 15 Aug 2003, Micael wrote: This is mistaken, if you mean what you say. There is a JDBC resource available via JNDI in Tomcat. You have to code it, of course, but it definitely is available. At 02:53 PM 8/15/2003 -0500, Madere, Colin wrote: I think your inclinations that Tomcat is not a naming service are correct. I have not seen reference to anything that suggests you can set up resources in Tomcat that are available via JNDI. JBoss, certainly, as it does provide a JNDI server (whatever the appropriate name for that is), as I've used that with JMS/JBossMQ. AFAIK, the Tomcat JNDI setup stuff is just for processes internal to Tomcat, but that is an educated guess, not a known fact :) -Original Message- From: Jason Mowat [mailto:[EMAIL PROTECTED] Sent: Friday, August 15, 2003 12:14 PM To: [EMAIL PROTECTED] Subject: JNDI References To Tomcat 4.1 Greetings, I am trying to create a standalone application that references a DBCP on Tomcat. I'm not sure if I can do this; I've seem some articles that seem to suggest that it can be done, but again, I'm not sure. I've read http://www.mail-archive.com/[EMAIL PROTECTED]/msg08353.html. I have set up in tomcat/conf/server.xml the following context info: DefaultContext Resource name=jdbc/test_db auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/test_db parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namedriverClassName/name valueoracle.jdbc.driver.OracleDriver/value /parameter parameter nameurl/name valuejdbc:oracle:thin:@internal.sbgh.mb.ca:1521:test/value /parameter parameter nameusername/name valuetest/value /parameter parameter namepassword/name valuetest/value /parameter parameter namemaxActive/name value20/value /parameter parameter namemaxIdle/name value3/value /parameter parameter namemaxWait/name value100/value /parameter /ResourceParams /DefaultContext Note that I have not created any references in a web.xml, since I will not be running an application, per se, from Tomcat. PERHAPS THIS IS WHERE MY PROBLEM IS? The client code I am using is not a servlet or a JSP; it's a simple piece of code to see if I can communicate with the database pool on Tomcat as configured above. Hashtable env = new Hashtable(); env.put( Context.INITIAL_CONTEXT_FACTORY, org.apache.commons.dbcp.BasicDataSourceFactory ); // *** THIS IS ANOTHER AREA WHERE I MAY BE WRONG! *** env.put( Context.PROVIDER_URL, http://localhost:8080; ); try { InitialContext initCtx = new InitialContext(env); DataSource ds = (DataSource)initCtx.lookup(java:comp/env/jdbc/test_db); Connection conn = ds.getConnection(); Statement stmt = conn.createStatement(); ResultSet rset = stmt.executeQuery(SELECT * FROM tbl_test); conn.close(); initCtx.close(); } catch(NamingException e) { fail(Naming exception thrown); } catch (SQLException e) { fail(SQL Exception thrown); } I start Tomcat, assuming that the pool is set up. Then I use the client to try to get an initial context from it. This throws a naming exception, because it doesn't know how to get an initial context for org.apache.commons.dbcp.BasicDataSourceFactory at http://localhost:8080. My first question: can I do this? My second question: If I can't do it like this, do I need to set up a JNDI provider (like on JBoss) and set up the pooling there? My final question: It feels as if my problem is simply setting up the PROVIDER_URL properly so that it can get the context from Tomcat. I've done LDAP PROVIDER_URLs before, but never one that gets a data source factory from a servlet container. Can I use http over port 8080 to get the data source factory? Is there a different mechanism for getting the factory from code that is not residing within the servlet container? Can this even be done on Tomcat? I appreciate any help that anyone can provide. Cheers, Jason - To
RE: JNDI References To Tomcat 4.1
I think your inclinations that Tomcat is not a naming service are correct. I have not seen reference to anything that suggests you can set up resources in Tomcat that are available via JNDI. JBoss, certainly, as it does provide a JNDI server (whatever the appropriate name for that is), as I've used that with JMS/JBossMQ. AFAIK, the Tomcat JNDI setup stuff is just for processes internal to Tomcat, but that is an educated guess, not a known fact :) -Original Message- From: Jason Mowat [mailto:[EMAIL PROTECTED] Sent: Friday, August 15, 2003 12:14 PM To: [EMAIL PROTECTED] Subject: JNDI References To Tomcat 4.1 Greetings, I am trying to create a standalone application that references a DBCP on Tomcat. I'm not sure if I can do this; I've seem some articles that seem to suggest that it can be done, but again, I'm not sure. I've read http://www.mail-archive.com/[EMAIL PROTECTED]/msg08353.html. I have set up in tomcat/conf/server.xml the following context info: DefaultContext Resource name=jdbc/test_db auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/test_db parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namedriverClassName/name valueoracle.jdbc.driver.OracleDriver/value /parameter parameter nameurl/name valuejdbc:oracle:thin:@internal.sbgh.mb.ca:1521:test/value /parameter parameter nameusername/name valuetest/value /parameter parameter namepassword/name valuetest/value /parameter parameter namemaxActive/name value20/value /parameter parameter namemaxIdle/name value3/value /parameter parameter namemaxWait/name value100/value /parameter /ResourceParams /DefaultContext Note that I have not created any references in a web.xml, since I will not be running an application, per se, from Tomcat. PERHAPS THIS IS WHERE MY PROBLEM IS? The client code I am using is not a servlet or a JSP; it's a simple piece of code to see if I can communicate with the database pool on Tomcat as configured above. Hashtable env = new Hashtable(); env.put( Context.INITIAL_CONTEXT_FACTORY, org.apache.commons.dbcp.BasicDataSourceFactory ); // *** THIS IS ANOTHER AREA WHERE I MAY BE WRONG! *** env.put( Context.PROVIDER_URL, http://localhost:8080; ); try { InitialContext initCtx = new InitialContext(env); DataSource ds = (DataSource)initCtx.lookup(java:comp/env/jdbc/test_db); Connection conn = ds.getConnection(); Statement stmt = conn.createStatement(); ResultSet rset = stmt.executeQuery(SELECT * FROM tbl_test); conn.close(); initCtx.close(); } catch(NamingException e) { fail(Naming exception thrown); } catch (SQLException e) { fail(SQL Exception thrown); } I start Tomcat, assuming that the pool is set up. Then I use the client to try to get an initial context from it. This throws a naming exception, because it doesn't know how to get an initial context for org.apache.commons.dbcp.BasicDataSourceFactory at http://localhost:8080. My first question: can I do this? My second question: If I can't do it like this, do I need to set up a JNDI provider (like on JBoss) and set up the pooling there? My final question: It feels as if my problem is simply setting up the PROVIDER_URL properly so that it can get the context from Tomcat. I've done LDAP PROVIDER_URLs before, but never one that gets a data source factory from a servlet container. Can I use http over port 8080 to get the data source factory? Is there a different mechanism for getting the factory from code that is not residing within the servlet container? Can this even be done on Tomcat? I appreciate any help that anyone can provide. Cheers, Jason - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: JNDI References To Tomcat 4.1
This is mistaken, if you mean what you say. There is a JDBC resource available via JNDI in Tomcat. You have to code it, of course, but it definitely is available. At 02:53 PM 8/15/2003 -0500, Madere, Colin wrote: I think your inclinations that Tomcat is not a naming service are correct. I have not seen reference to anything that suggests you can set up resources in Tomcat that are available via JNDI. JBoss, certainly, as it does provide a JNDI server (whatever the appropriate name for that is), as I've used that with JMS/JBossMQ. AFAIK, the Tomcat JNDI setup stuff is just for processes internal to Tomcat, but that is an educated guess, not a known fact :) -Original Message- From: Jason Mowat [mailto:[EMAIL PROTECTED] Sent: Friday, August 15, 2003 12:14 PM To: [EMAIL PROTECTED] Subject: JNDI References To Tomcat 4.1 Greetings, I am trying to create a standalone application that references a DBCP on Tomcat. I'm not sure if I can do this; I've seem some articles that seem to suggest that it can be done, but again, I'm not sure. I've read http://www.mail-archive.com/[EMAIL PROTECTED]/msg08353.html. I have set up in tomcat/conf/server.xml the following context info: DefaultContext Resource name=jdbc/test_db auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/test_db parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namedriverClassName/name valueoracle.jdbc.driver.OracleDriver/value /parameter parameter nameurl/name valuejdbc:oracle:thin:@internal.sbgh.mb.ca:1521:test/value /parameter parameter nameusername/name valuetest/value /parameter parameter namepassword/name valuetest/value /parameter parameter namemaxActive/name value20/value /parameter parameter namemaxIdle/name value3/value /parameter parameter namemaxWait/name value100/value /parameter /ResourceParams /DefaultContext Note that I have not created any references in a web.xml, since I will not be running an application, per se, from Tomcat. PERHAPS THIS IS WHERE MY PROBLEM IS? The client code I am using is not a servlet or a JSP; it's a simple piece of code to see if I can communicate with the database pool on Tomcat as configured above. Hashtable env = new Hashtable(); env.put( Context.INITIAL_CONTEXT_FACTORY, org.apache.commons.dbcp.BasicDataSourceFactory ); // *** THIS IS ANOTHER AREA WHERE I MAY BE WRONG! *** env.put( Context.PROVIDER_URL, http://localhost:8080; ); try { InitialContext initCtx = new InitialContext(env); DataSource ds = (DataSource)initCtx.lookup(java:comp/env/jdbc/test_db); Connection conn = ds.getConnection(); Statement stmt = conn.createStatement(); ResultSet rset = stmt.executeQuery(SELECT * FROM tbl_test); conn.close(); initCtx.close(); } catch(NamingException e) { fail(Naming exception thrown); } catch (SQLException e) { fail(SQL Exception thrown); } I start Tomcat, assuming that the pool is set up. Then I use the client to try to get an initial context from it. This throws a naming exception, because it doesn't know how to get an initial context for org.apache.commons.dbcp.BasicDataSourceFactory at http://localhost:8080. My first question: can I do this? My second question: If I can't do it like this, do I need to set up a JNDI provider (like on JBoss) and set up the pooling there? My final question: It feels as if my problem is simply setting up the PROVIDER_URL properly so that it can get the context from Tomcat. I've done LDAP PROVIDER_URLs before, but never one that gets a data source factory from a servlet container. Can I use http over port 8080 to get the data source factory? Is there a different mechanism for getting the factory from code that is not residing within the servlet container? Can this even be done on Tomcat? I appreciate any help that anyone can provide. Cheers, Jason - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] LEGAL NOTICE This electronic mail transmission and any accompanying documents contain information belonging to the sender which may be confidential and legally privileged. This information is intended only for the use of the individual or entity to whom this electronic mail transmission was sent as indicated above. If you are not the intended recipient, any disclosure, copying, distribution, or action taken in reliance on the contents of the information contained in this
RE: JNDI References To Tomcat 4.1
Howdy, I believe he was referring to external access to tomcat's JNDI provider, which is tricky. In-memory is easy and you're right a JDBC resource can be configured (just like any other JNDI resource). Of course, if tomcat's JNDI provider moves into its own jakarta-commons component as we've been discussing, I bet you'd have standalone JNDI very soon ;) Yoav Shapira On Fri, 15 Aug 2003, Micael wrote: This is mistaken, if you mean what you say. There is a JDBC resource available via JNDI in Tomcat. You have to code it, of course, but it definitely is available. At 02:53 PM 8/15/2003 -0500, Madere, Colin wrote: I think your inclinations that Tomcat is not a naming service are correct. I have not seen reference to anything that suggests you can set up resources in Tomcat that are available via JNDI. JBoss, certainly, as it does provide a JNDI server (whatever the appropriate name for that is), as I've used that with JMS/JBossMQ. AFAIK, the Tomcat JNDI setup stuff is just for processes internal to Tomcat, but that is an educated guess, not a known fact :) -Original Message- From: Jason Mowat [mailto:[EMAIL PROTECTED] Sent: Friday, August 15, 2003 12:14 PM To: [EMAIL PROTECTED] Subject: JNDI References To Tomcat 4.1 Greetings, I am trying to create a standalone application that references a DBCP on Tomcat. I'm not sure if I can do this; I've seem some articles that seem to suggest that it can be done, but again, I'm not sure. I've read http://www.mail-archive.com/[EMAIL PROTECTED]/msg08353.html. I have set up in tomcat/conf/server.xml the following context info: DefaultContext Resource name=jdbc/test_db auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/test_db parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namedriverClassName/name valueoracle.jdbc.driver.OracleDriver/value /parameter parameter nameurl/name valuejdbc:oracle:thin:@internal.sbgh.mb.ca:1521:test/value /parameter parameter nameusername/name valuetest/value /parameter parameter namepassword/name valuetest/value /parameter parameter namemaxActive/name value20/value /parameter parameter namemaxIdle/name value3/value /parameter parameter namemaxWait/name value100/value /parameter /ResourceParams /DefaultContext Note that I have not created any references in a web.xml, since I will not be running an application, per se, from Tomcat. PERHAPS THIS IS WHERE MY PROBLEM IS? The client code I am using is not a servlet or a JSP; it's a simple piece of code to see if I can communicate with the database pool on Tomcat as configured above. Hashtable env = new Hashtable(); env.put( Context.INITIAL_CONTEXT_FACTORY, org.apache.commons.dbcp.BasicDataSourceFactory ); // *** THIS IS ANOTHER AREA WHERE I MAY BE WRONG! *** env.put( Context.PROVIDER_URL, http://localhost:8080; ); try { InitialContext initCtx = new InitialContext(env); DataSource ds = (DataSource)initCtx.lookup(java:comp/env/jdbc/test_db); Connection conn = ds.getConnection(); Statement stmt = conn.createStatement(); ResultSet rset = stmt.executeQuery(SELECT * FROM tbl_test); conn.close(); initCtx.close(); } catch(NamingException e) { fail(Naming exception thrown); } catch (SQLException e) { fail(SQL Exception thrown); } I start Tomcat, assuming that the pool is set up. Then I use the client to try to get an initial context from it. This throws a naming exception, because it doesn't know how to get an initial context for org.apache.commons.dbcp.BasicDataSourceFactory at http://localhost:8080. My first question: can I do this? My second question: If I can't do it like this, do I need to set up a JNDI provider (like on JBoss) and set up the pooling there? My final question: It feels as if my problem is simply setting up the PROVIDER_URL properly so that it can get the context from Tomcat. I've done LDAP PROVIDER_URLs before, but never one that gets a data source factory from a servlet container. Can I use http over port 8080 to get the data source factory? Is there a different mechanism for getting the factory from code that is not residing within the servlet container? Can this even be done on Tomcat? I appreciate any help that anyone can provide. Cheers, Jason - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]