let me describe the environment first:
environment: - mac os x (java build 1.6.0_35-b10-428-11M3811) - apache tomcat 7.0.30 - mysql 5.5.27 - tomcat/lib --> mysql-connector-java-5.1.22-bin.jar
i've implemented successfully a JDBCRealm and want to switch to a DataSourceRealm because it is recommended for production environments. i use form-based authentication.
I did everything described here: http://tomcat.apache.org/tomcat-7.0-doc/realm-howto.html#DataSourceRealm and here: http://tomcat.apache.org/tomcat-7.0-doc/jndi-datasource-examples-howto.html#MySQL_DBCP_Example
server.xml
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.DataSourceRealm"
dataSourceName="jdbc/proto" digest="SHA-256" roleNameCol="role"
userCredCol="password" userNameCol="name" userRoleTable="roles"
userTable="users"/>
</Realm>
context.xml
<Resource auth="Container"
driverClassName="com.mysql.jdbc.Driver"
maxActive="100" maxIdle="30" maxWait="10000"
name="jdbc/proto" password="proto" type="javax.sql.DataSource"
url="jdbc:mysql://localhost:3306/proto" username="proto"/>
WEB-INF/web.xml
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/proto</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
when i submit the username and password i get the following exception:
Sep 18, 2012 9:38:32 PM org.apache.catalina.realm.DataSourceRealm open
SEVERE: Exception performing authentication
javax.naming.NameNotFoundException: Name [jdbc/proto] is not bound in this Context. Unable to find [jdbc].
at org.apache.naming.NamingContext.lookup(NamingContext.java:820)
at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
at org.apache.catalina.realm.DataSourceRealm.open(DataSourceRealm.java:394)
at org.apache.catalina.realm.DataSourceRealm.authenticate(DataSourceRealm.java:285)
at org.apache.catalina.realm.CombinedRealm.authenticate(CombinedRealm.java:146)
at org.apache.catalina.realm.LockOutRealm.authenticate(LockOutRealm.java:180)
at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthenticator.java:295)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:450)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
i haven't tried to setup the environment on a different os to test if it's a mac specific issue.
any suggestions what i missed? i appreciate your help! thank you.