Hello, 
>       I am having problem setting up JNDI resources with Tomcat 4.0.4 .
> I am using MS SQL Server.  I have read and followed the howTo tutorial but
> i keep on getting this exception:
> 
> javax.naming.NamingException: Cannot create resource instance
>         at
> org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceF
> actory.java:167)
>         at
> javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:3
> 11)
>         at org.apache.naming.NamingContext.lookup(NamingContext.java:835)
>         at org.apache.naming.NamingContext.lookup(NamingContext.java:181)
>         at org.apache.naming.NamingContext.lookup(NamingContext.java:822)
>         at org.apache.naming.NamingContext.lookup(NamingContext.java:194)
>         at
> gov.nih.nhlbi.training.servlet.DisplayMechanism.handleRequest(Display
> Mechanism.java:44)
> 
> My server.xml has following entry:
> <Context path="/training" docBase="training" debug="0"
>                  reloadable="true" crossContext="true">
>       <!-- JNDI SETUP -->
>       
>       <Resource name="jdbc/SQLServer" auth="Container"
>                     type="javax.sql.DataSource"/> 
>       
>       <ResourceParams name="jdbc/SQLServer">
>         <parameter>
>           <name>factory</name>
>           <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
>         </parameter>
>         <parameter>
>           <name>driverClassName</name>
>           <value>com.inet.tds.TdsDriver</value>
>         </parameter>
>         <parameter>
>           <name>url</name>
>           <value>jdbc:inetdae7: testdatabase.somemachine.com
> ?database=training</value>
>         </parameter>
>         <parameter>
>           <name>username</name>
>           <value>  username </value>
>         </parameter>
>         <parameter>
>           <name>password</name>
>           <value>  password </value>
>         </parameter>
>         <parameter>
>           <name>maxActive</name>
>           <value>20</value>
>         </parameter>
>         <parameter>
>           <name>maxIdle</name>
>           <value>10</value>
>         </parameter>
>         <parameter>
>           <name>maxWait</name>
>           <value>-1</value>
>         </parameter>
>       </ResourceParams>
>       
>       </Context>
> 
> 
> Application web.xml has following entry:
> <!--JNDI SETUP -->
>      <resource-ref>
>        <description>SQLServer Datasource example</description>
>        <res-ref-name>jdbc/SQLServer</res-ref-name>
>        <res-type>javax.sql.DataSource</res-type>
>        <res-auth>Container</res-auth>
>      </resource-ref> 
> 
> 
> And finally this is java code i am using to get the datasource
> 
>       javax.naming.Context initContext = new InitialContext();
>             javax.naming.Context envContext  =
> (javax.naming.Context)initContext.lookup("java:comp/env");
> 
>             DataSource ds =
> (DataSource)envContext.lookup("jdbc/SQLServer");
>             Connection connection = ds.getConnection();
> 
> Do you see anything wrong with all this? Any help will be appreciated.
> Thanks in advance.

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to