You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by joelsherriff <jo...@comcast.net> on 2005/04/22 21:56:20 UTC

Help with JDBCRealm config on Tomcat 4.1

Hope someone can help me - I'm still a relative newbie to tomcat, am baffled
at this point and I can't even get it configured so that I
can get debug info to find out what's wrong.

I've added a context to my server.xml for the webapp I'm trying to set up
JDBCRealm authentication for:

      <Context path="/blojsom" docBase="blojsom" debug="99" >
            <Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_blojsom_log." suffix=".txt" timestamp="true" />
            <Realm  className="org.apache.catalina.realm.JDBCRealm"
debug="99" driverName="org.gjt.mm.mysql.Driver"

connectionURL="jdbc:mysql://localhost/mydatabase?user=xxxxxx;password=xxxxxx
"
                connectionName="xxxxxx" connectionPassword="xxxxxx"
digest="MD5"
                userTable="users" userNameCol="userid"
userCredCol="md5password"
                userRoleTable="user_roles" roleNameCol="role_name" />
      </Context>

And, of course, added the supporting tables and roles to my database.  When
I attempt to access a page from the webapp,
my login.jsp page is displayed, and when I attempt to login, my error.jsp
page is displayed.   I didn't expect this to work
correctly the first time I configured it,  and it's not, but my problem is
that I can't figure out how to debug it at all.  The
Logger I have configured in the webapp's Context does nothing - doesn't
create the log file and nothing is logged
anywhere else either.   How can I further debug it?

Now, if I take the Realm out of the Context (applying it to the entire
server), I get an exception in my catalina_log:

2005-04-22 15:26:10 JDBCRealm[Standalone]: Exception performing
authentication
java.sql.SQLException: org.gjt.mm.mysql.Driver
 at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:588)
 at org.apache.catalina.realm.JDBCRealm.authenticate(JDBCRealm.java:343)

Though it doesn't say it precisely, I think this implies that it's not
connecting to the DB, but the db, user and password values are all correct.

Basically, I have three problems:  why can't I get logging to work from
within a specific context,  am I doing something wrong in my attempt
to get JDBCRealm authentication to work, and what is the right way to debug
the problem further, if the solution isn't obvious?

Also, I've added to my webapp's web.xml file:

<security-constraint>
<web-resource-collection>
<web-resource-name>Entire Application</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>users</role-name>
</auth-constraint>
</security-constraint>

<login-config>
<auth-method>FORM</auth-method>
<realm-name>Users</realm-name>
<form-login-config>
<form-login-page>/login.jsp</form-login-page>
<form-error-page>/error.jsp</form-error-page>
</form-login-config>
</login-config>

<security-role>
<description>
Some Stuff
</description>
<role-name>users</role-name>
</security-role>





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


Re: Any better way to do this?

Posted by joelsherriff <jo...@comcast.net>.
Thanks for the input.  Very appreciated.  There seem to be so many
configuration options in tomcat that I wasn't
sure if I was trying to use filters when something else was already there
waiting for me to use.


----- Original Message ----- 
From: "Will Hartung" <wi...@msoft.com>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Monday, April 25, 2005 8:14 PM
Subject: Re: Any better way to do this?


> > From: "joelsherriff" <jo...@comcast.net>
> > Sent: Monday, April 25, 2005 4:16 PM
>
> > I want to setup what is basically a blog server - so that user's must
> login
> > and can then access
> > their personal blog, but nobody elses.  I think I can do this using a
> > servlet filter to trap requests to the
> > blog pages, lookup the user's blog page url using the session info, and
> > modify the request to point
> > to his/her own blog, regardless of what blog they initially requested.
> >
> > Seems like there ought to be a better way but I'm pretty new to tomcat
so
> > .... is there?
>
> Actually that's a perfect way to do it. You simply write the filter,
install
> it, and be done with it. The challenge being integrating with the Blog
> software's registration system, perhaps, but the beauty of the system is
> that the blogging servlets/JSPs/etc. are totally ignorant of the change,
and
> you can move ahead with very little knowledge of how the blogging software
> works or is configured. It's a nice, non-invasive system to do exactly
what
> you want.
>
> Regards,
>
> Will Hartung
> (willh@msoft.com)
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>



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


Re: Any better way to do this?

Posted by Will Hartung <wi...@msoft.com>.
> From: "joelsherriff" <jo...@comcast.net>
> Sent: Monday, April 25, 2005 4:16 PM

> I want to setup what is basically a blog server - so that user's must
login
> and can then access
> their personal blog, but nobody elses.  I think I can do this using a
> servlet filter to trap requests to the
> blog pages, lookup the user's blog page url using the session info, and
> modify the request to point
> to his/her own blog, regardless of what blog they initially requested.
>
> Seems like there ought to be a better way but I'm pretty new to tomcat so
> .... is there?

Actually that's a perfect way to do it. You simply write the filter, install
it, and be done with it. The challenge being integrating with the Blog
software's registration system, perhaps, but the beauty of the system is
that the blogging servlets/JSPs/etc. are totally ignorant of the change, and
you can move ahead with very little knowledge of how the blogging software
works or is configured. It's a nice, non-invasive system to do exactly what
you want.

Regards,

Will Hartung
(willh@msoft.com)


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


Any better way to do this?

Posted by joelsherriff <jo...@comcast.net>.
I want to setup what is basically a blog server - so that user's must login
and can then access
their personal blog, but nobody elses.  I think I can do this using a
servlet filter to trap requests to the
blog pages, lookup the user's blog page url using the session info, and
modify the request to point
to his/her own blog, regardless of what blog they initially requested.

Seems like there ought to be a better way but I'm pretty new to tomcat so
.... is there?



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


Re: Help with JDBCRealm config on Tomcat 4.1

Posted by joelsherriff <jo...@comcast.net>.
Well I've got JDBCRealm working for the entire server, but when I try to
wrap the realm in a context for a specific
webapp it stops working.  Anyone have any ideas why?  Is my Context
specification not correct?

<Context path="/blojsom" docBase="blojsom" debug="99" >
<Realm  className="org.apache.catalina.realm.JDBCRealm" debug="99"
driverName="com.mysql.jdbc.Driver"
        connectionURL="jdbc:mysql://localhost/mydatabase"
        connectionName="xxxxxx" connectionPassword="xxxxxx" digest="MD5"
        userTable="users" userNameCol="userid"
        userCredCol="md5password"
        userRoleTable="user_roles" roleNameCol="role_name" />
</Context>


----- Original Message ----- 
From: "joelsherriff" <jo...@comcast.net>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Friday, April 22, 2005 3:56 PM
Subject: Help with JDBCRealm config on Tomcat 4.1


> Hope someone can help me - I'm still a relative newbie to tomcat, am
baffled
> at this point and I can't even get it configured so that I
> can get debug info to find out what's wrong.
>
> I've added a context to my server.xml for the webapp I'm trying to set up
> JDBCRealm authentication for:
>
>       <Context path="/blojsom" docBase="blojsom" debug="99" >
>             <Logger className="org.apache.catalina.logger.FileLogger"
> prefix="localhost_blojsom_log." suffix=".txt" timestamp="true" />
>             <Realm  className="org.apache.catalina.realm.JDBCRealm"
> debug="99" driverName="org.gjt.mm.mysql.Driver"
>
>
connectionURL="jdbc:mysql://localhost/mydatabase?user=xxxxxx;password=xxxxxx
> "
>                 connectionName="xxxxxx" connectionPassword="xxxxxx"
> digest="MD5"
>                 userTable="users" userNameCol="userid"
> userCredCol="md5password"
>                 userRoleTable="user_roles" roleNameCol="role_name" />
>       </Context>
>
> And, of course, added the supporting tables and roles to my database.
When
> I attempt to access a page from the webapp,
> my login.jsp page is displayed, and when I attempt to login, my error.jsp
> page is displayed.   I didn't expect this to work
> correctly the first time I configured it,  and it's not, but my problem is
> that I can't figure out how to debug it at all.  The
> Logger I have configured in the webapp's Context does nothing - doesn't
> create the log file and nothing is logged
> anywhere else either.   How can I further debug it?
>
> Now, if I take the Realm out of the Context (applying it to the entire
> server), I get an exception in my catalina_log:
>
> 2005-04-22 15:26:10 JDBCRealm[Standalone]: Exception performing
> authentication
> java.sql.SQLException: org.gjt.mm.mysql.Driver
>  at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:588)
>  at org.apache.catalina.realm.JDBCRealm.authenticate(JDBCRealm.java:343)
>
> Though it doesn't say it precisely, I think this implies that it's not
> connecting to the DB, but the db, user and password values are all
correct.
>
> Basically, I have three problems:  why can't I get logging to work from
> within a specific context,  am I doing something wrong in my attempt
> to get JDBCRealm authentication to work, and what is the right way to
debug
> the problem further, if the solution isn't obvious?
>
> Also, I've added to my webapp's web.xml file:
>
> <security-constraint>
> <web-resource-collection>
> <web-resource-name>Entire Application</web-resource-name>
> <url-pattern>/*</url-pattern>
> </web-resource-collection>
> <auth-constraint>
> <role-name>users</role-name>
> </auth-constraint>
> </security-constraint>
>
> <login-config>
> <auth-method>FORM</auth-method>
> <realm-name>Users</realm-name>
> <form-login-config>
> <form-login-page>/login.jsp</form-login-page>
> <form-error-page>/error.jsp</form-error-page>
> </form-login-config>
> </login-config>
>
> <security-role>
> <description>
> Some Stuff
> </description>
> <role-name>users</role-name>
> </security-role>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>



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