tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Hoebeke <mark.hoeb...@sb-roscoff.fr>
Subject Configuring a context specific JNDI/JDBC Realm
Date Mon, 02 May 2011 16:11:41 GMT
Hello,

after Googling a lot across Tomcat docs and mailing lists, and finding
no answer to my problem I decided to give it a try on the mailing list.

So, I'm using Tomcat 6.0.26 and I'm developing an application relying on
a Realm to authenticate users. The Realm is a DataSourceRealm pointing
to a JNDI Resource declared in the ${catalina.home}/conf/context.xml as
follows :

<Resource name="jdbc/mydb"
	auth="Container"
	type="javax.sql.DataSource"
	driverClassName="org.postgresql.Driver"
	url="jdbc:postgresql://dbhost:5437/dbname"
	username="dbuser" password="dbpasswd"/>

This declaration is fully functional as the same application relies on
it for non-authentication related uses that actually work.

I've tried putting the Realm declaration in the META-INF/context.xml
file of my application, as follows :


<Context path="/myapp">

	<Realm className="org.apache.catalina.realm.DataSourceRealm"
auth="Container" debug="99" dataSourceName="jdbc/mydb" userTable="users"
userRoleTable="roles" userNameCol="name" userCredCol="password"
roleNameCol="role" digest="SHA-1" />


</Context>

(As I'm (re)deploying the app quite frequently I cannot put this
declaration in the ${catalina.home}/conf/server.xml file, if I'm right).

Whenever I try to access the part of the app needing authentication, and
submit the login form, the request gets denied, and a log entry gets
generated. The latter states that de name jdbc is not bound :

SEVERE: Exception performing authentication
javax.naming.NameNotFoundException: Name jdbc is not bound in this Context

So it's not an issue of wrong login/password credentials.

I tried to add a ResourceLink entry to the context.xml file, to no
avail. Needless to say, I don't want to declare the Resource itself in
the context.xml, as its connection parameters are the responsibility of
the Tomcat admin and not of the developers.

So if anyone could give me some pointers as to how to declare a
JNDI-based context specific Realm, outside of the server.xml file, it
would be of great help.

Many thanks.

Mark











Mime
View raw message