You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Roger Keays <ro...@ninthavenue.com.au> on 2008/04/15 08:22:54 UTC

javax.naming.NameNotFoundException: Name jdbc is not bound in this Context

The following configuration gives me a javax.naming.NameNotFoundException:

<Context path="/">

   <!-- connection pool for database -->
   <Resource name="jdbc/data" auth="Container" type="javax.sql.DataSource"
             driverClassName="org.postgresql.Driver"
             url="jdbc:postgresql://localhost/test"
             username="postgres" password=""
             maxActive="5" maxIdle="2" maxWait="-1"/>

   <!-- authentication realm -->
   <Realm className="org.apache.catalina.realm.DataSourceRealm"
          dataSourceName="jdbc/data" digest="MD5"
          userTable="web_users" userRoleTable="web_user_roles"
          userNameCol="id" userCredCol="password" roleNameCol="role"/>
</Context>

However, if I move the JNDI resource up it works as expected:

<GlobalNamingResources>

   <!-- connection pool for database -->
   <Resource name="jdbc/data" auth="Container" type="javax.sql.DataSource"
             driverClassName="org.postgresql.Driver"
             url="jdbc:postgresql://localhost/test"
             username="postgres" password=""
             maxActive="5" maxIdle="2" maxWait="-1"/>
</GlobalNamingResources>
...
<Context path="/">

   <!-- authentication realm -->
   <Realm className="org.apache.catalina.realm.DataSourceRealm"
          dataSourceName="jdbc/data" digest="MD5"
          userTable="web_users" userRoleTable="web_user_roles"
          userNameCol="id" userCredCol="password" roleNameCol="role"/>
</Context>



Is that the intended behaviour?

Cheers,

Roger


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context

Posted by Mark Thomas <ma...@apache.org>.
Roger Keays wrote:
> Is that the intended behaviour?
Yes. If you want a realm to use a context defined datasource rather than a 
global one you need to set:
localDataSource="true" on the realm

It is documented in the howto but not the realm docs. I'll fix that now.
http://tomcat.apache.org/tomcat-6.0-doc/realm-howto.html#DataSourceRealm

Mark

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: javax.naming.NameNotFoundException: Name jdbc is not bound inthisContext

Posted by Mark Thomas <ma...@apache.org>.
Caldarale, Charles R wrote:
> I'd certainly like to see a Tomcat config tag with a couple of settings
> that would log or optionally reject badly formed <Context> elements.

Patches are always welcome ;)

Mark


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: javax.naming.NameNotFoundException: Name jdbc is not bound inthisContext

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Christopher Schultz [mailto:chris@christopherschultz.net] 
> Subject: Re: javax.naming.NameNotFoundException: Name jdbc is 
> not bound inthisContext
> 
> Can you think of a reason not to have Tomcat simply
> refuse to load a <Context> that specifies its own 
> path (unless it is in server.xml)?

Only for compatibility with older or sloppily implemented pre-packaged
webapps from third parties.

I'd certainly like to see a Tomcat config tag with a couple of settings
that would log or optionally reject badly formed <Context> elements.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: javax.naming.NameNotFoundException: Name jdbc is not bound in thisContext

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chuck,

Caldarale, Charles R wrote:
| Also note that for any Tomcat released in the last few
| years, the only time a path attribute is allowed at all is when the
| <Context> element is in server.xml (where it should never be).

Can you think of a reason not to have Tomcat simply refuse to load a
<Context> that specifies its own path (unless it is in server.xml)? This
seems to (possibly) cause lots of problems that we handle on the list,
and it might be easier to simply enforce it with software.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkgGPX8ACgkQ9CaO5/Lv0PDMQACgtFw6Kn+zWtmHwP7fwEzFzfhs
PS0AoLAKeKkvvFmp8d47max6eDA8uzQp
=NmmQ
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: javax.naming.NameNotFoundException: Name jdbc is not bound in thisContext

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: news [mailto:news@ger.gmane.org] On Behalf Of Roger Keays
> Subject: javax.naming.NameNotFoundException: Name jdbc is not 
> bound in thisContext
> 
> The following configuration gives me a 
> javax.naming.NameNotFoundException:
> 
> <Context path="/">

That path specification is incorrect, regardless of the version of
Tomcat you're using (which you didn't bother to tell us).  If you're
trying to declare the default webapp, the path must be an empty string,
not a slash.  Also note that for any Tomcat released in the last few
years, the only time a path attribute is allowed at all is when the
<Context> element is in server.xml (where it should never be).

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org