You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Michael Wesner <mi...@konsole.net> on 2007/06/19 20:23:43 UTC

Tomcat 6.0.10 DataSourceRealm says "Name jdbc is not bound in this Context"

I am sure someone has run across this before.  I appreciate any help  
or pointers to other threads about this.

in the logs I get this error:

	un 19, 2007 1:01:24 PM org.apache.catalina.realm.DataSourceRealm open
	SEVERE: Exception performing authentication
	javax.naming.NameNotFoundException: Name jdbc is not bound in this  
Context


What am I doing wrong?



I have a default server.xml.   I configure everything using   META- 
INF/context.xml  and WEB-INF/web.xml


context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<Context path="apppath" docBase="appname" reloadable="true"  
antiJARLocking="true">
	<Resource auth="Container"
		driverClassName="org.gjt.mm.mysql.Driver"
		maxActive="10"
		maxIdle="5"
		name="jdbc/gateway"
		password="apassword"
		type="javax.sql.DataSource"
		url="jdbc:mysql://localhost:3306/gateway?autoReconnect=true"
		username="myusername"/>
<Realm className="org.apache.catalina.realm.DataSourceRealm" debug="99"
	   dataSourceName="jdbc/gateway"
	   userTable="user"
	   userNameCol="Username"
	   userCredCol="Password"
	   userRoleTable="loginroleview"
	   roleNameCol="RoleName"/>
</Context>

web.xml:  (has other things, but here is the auth part)

	<security-constraint>
		<web-resource-collection>
			<web-resource-name>Secured Area</web-resource-name>
			<url-pattern>/secure/*</url-pattern>
		</web-resource-collection>
		<auth-constraint>
			<role-name>Administrator</role-name>
			<role-name>User</role-name>
		</auth-constraint>
	</security-constraint>
	
	
	<login-config>
     	<auth-method>BASIC</auth-method>
     	<realm-name>Gateway Secure Area</realm-name>
   	</login-config>
   	
   	<security-role>
     	<description>
       		The role that is required
     	</description>
     	<role-name>Administrator</role-name>
   	</security-role>
   	  	<security-role>
     	<description>
       		The role that is required
     	</description>
     	<role-name>User</role-name>
   	</security-role>
</web-app>





Re: Tomcat 6.0.10 DataSourceRealm says "Name jdbc is not bound in this Context"

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

Michael,

Michael Wesner wrote:
> I am sure someone has run across this before.  I appreciate any help or
> pointers to other threads about this.

Ooh! So close...

What you are looking for is documented on this page (and unfortunately
nowhere else, AFAICT):
http://tomcat.apache.org/tomcat-6.0-doc/realm-howto.html

If you look under the "DataSourceRealm" section, you'll see that you
need to set the localDataSource attribute to true in order to use a
datasource defined in the <Context> element when you want to use a
<Realm> with that data source. Otherwise, it will look for a "global"
JNDI datasource.

- -chris

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

iD8DBQFGeCkC9CaO5/Lv0PARAspvAJ4zPNV8wvGYgZu7b3Emyn6I310NlACeN4dl
wSTYi03A3hPndArNWIjUIZQ=
=V2RF
-----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