RE: JNDI DataSource Realm
Where is your JDBC driver .jar file located? It should be in TOMCAT-HOME/common/lib. Also, how are you instantiating your DataSource object within your code? Thanks, Scott Stewart [Manager, Software Development] [EMAIL PROTECTED] ClearSky Mobile Media, Inc. 56 E. Pine St. Suite 200 Orlando, FL 32801 USA -Original Message- From: Madere, Colin [mailto:[EMAIL PROTECTED] Sent: Friday, August 15, 2003 3:44 PM To: 'Tomcat Users List' Subject: RE: JNDI DataSource Realm Ok, so changing the dataSourceName attribute in the Realm config (as you suggest which contradicts the HOWTO) to the short name I've given my resource makes the Realm auth work with the globally defined datasource. Yay! However, when trying to connect to the datasource (moved the jdbc/Auth resource from DefaultContext tag to GlobalNamingResources tag), my servlet application still gives the same Name jdbc is not bound in this Context error. You mention not having to put a resource-ref in the context specific web.xml file, and I assume your suggestion to put ResourceLink tag in the Context (in my case putting it in the DefaultContext tag so it works, or should, for all autodeployed contexts) is what you mean removes the need for the those aforementioned entries. However, it doesn't appear to work (as it _does_ work when I move the whole Resource/ResourceParams tags into the DefaultContext tag. Don't want to do this as I will have multiple virtual hosts using the same resource...) Doubt it's of importance, but adding the resource-ref you suggest is not necessary produces the elusive Cannot load JDBC driver class 'null' error, which I believe is unrelated. Any more ideas why my app would not see the global resource as defined below as a global resource and then resource-linked in the default context? -Original Message- From: Scott Stewart [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 13, 2003 5:27 PM To: 'Tomcat Users List' Subject: RE: JNDI DataSource Realm I posted this awhile back (for MySQL), but here it is again. Also, when you define your DataSource in this manner, you do not need the resource-ref node in your context-specific web.xml files. The global DataSource definition !-- Global JNDI resources -- GlobalNamingResources !-- Editable user database that can also be used by JNDI DatabaseRealm to authenticate users -- Resource name=jdbc/MySQLConnectPool auth=Container type=javax.sql.DataSource / ResourceParams name=jdbc/MySQLConnectPool parameter nameusername/name value/value /parameter parameter namepassword/name value/value /parameter parameter namedriverClassName/name valuecom.mysql.jdbc.Driver/value /parameter parameter nameurl/name valuejdbc:mysql://your IP here:3306/your DB name here?autoReconnect=true/value /parameter parameter nameremoveAbandoned/name valuetrue/value /parameter parameter nameremoveAbandonedTimeout/name value60/value /parameter parameter namelogAbandoned/name valuetrue/value /parameter parameter namemaxActive/name value200/value /parameter parameter namemaxIdle/name value3/value /parameter parameter namemaxWait/name value100/value /parameter /ResourceParams /GlobalNamingResources Realm definition using global DataSource Realm className=org.apache.catalina.realm.DataSourceRealm dataSourceName=jdbc/MySQLConnectPool userTable=customers userNameCol=customer_username userCredCol=customer_password userRoleTable=roles roleNameCol=role debug=0 / Context reference to global DataSource -- ResourceLink name=jdbc/MySQLConnectPool global=jdbc/MySQLConnectPool type=javax.sql.DataSource
RE: JNDI DataSource Realm
Ok, so changing the dataSourceName attribute in the Realm config (as you suggest which contradicts the HOWTO) to the short name I've given my resource makes the Realm auth work with the globally defined datasource. Yay! However, when trying to connect to the datasource (moved the jdbc/Auth resource from DefaultContext tag to GlobalNamingResources tag), my servlet application still gives the same Name jdbc is not bound in this Context error. You mention not having to put a resource-ref in the context specific web.xml file, and I assume your suggestion to put ResourceLink tag in the Context (in my case putting it in the DefaultContext tag so it works, or should, for all autodeployed contexts) is what you mean removes the need for the those aforementioned entries. However, it doesn't appear to work (as it _does_ work when I move the whole Resource/ResourceParams tags into the DefaultContext tag. Don't want to do this as I will have multiple virtual hosts using the same resource...) Doubt it's of importance, but adding the resource-ref you suggest is not necessary produces the elusive Cannot load JDBC driver class 'null' error, which I believe is unrelated. Any more ideas why my app would not see the global resource as defined below as a global resource and then resource-linked in the default context? -Original Message- From: Scott Stewart [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 13, 2003 5:27 PM To: 'Tomcat Users List' Subject: RE: JNDI DataSource Realm I posted this awhile back (for MySQL), but here it is again. Also, when you define your DataSource in this manner, you do not need the resource-ref node in your context-specific web.xml files. The global DataSource definition !-- Global JNDI resources -- GlobalNamingResources !-- Editable user database that can also be used by JNDI DatabaseRealm to authenticate users -- Resource name=jdbc/MySQLConnectPool auth=Container type=javax.sql.DataSource / ResourceParams name=jdbc/MySQLConnectPool parameter nameusername/name value/value /parameter parameter namepassword/name value/value /parameter parameter namedriverClassName/name valuecom.mysql.jdbc.Driver/value /parameter parameter nameurl/name valuejdbc:mysql://your IP here:3306/your DB name here?autoReconnect=true/value /parameter parameter nameremoveAbandoned/name valuetrue/value /parameter parameter nameremoveAbandonedTimeout/name value60/value /parameter parameter namelogAbandoned/name valuetrue/value /parameter parameter namemaxActive/name value200/value /parameter parameter namemaxIdle/name value3/value /parameter parameter namemaxWait/name value100/value /parameter /ResourceParams /GlobalNamingResources Realm definition using global DataSource Realm className=org.apache.catalina.realm.DataSourceRealm dataSourceName=jdbc/MySQLConnectPool userTable=customers userNameCol=customer_username userCredCol=customer_password userRoleTable=roles roleNameCol=role debug=0 / Context reference to global DataSource -- ResourceLink name=jdbc/MySQLConnectPool global=jdbc/MySQLConnectPool type=javax.sql.DataSource / Hope this helps!! Thanks, Scott Stewart [Manager, Software Development] [EMAIL PROTECTED] ClearSky Mobile Media, Inc. 56 E. Pine St. Suite 200 Orlando, FL 32801 USA -Original Message- From: Madere, Colin [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 13, 2003 5:17 PM To: 'Tomcat Users List' Subject: JNDI DataSource Realm Tomcat 4.1.27 PostgreSQL 7.3.4 pg73jdbc3.jar Trying to use JNDI as a Realm source
RE: JNDI DataSource Realm
I posted this awhile back (for MySQL), but here it is again. Also, when you define your DataSource in this manner, you do not need the resource-ref node in your context-specific web.xml files. The global DataSource definition !-- Global JNDI resources -- GlobalNamingResources !-- Editable user database that can also be used by JNDI DatabaseRealm to authenticate users -- Resource name=jdbc/MySQLConnectPool auth=Container type=javax.sql.DataSource / ResourceParams name=jdbc/MySQLConnectPool parameter nameusername/name value/value /parameter parameter namepassword/name value/value /parameter parameter namedriverClassName/name valuecom.mysql.jdbc.Driver/value /parameter parameter nameurl/name valuejdbc:mysql://your IP here:3306/your DB name here?autoReconnect=true/value /parameter parameter nameremoveAbandoned/name valuetrue/value /parameter parameter nameremoveAbandonedTimeout/name value60/value /parameter parameter namelogAbandoned/name valuetrue/value /parameter parameter namemaxActive/name value200/value /parameter parameter namemaxIdle/name value3/value /parameter parameter namemaxWait/name value100/value /parameter /ResourceParams /GlobalNamingResources Realm definition using global DataSource Realm className=org.apache.catalina.realm.DataSourceRealm dataSourceName=jdbc/MySQLConnectPool userTable=customers userNameCol=customer_username userCredCol=customer_password userRoleTable=roles roleNameCol=role debug=0 / Context reference to global DataSource -- ResourceLink name=jdbc/MySQLConnectPool global=jdbc/MySQLConnectPool type=javax.sql.DataSource / Hope this helps!! Thanks, Scott Stewart [Manager, Software Development] [EMAIL PROTECTED] ClearSky Mobile Media, Inc. 56 E. Pine St. Suite 200 Orlando, FL 32801 USA -Original Message- From: Madere, Colin [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 13, 2003 5:17 PM To: 'Tomcat Users List' Subject: JNDI DataSource Realm Tomcat 4.1.27 PostgreSQL 7.3.4 pg73jdbc3.jar Trying to use JNDI as a Realm source for both auth and data access for a whole server, therefore trying as a GlobalNamingContext attribute. No love. * Set up as a JDBC Realm, auth works. * Set up Datasource as JNDI Resource within DefaultContext, data access works. Move Resource and params to GlobalNamingContext and I get the Name jdbc is not bound in this Context error. Saw lots of refs to this error via Google, but none relevant AFAICT. (Do I look up resources in the global context differently? If so doesn't that kind of break the idea of it being an abstractly defined data source?) Anyone successfully using GlobalNamingContext for DataSources? Using these components (Tomcat 4.1.x, postgreSQL)? Change Realm from JDBC to DataSourceRealm and auth does not work (or report any errors in logs). server.xml (with DataSourceRealm commented out) Server port=8005 shutdown=SHUTDOWN debug=0 Listener className=org.apache.catalina.mbeans.ServerLifecycleListener debug=0/ Listener className=org.apache.catalina.mbeans.GlobalResourcesLifecycleListener debug=0/ !-- Global JNDI resources -- GlobalNamingResources /GlobalNamingResources !-- Define the Tomcat Stand-Alone Service -- Service name=Tomcat-Standalone !-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8080 -- Connector className=org.apache.coyote.tomcat4.CoyoteConnector port=8080 minProcessors=5 maxProcessors=75 enableLookups=true redirectPort=8443 acceptCount=100 debug=0