RE: DataSource realm, apply fix for 16316 bug, still not working ?
You need to configure the datasource you're using for authentication in GlobalNamingResources section of server.xml, not in your application context. -Original Message- Basicaly my own Realm implementation is copy/paste DataSourceRealm, I just changed preparedRoles and preparedCredentials in start() and also modified hasRole(Principal principal, String role) for my needs, but exception that I get is when opening DataSource which is defined in Context, it seemes that Context is not started yet when opening DB connection from Realm ? -- Nicholas Sushkin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: DataSource realm, apply fix for 16316 bug, still not working ?
Basicaly my own Realm implementation is copy/paste DataSourceRealm, I just changed preparedRoles and preparedCredentials in start() and also modified hasRole(Principal principal, String role) for my needs, but exception that I get is when opening DataSource which is defined in Context, it seemes that Context is not started yet when opening DB connection from Realm ? -Original Message- From: Glenn Nielsen [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 17:18 To: Tomcat Developers List Subject: Re: DataSource realm, apply fix for 16316 bug, still not working ? So the problem isn't in the DataSourceRealm that comes with Tomcat? It is in your own Realm implementation? If so, debugging the problem is up to you. From your config you might try using the fully qualified JNDI name in your Realm config java:env/jdbc/hsqldb. Regards, Glenn Uros Kotnik wrote: OK, I'm doing this: I made class - public class UserManager extends RealmBase It's almost same like DataSourceRealm just little changed to suit my DB. I deleted code parts from start() that validates that we can open our connection and also put this code part to public Principal authenticate(String username, String credentials) if (dbConnection == null) { return null; } This is where I get exception - private Connection open() { try { StandardServer server = (StandardServer) ServerFactory.getServer(); Context context = server.getGlobalNamingContext(); DataSource dataSource = (DataSource)context.lookup(dataSourceName); //exception here return dataSource.getConnection(); } catch (Exception e) { // Log the problem for posterity log(sm.getString(dataSourceRealm.exception), e); } return null; } This is from the log: - 003-02-25 15:09:16 DataSourceRealm[]: Exception performing authentication javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:811) at org.apache.naming.NamingContext.lookup(NamingContext.java:194) at org.asterius.tomcat.security.UserManager.open(UserManager.java:647) at org.asterius.tomcat.security.UserManager.authenticate(UserManager.java:4 80) at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAut henticator.java:263) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authenticator Base.java:480) This is Server.xml -- Context debug=0 docBase=C:\Projects\ipcs\ipcs path= workDir=C:\Projects\ipcs\ipcs Resource name=jdbc/hsqldb auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/hsqldb parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namemaxActive/name value100/value /parameter parameter namemaxIdle/name value30/value /parameter parameter namemaxWait/name value1/value /parameter !-- dB username and password for dB connections -- parameter nameusername/name valueiuser/value /parameter parameter namepassword/name valueiuser/value /parameter !-- Class name for JDBC driver -- parameter namedriverClassName/name valueorg.hsqldb.jdbcDriver/value /parameter parameter nameurl/name valuejdbc:hsqldb:hsql://asterix/value /parameter /ResourceParams Realm className=org.asterius.tomcat.security.UserManager debug=99 dataSourceName=jdbc/hsqldb userTable=ic_users userNameCol=login_name userCredCol=password userRoleTable=ic_groups roleNameCol=group_name linkUserRoleTable=ic_users_groups groupIDcol=id_group userIDcol=id_user userIDlang = id_language userRealName=real_name / -- Glenn Nielsen [EMAIL PROTECTED] | /* Spelin donut madder| MOREnet System Programming | * if iz ina coment. | Missouri Research and Education Network | */ | -- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: DataSource realm, apply fix for 16316 bug, still not working?
Take a step back and see if you can access the JDBC DataSource from a test jsp page in your context. First make sure your DataSource is configured correctly. Glenn Uros Kotnik wrote: Basicaly my own Realm implementation is copy/paste DataSourceRealm, I just changed preparedRoles and preparedCredentials in start() and also modified hasRole(Principal principal, String role) for my needs, but exception that I get is when opening DataSource which is defined in Context, it seemes that Context is not started yet when opening DB connection from Realm ? -Original Message- From: Glenn Nielsen [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 17:18 To: Tomcat Developers List Subject: Re: DataSource realm, apply fix for 16316 bug, still not working ? So the problem isn't in the DataSourceRealm that comes with Tomcat? It is in your own Realm implementation? If so, debugging the problem is up to you. From your config you might try using the fully qualified JNDI name in your Realm config java:env/jdbc/hsqldb. Regards, Glenn Uros Kotnik wrote: OK, I'm doing this: I made class - public class UserManager extends RealmBase It's almost same like DataSourceRealm just little changed to suit my DB. I deleted code parts from start() that validates that we can open our connection and also put this code part to public Principal authenticate(String username, String credentials) if (dbConnection == null) { return null; } This is where I get exception - private Connection open() { try { StandardServer server = (StandardServer) ServerFactory.getServer(); Context context = server.getGlobalNamingContext(); DataSource dataSource = (DataSource)context.lookup(dataSourceName); //exception here return dataSource.getConnection(); } catch (Exception e) { // Log the problem for posterity log(sm.getString(dataSourceRealm.exception), e); } return null; } This is from the log: - 003-02-25 15:09:16 DataSourceRealm[]: Exception performing authentication javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:811) at org.apache.naming.NamingContext.lookup(NamingContext.java:194) at org.asterius.tomcat.security.UserManager.open(UserManager.java:647) at org.asterius.tomcat.security.UserManager.authenticate(UserManager.java:4 80) at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAut henticator.java:263) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authenticator Base.java:480) This is Server.xml -- Context debug=0 docBase=C:\Projects\ipcs\ipcs path= workDir=C:\Projects\ipcs\ipcs Resource name=jdbc/hsqldb auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/hsqldb parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namemaxActive/name value100/value /parameter parameter namemaxIdle/name value30/value /parameter parameter namemaxWait/name value1/value /parameter !-- dB username and password for dB connections -- parameter nameusername/name valueiuser/value /parameter parameter namepassword/name valueiuser/value /parameter !-- Class name for JDBC driver -- parameter namedriverClassName/name valueorg.hsqldb.jdbcDriver/value /parameter parameter nameurl/name valuejdbc:hsqldb:hsql://asterix/value /parameter /ResourceParams Realm className=org.asterius.tomcat.security.UserManager debug=99 dataSourceName=jdbc/hsqldb userTable=ic_users userNameCol=login_name userCredCol=password userRoleTable=ic_groups roleNameCol=group_name linkUserRoleTable=ic_users_groups groupIDcol=id_group userIDcol=id_user userIDlang = id_language userRealName=real_name / -- Glenn Nielsen [EMAIL PROTECTED] | /* Spelin donut madder| MOREnet System Programming | * if iz ina coment. | Missouri Research and Education Network | */ | -- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: DataSource realm, apply fix for 16316 bug, still not working ?
Basicaly my own Realm implementation is copy/paste DataSourceRealm, I just changed preparedRoles and preparedCredentials in start() and also modified hasRole(Principal principal, String role) for my needs, but exception that I get is when opening DataSource which is defined in Context, it seemes that Context is not started yet when opening DB connection from Realm ? -Original Message- From: Glenn Nielsen [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 17:18 To: Tomcat Developers List Subject: Re: DataSource realm, apply fix for 16316 bug, still not working ? So the problem isn't in the DataSourceRealm that comes with Tomcat? It is in your own Realm implementation? If so, debugging the problem is up to you. From your config you might try using the fully qualified JNDI name in your Realm config java:env/jdbc/hsqldb. Regards, Glenn Uros Kotnik wrote: OK, I'm doing this: I made class - public class UserManager extends RealmBase It's almost same like DataSourceRealm just little changed to suit my DB. I deleted code parts from start() that validates that we can open our connection and also put this code part to public Principal authenticate(String username, String credentials) if (dbConnection == null) { return null; } This is where I get exception - private Connection open() { try { StandardServer server = (StandardServer) ServerFactory.getServer(); Context context = server.getGlobalNamingContext(); DataSource dataSource = (DataSource)context.lookup(dataSourceName); //exception here return dataSource.getConnection(); } catch (Exception e) { // Log the problem for posterity log(sm.getString(dataSourceRealm.exception), e); } return null; } This is from the log: - 003-02-25 15:09:16 DataSourceRealm[]: Exception performing authentication javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:811) at org.apache.naming.NamingContext.lookup(NamingContext.java:194) at org.asterius.tomcat.security.UserManager.open(UserManager.java:647) at org.asterius.tomcat.security.UserManager.authenticate(UserManager.java:4 80) at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAut henticator.java:263) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authenticator Base.java:480) This is Server.xml -- Context debug=0 docBase=C:\Projects\ipcs\ipcs path= workDir=C:\Projects\ipcs\ipcs Resource name=jdbc/hsqldb auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/hsqldb parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namemaxActive/name value100/value /parameter parameter namemaxIdle/name value30/value /parameter parameter namemaxWait/name value1/value /parameter !-- dB username and password for dB connections -- parameter nameusername/name valueiuser/value /parameter parameter namepassword/name valueiuser/value /parameter !-- Class name for JDBC driver -- parameter namedriverClassName/name valueorg.hsqldb.jdbcDriver/value /parameter parameter nameurl/name valuejdbc:hsqldb:hsql://asterix/value /parameter /ResourceParams Realm className=org.asterius.tomcat.security.UserManager debug=99 dataSourceName=jdbc/hsqldb userTable=ic_users userNameCol=login_name userCredCol=password userRoleTable=ic_groups roleNameCol=group_name linkUserRoleTable=ic_users_groups groupIDcol=id_group userIDcol=id_user userIDlang = id_language userRealName=real_name / -- Glenn Nielsen [EMAIL PROTECTED] | /* Spelin donut madder| MOREnet System Programming | * if iz ina coment. | Missouri Research and Education Network | */ | -- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: DataSource realm, apply fix for 16316 bug, still not working?
The code for DataSourceRealm defers obtaining the db connection from the JNDI named JDBC DataSource until it is used, after the context is started. What you are trying to do should work. Please post more information about your configuration and any stack traces or errors which get logged. Glenn Uros Kotnik wrote: Hi, Applyed fix for bug 16316, DataSourceRealm can not find JNDI name in context. Before fix solution was to put JNDI Named DataSource which is used by the DataSourceRealm in the GlobalNamingResources section of your server.xml config and that worked. I thought than now I can left JNDI Named DataSource from GlobalNamingResources and put it in Context (or use JNDI Named DataSource that I defined in context) but I still get Name jdbc is not bound in this Context. Thanx. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: DataSource realm, apply fix for 16316 bug, still not working ?
OK, I'm doing this: I made class - public class UserManager extends RealmBase It's almost same like DataSourceRealm just little changed to suit my DB. I deleted code parts from start() that validates that we can open our connection and also put this code part to public Principal authenticate(String username, String credentials) if (dbConnection == null) { return null; } This is where I get exception - private Connection open() { try { StandardServer server = (StandardServer) ServerFactory.getServer(); Context context = server.getGlobalNamingContext(); DataSource dataSource = (DataSource)context.lookup(dataSourceName); //exception here return dataSource.getConnection(); } catch (Exception e) { // Log the problem for posterity log(sm.getString(dataSourceRealm.exception), e); } return null; } This is from the log: - 003-02-25 15:09:16 DataSourceRealm[]: Exception performing authentication javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:811) at org.apache.naming.NamingContext.lookup(NamingContext.java:194) at org.asterius.tomcat.security.UserManager.open(UserManager.java:647) at org.asterius.tomcat.security.UserManager.authenticate(UserManager.java:4 80) at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAut henticator.java:263) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authenticator Base.java:480) This is Server.xml -- Context debug=0 docBase=C:\Projects\ipcs\ipcs path= workDir=C:\Projects\ipcs\ipcs Resource name=jdbc/hsqldb auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/hsqldb parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namemaxActive/name value100/value /parameter parameter namemaxIdle/name value30/value /parameter parameter namemaxWait/name value1/value /parameter !-- dB username and password for dB connections -- parameter nameusername/name valueiuser/value /parameter parameter namepassword/name valueiuser/value /parameter !-- Class name for JDBC driver -- parameter namedriverClassName/name valueorg.hsqldb.jdbcDriver/value /parameter parameter nameurl/name valuejdbc:hsqldb:hsql://asterix/value /parameter /ResourceParams Realm className=org.asterius.tomcat.security.UserManager debug=99 dataSourceName=jdbc/hsqldb userTable=ic_users userNameCol=login_name userCredCol=password userRoleTable=ic_groups roleNameCol=group_name linkUserRoleTable=ic_users_groups groupIDcol=id_group userIDcol=id_user userIDlang = id_language userRealName=real_name / -Original Message- From: Glenn Nielsen [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 14:52 To: Tomcat Developers List Subject: Re: DataSource realm, apply fix for 16316 bug, still not working ? The code for DataSourceRealm defers obtaining the db connection from the JNDI named JDBC DataSource until it is used, after the context is started. What you are trying to do should work. Please post more information about your configuration and any stack traces or errors which get logged. Glenn Uros Kotnik wrote: Hi, Applyed fix for bug 16316, DataSourceRealm can not find JNDI name in context. Before fix solution was to put JNDI Named DataSource which is used by the DataSourceRealm in the GlobalNamingResources section of your server.xml config and that worked. I thought than now I can left JNDI Named DataSource from GlobalNamingResources and put it in Context (or use JNDI Named DataSource that I defined in context) but I still get Name jdbc is not bound in this Context. Thanx. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: DataSource realm, apply fix for 16316 bug, still not working?
So the problem isn't in the DataSourceRealm that comes with Tomcat? It is in your own Realm implementation? If so, debugging the problem is up to you. From your config you might try using the fully qualified JNDI name in your Realm config java:env/jdbc/hsqldb. Regards, Glenn Uros Kotnik wrote: OK, I'm doing this: I made class - public class UserManager extends RealmBase It's almost same like DataSourceRealm just little changed to suit my DB. I deleted code parts from start() that validates that we can open our connection and also put this code part to public Principal authenticate(String username, String credentials) if (dbConnection == null) { return null; } This is where I get exception - private Connection open() { try { StandardServer server = (StandardServer) ServerFactory.getServer(); Context context = server.getGlobalNamingContext(); DataSource dataSource = (DataSource)context.lookup(dataSourceName); //exception here return dataSource.getConnection(); } catch (Exception e) { // Log the problem for posterity log(sm.getString(dataSourceRealm.exception), e); } return null; } This is from the log: - 003-02-25 15:09:16 DataSourceRealm[]: Exception performing authentication javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:811) at org.apache.naming.NamingContext.lookup(NamingContext.java:194) at org.asterius.tomcat.security.UserManager.open(UserManager.java:647) at org.asterius.tomcat.security.UserManager.authenticate(UserManager.java:4 80) at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAut henticator.java:263) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authenticator Base.java:480) This is Server.xml -- Context debug=0 docBase=C:\Projects\ipcs\ipcs path= workDir=C:\Projects\ipcs\ipcs Resource name=jdbc/hsqldb auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/hsqldb parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namemaxActive/name value100/value /parameter parameter namemaxIdle/name value30/value /parameter parameter namemaxWait/name value1/value /parameter !-- dB username and password for dB connections -- parameter nameusername/name valueiuser/value /parameter parameter namepassword/name valueiuser/value /parameter !-- Class name for JDBC driver -- parameter namedriverClassName/name valueorg.hsqldb.jdbcDriver/value /parameter parameter nameurl/name valuejdbc:hsqldb:hsql://asterix/value /parameter /ResourceParams Realm className=org.asterius.tomcat.security.UserManager debug=99 dataSourceName=jdbc/hsqldb userTable=ic_users userNameCol=login_name userCredCol=password userRoleTable=ic_groups roleNameCol=group_name linkUserRoleTable=ic_users_groups groupIDcol=id_group userIDcol=id_user userIDlang = id_language userRealName=real_name / -- Glenn Nielsen [EMAIL PROTECTED] | /* Spelin donut madder| MOREnet System Programming | * if iz ina coment. | Missouri Research and Education Network | */ | -- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]