users@glassfish.java.net

Issue with DataSource lookup in Glassfish

From: <glassfish_at_javadesktop.org>
Date: Mon, 05 Jul 2010 03:26:49 PDT

Hi,

I have set up a ConnectionPool in GlassFish Server Open Source Edition 3.0.1 (build 22) for the MySQL database using Connector/J 5.1.12 . This seems to be OK and Ping is successful. I've also setup a JDBC Resource that is configured to use the ConnectionPool.

I have written and successfully deployed a simple JSP app. This can be launched and runs. However, when I perform the database lookup using this line:

ds = (DataSource) ctx.lookup("java:comp/env/jdbc/MySQLDataSource");

I get the following error:

 Lookup failed for 'jdbc/MySQLDataSource/world' in SerialContext

The name I specify in the lookup, jdbc/MySQLDataSource is the JNDI name I specified when creating the JDBC Resource.

This is interesting. Note the ''jdbc/MySQLDataSource/world'' in the error message. It does seem to have picked up the DataSource I created, because in that datasource I specified the database to be 'world'. So it seems to have found the DataSource, but in what way did the lookup fail? World definitely exists in the server (checked with command line client).

I'm running on:

C:\HelloWebApp>java -version
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing)

Any help would be greatly appreciated in figuring out what I'm doing wrong,

Thanks,
Tony
[Message sent by forum member 'codefire']

http://forums.java.net/jive/thread.jspa?messageID=476777