tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "sergiodegioia@libero.it" <sergiodegi...@libero.it>
Subject Re: JNDI resource in Tomcat 4.0.1
Date Wed, 12 Dec 2001 14:07:28 GMT
You must invoke lookup() on a new context: that you get through 
ctx.lookup("java:comp/env")
that is:

Context ctx = new InitialContext();
Context env = ctx.lookup("java:comp/env");
javax.sql.ConnectionPoolDataSource ds= 
(javax.sql.ConnectionPoolDataSource) ctx.lookup("jdbc/tdcconn");

> Hi!
> Got a serious problem to define and use a Resource in Tomcat 4.0.1.
> I want to define in the Tomcat a JNDI resource like this (server.xml) 
under
> my webapplication (<context.......>    </context>)
> 
> 	<Resource name="jdbc/tdcconn" auth="Container"
> type="javax.sql.ConnectionPoolDataSource"/>
> 			<ResourceParams name="jdbc/tdcconn">
>             		<parameter>
> 				<name>user</name>
> 				<value>tdc</value>
> 			</parameter>
>             		<parameter>
> 				<name>password</name>
> 				<value>tdc</value>
> 			</parameter>
>             		<parameter>
> 				<name>driverClassName</name>
>  
> <value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>
> 			</parameter>
>             		<parameter>
> 				<name>driverName</name>
>  
> <value>jdbc:microsoft:sqlserver://ramirez:1433</value>
> 			</parameter>
>           	</ResourceParams>
> 
> And in the web.xml for my webapplication I´vd declared the resource li
ke
> this:
> 
> 	<resource-ref>
>   		<description>Try connection pool with fucking
> MS</description>
>   		<res-ref-name>jdbc/tdcconn</res-ref-name>
>   		<res-type>javax.sql.ConnectionPoolDataSource</res-type>
>   		<res-auth>Container</res-auth>
> 	</resource-ref>
> 
> In my JSP code I try to access the resource like this:
> 
> 	javax.naming.InitialContext ctx= new javax.naming.InitialContext
();
> 	ctx.lookup("java:comp/env");
> 	javax.naming.NamingEnumeration enum= ctx.list("java:comp/env");
> 	ds= (javax.sql.ConnectionPoolDataSource) ctx.lookup
("jdbc/tdcconn");
> 
> 
> And the exception comes out like this:
> 
> 
	javax.naming.NameNotFoundException: Name jdbc is not bound in th
is
> context.....
> 
> 
> Any suggestions
> 
> Niclas Rothman
> 
> 
> 
> Niclas Rothman
> System Developer
> 
> e|sense
> Øster Fælled Torv 4
> DK-2100 Copenhagen
> Denmark
> 
> +45 35 44 17 00 - reception
> +45 35 44 17 21 - direct
> +45 35 44 17 17 - fax
> 
> nir@e-sense.dk
> www.e-sense.dk
> 
> e|sense - a Kunde Group company
>  
> 
> 
> --
> To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
> Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>
> 
> 
Mime
View raw message