You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Faisal Mahmoud <fa...@gmail.com> on 2005/10/03 19:09:15 UTC

Datasource not found by Plugin on startup

Hi,
 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?
 -Faisal
--
http://www.quidprocode.com

Re: Datasource not found by Plugin on startup

Posted by Martin Gainty <mg...@hotmail.com>.
Mahmoud-

If your webapp is called foo, create a file 
$TOMCAT_HOME/conf/Catalina/localhost/foo.xml
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");

http://forums.devshed.com/archive/t-120081

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

(US)
001-617-852-7822
----- Original Message ----- 
From: "Faisal Mahmoud" <fa...@gmail.com>
To: <us...@struts.apache.org>
Sent: Monday, October 03, 2005 1:09 PM
Subject: Datasource not found by Plugin on startup


Hi,
 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?
 -Faisal
--
http://www.quidprocode.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org