Hi all.

Well, I'm not having much success with JDBC data source over JNDI. What happens 
is that the object that should be javax.sql.DataSource is returned "null" from 
the lookup.

What steps can I take to identify the source of (not only) my problem?

SERVER.XML
----------
<Context docBase="addr_admin" path="/addr_admin" debug="0">
   <Resource name="jdbc/AddressBookDB" type="javax.sql.DataSource"/>
   <ResourceParams name="jdbc/AddressBookDB">
     <Parameter>
       <Name>driverClassName</Name>
       <Value>org.postgresql.Driver</Value>
     </Parameter>
     <Parameter>
       <Name>driverName</Name>
       <Value>jdbc:postgresql://test.domain.com/test</Value>
     </Parameter>
     <Parameter>
       <Name>user</Name>
       <Value>my_user</Value>
     </Parameter>
     <Parameter>
       <Name>password</Name>
       <Value>my_pass</Value>
     </Parameter>
   </ResourceParams>
</Context>

WEB.XML
-------
<resource-ref>
   <res-ref-name>jdbc/AddressBookDB</res-ref-name>
   <res-type>javax.sql.DataSource</res-type>
   <res-auth>Container</res-auth>
</resource-ref>

TEST.JSP
--------
public void init() throws ServletException {
   Context initCtx, envCtx;

   super.init();
   try {
     initCtx = new InitialContext();
     if( (envCtx = (Context)initCtx.lookup( "java:comp/env" )) == null ) {
       throw new UnavailableException( "No java:comp/env context" );
     }
     if( (ds = (DataSource)envCtx.lookup( "jdbc/AddressBookDB" )) == null ) {
       throw new UnavailableException( "No environment resource: JDBC" );
     }
   } catch( javax.naming.NamingException ne ) {
     throw new UnavailableException( "Naming service failure" );
   }
}

The servlet goes to "unavailable" and the error in logs is that JDBC line. So, 
the "java:comp/env" is accessable, but not the "jdbc/AddressBookDB". What could 
possibly be the reason for this? How can test JNDI setup?

Nix.


--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to