tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uros Kotnik" <u...@asterius.co.yu>
Subject RE: DataSource realm, apply fix for 16316 bug, still not working ?
Date Mon, 03 Mar 2003 08:17:16 GMT
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:glenn@mail.more.net] 
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>
>       <name>factory</name>
>       <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
>     </parameter>
> 
>     <parameter>
>       <name>maxActive</name>
>       <value>100</value>
>     </parameter>
> 
>     <parameter>
>       <name>maxIdle</name>
>       <value>30</value>
>     </parameter>
> 
>    
>     <parameter>
>       <name>maxWait</name>
>       <value>10000</value>
>     </parameter>
> 
>     <!-- dB username and password for dB connections  -->
>     <parameter>
>      <name>username</name>
>      <value>iuser</value>
>     </parameter>
>     <parameter>
>      <name>password</name>
>      <value>iuser</value>
>     </parameter>
> 
>     <!-- Class name for JDBC driver -->
>     <parameter>
>        <name>driverClassName</name>
>        <value>org.hsqldb.jdbcDriver</value>       
>     </parameter>
> 
>     <parameter>
>       <name>url</name>
>       <value>jdbc: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             glenn@more.net | /* Spelin donut madder    |
MOREnet System Programming               |  * if iz ina coment.      |
Missouri Research and Education Network  |  */                       |
----------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message