struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Gainty" <>
Subject Re: Datasource not found by Plugin on startup
Date Mon, 03 Oct 2005 18:50:06 GMT

If your webapp is called foo, create a file 
You will need to match the exact name of the identified resource contained 
within foo.xml
<Resource name="jdbc/sampdb" type="javax.sql.DataSource"/>
later on you will reference
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
if(envCtx == null )
throw new Exception("Boom - No Environment Context");
// the following matches the resource name defined in foo.xml
DataSource ds =
(DataSource) envCtx.lookup("jdbc/sampdb");

Please dont hesitate to contact me if you need any help,
Marty Gainty

----- Original Message ----- 
From: "Faisal Mahmoud" <>
To: <>
Sent: Monday, October 03, 2005 1:09 PM
Subject: Datasource not found by Plugin on startup

 I have written a plugin for a Struts app which accesses a DB connection via
a datasource. The datasource is defined in the Tomcat server.xml file, and
is loaded via a library we wrote. I know the datasource works fine because I
can access if from other classes in the app. But when I start up Tomcat, I
get the following exception thrown:

javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
Is there something I need to do to make the DS available to my Plugin?

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message