tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anton Tagunov <atagu...@mail.cnt.ru>
Subject Re: JNDI lookup from console app
Date Mon, 15 Sep 2003 09:20:43 GMT
Hello James!

JD> I'm trying to lookup a DataSource using JNDI configured within Tomcat (I'm
JD> not using JBoss) from an application that isn't in the container (i.e. a
JD> console app). 

JD> 1. Is Tomcat's JNDI available to application outside of the container?
No they are not.
BTW, how you would imagine it would work?
What sort of communication would be stablished between the console
app and Tomcat? Tomcat serves only HTTP requests and requests from
connectors like mod_jk to plug Tomcat into things like Apache and IIS.
Nothing else. How would JNDI work? Imagine you would get something
for the JNDI node the datasrouce is configured at. Now, how will you
communicate to the datasource? The datasource lives inside Tomcat JVM,
your application runs in another. How would you invoke methods across
JVM? Via RMI or Corba? But then the datasource implementation should
have been running as an RMI or Corba object which it does not.
The JNDI run by Tomcat is for Tomcat inhabitants like JSP-s and
servlets only.

BTW, datasource implementations are not regularly remoted in any
scenario. If you're running a EJB server like JBoss, or Jonas, then
it has datasources configured internally for the use of EJB-s that
it hosts, but only the EJB-s themselves, not the datasources they
use are accessible remotely.

If you need datasource functionality in your console application
create and configure it manually there. Most likely your JDBC
driver has a Datasource implementation bundled in, instantiate
it directly. Or just use DriverManager.getConnection().
If you need pooling use BasicDataSource from jakarta-commons/dbcp
manually on top of your db vendor provided datasource or
DriverManager-compatible driver.


Anton


Mime
View raw message