On 7 Oct 2012, at 15:26, Aladin Dajani <aladin.daj...@gmail.com> wrote:

> OK So I tried to use DataSourceRealm.  Seems simple enough. but I get the
> following exception:
>
> Oct 7, 2012 9:54:51 AM org.apache.catalina.realm.DataSourceRealm open
> SEVERE: Exception performing authentication
> javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
>
> Here is my configuration.  context.xml is unchanged from previous setup
> (works well for pooled database access within the app)
>
> {catalina-base}\conf\context.xml:
>    <Resource
> name="jdbc/MyAppDB"
> auth="Container"
> driverClassName="com.mysql.jdbc.Driver"
> logAbandoned="true"
> maxActive="100"
> maxIdle="30"
> maxWait="10000"
> password="password"
> username="user"
> removeAbandoned="true"
> removeAbandonedTimeout="60"
> type="javax.sql.DataSource"
> url="jdbc:mysql://localhost:3306/databasename"
> />
>
> Server.xml replaces the JDBCRealm with the DataSourceRealm as below
>
> {catalina-base}\conf\server.xml:
>      <Realm className="org.apache.catalina.realm.LockOutRealm">
> <Realm className="org.apache.catalina.realm.DataSourceRealm"
> dataSourceName="jdbc/MyAppDB"
> userTable="users"
> userNameCol="username"
> userCredCol="password"
> userRoleTable="roles"
> roleNameCol="rolename"
>        digest="MD5"
> />
>      </Realm>
>
> Have I missed a configuration somewhere ?

Yes, define the Resource in GlobalResources in server.xml.


p




>
> Thanks.
> On Sun, Oct 7, 2012 at 9:36 AM, Felix Schumacher <
> felix.schumac...@internetallee.de> wrote:
>
>>
>>
>> Aladin Dajani <aladin.daj...@gmail.com> schrieb:
>>
>>> Hello List,
>>>
>>> My application is configured for JDBCRealm authentication uses a MySQL
>>> database.
>>> For my own use inside the application, I have setup a connection pool
>>> to
>>> access the database,  However, the configuration of JDBCRealm in
>>> server.xml
>>> uses astand-alone connection.  Since MySQL times-out connections after
>>> 8
>>> hours, I get the following error in tomcat logs as I try to log-in
>>> after
>>> the connection times out:
>>>
>>> Oct 7, 2012 8:36:51 AM org.apache.catalina.realm.JDBCRealm getPassword
>>> SEVERE: Exception performing authentication
>>> com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
>>> No
>>> operations allowed after connection closed.Connection was implicitly
>>> closed
>>> by the driver.
>>>
>>> Users do not notice this error (I presume tomcat's JDBCRealm will
>>> create a
>>> new connection), but it US disconcerting to have all these exceptions
>>> in
>>> tomcat logs, especially that when the server goes into production mode,
>>> I
>>> fear this will have adverse effects.
>>>
>>> Is it possible to have JDBDRealm use the same connection pool which my
>>> application uses (which is setup in tomcat's context.xml so it should
>>> be accessible to all applications in tomcat).
>>
>> Have a look at DatasourceRealm.
>>
>> Regards
>> Felix
>>>
>>> Thanks.
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>> For additional commands, e-mail: users-h...@tomcat.apache.org
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to