I have also experienced 1. below. Does anyone know of there is any resolution? We are temporarily running servlets which use this through Tomcat directly.
Cynthia Jeness "Clearwater, Pete" wrote: > Hi Nick. > > I had similar problems, and have found out a couple of things: > > 1. I could not get my datasources to be found when using the WARP connector. Same >thing as you - null DataSource. No idea what the problem was here. > > 2. Initially I could not get it to work at all, but found that if I used the >parameter "url" instead of "driverName" then everything was OK (except for 1. above). > > cheers. Isn't debugging this JNDI stuff fun? The log messages sure give lots of >useful information.... > > pete. > > -----Original Message----- > From: nickJohnson [mailto:[EMAIL PROTECTED]] > Sent: Friday, April 19, 2002 8:07 PM > To: [EMAIL PROTECTED] > Subject: DataSource from JNDI always null > > I thought I had this problem fixed, but it has come up again. > > Basically I'm just trying to grab a JDBC resource for a postgresql > database. My code looks something like this: > > public static Connection getConnection(char mode) > throws NamingException, SQLException { > Context ctx = null; > > ctx = new InitialContext(); > Context envCtx = (Context) ctx.lookup("java:comp/env"); > String dbname = "jdbc/" + (mode == 'w'? "dbrw" : "dbro"); > DataSource ds = (DataSource) envCtx.lookup(dbname); > Connection c = ds.getConnection(); > return c; > } > > This code is called as a static method on a utility class from inside a > bean used by a JSP document. > > Of course what happens is I get a null pointer exception trying to call > getConnection on ds. Here's the relevent information from server.xml. > I'll paste in only the entry for "dbrw". dbro is identical except it uses > a different username. Both have the same problem. I have verified that I > can log in both using the command line tool and a quick and dirty jdbc > test program. > > <Resource name="jdbc/dbrw" auth="Container" > type="javax.sql.DataSource"/> > <ResourceParams name="jdbc/dbrw"> > <parameter> > <name>user</name> > <value>www</value> > </parameter> > <parameter> > <name>password</name> > <value>xxxxxxxx</value> > </parameter> > <parameter> > <name>driverClassName</name> > <value>org.postgresql.Driver</value> > </parameter> > <parameter> > <name>driverName</name> > <value>jdbc:postgresql://localhost:5432/main/value> > </parameter> > </ResourceParams> > > And in web.xml (I've decided to use the server's web.xml rather than the > context's): > > <resource-ref> > <description> > Resource reference to a java.sql.Connection factory > </description> > <res-ref-name>jdbc/dbrw</res-ref-name> > <res-type>javax.sql.DataSource</res-type> > <res-auth>Container</res-auth> > </resource-ref> > > postgresql.jar and the jdbc extensions are in common/lib. As far as I can > tell from snooping traffic across lo0, no connection attempt is ever made, > although I do see plenty of traffic from my little jdbc test program. > > Any pointers would be greatly appreciated, especially any information on > debugging problems with JNDI, getting diagnostic information out of it, > etc. A working postgresql config would be even better. My instinct about > this is that I have JNDI set up incorrectly, or the jdbc drivers are not > getting found or initialized properly, but having exhausted all my ideas, > I thought I'd ask for a pointer :) > > Many thanks, > > Nick > > -- > To unsubscribe: <mailto:[EMAIL PROTECTED]> > For additional commands: <mailto:[EMAIL PROTECTED]> > Troubles with the list: <mailto:[EMAIL PROTECTED]> > > -- > To unsubscribe: <mailto:[EMAIL PROTECTED]> > For additional commands: <mailto:[EMAIL PROTECTED]> > Troubles with the list: <mailto:[EMAIL PROTECTED]> -- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]>