I’ve set up a JDBC Realm in my META-INF/Context.xml as shown below, and that works.
The trouble is the JDBC driver now have to be placed under $CATALINA_HOME/lib/
Is there any way I can get that realm to load the jdbc driver from elsewhere, such as WEB-INF/lib/ in my webapp ?
META-INF/Context.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Realm className="org.apache.catalina.realm.JDBCRealm"
driverName="org.postgresql.Driver"
connectionURL="jdbc:postgresql://daemon/testdb"
userTable="users" userNameCol="userName" userCredCol="password"
connectionPassword="xxxxx"
connectionName="xxxxx"
userRoleTable="users" roleNameCol="role"
digest="MD5"/>
</Context>
I’m pretty sure you can’t do that, no. The Realm exists and is managed outside of the scope of any application. Consider the case where two webapps were deployed, for example, with conflicting drivers.
If you need to keep your JDBC driver inside your WAR, then you’ll need to do the security management there also, rather than relying on tomcat to do it for you.