-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Søren,

Søren Blidorf wrote:
> I do mean realm and the reason why I mention it is that I can validate users
> via my users and user_roles in my db, so the connection should work I guess?

That depends upon your connection settings.

>         <Context path="/xx" docBase="webapp" reloadable="true">
>          <Realm  name="UMRealm"

This looks good... and it should, since it apparently works.

> Get the connection with: DriverManager.getConnection(    connectionUrl,
> connectionUser,    connectionPass)

This is just about the simplest way to get a connection. Are you using
the same URL, username, and password? I don't see why this wouldn't
work. On the other hand, I'd never do it this way: I'd use a connection
pool (see below).

> I also just upgrade my struts could it be a taglib thing?

This should have nothing to do with either Struts or your taglibs
(unless you use taglibs for SQL queries... <shiver>).

My recommendation is to use a JNDI datasource and then use that for both
your "in-app" database connections as well as the <Realm>. Basically,
you change your <Context> element to include:

<Resource [see documentation for JNDI DataSource] />
<Realm [see documentation for DataSourceRealm;
        don't forget to set localDataSource="true"] />

Then, in your code, you'll need a slightly more complicated way of
getting a database connection. But, you already have your "get
connection" logic in a method used everywhere, right?

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.swl.DataSource;

public Connection getConnection()
    throws SQLException, NamingException
{
    Context ctx = new InitialContext();

    DataSource ds = (DataSource)ctx.lookup(DATASOURCE_PATH);

    if(null == ds)
        throw new NamingException("Cannot obtain DataSource");

    return ds.getConnection();
}

This way, both the Realm and your application are using the same pool of
connections. This avoids weird situations where your realm works but not
your application (and vice versa).

Hope that helps,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGe8AQ9CaO5/Lv0PARAmz5AJoCusXnwWzOobA8UaJxaLp0iJfdMwCguf9S
OpmaxB78ll5KigAJdUB4At4=
=Q5C4
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to