Robert Harper wrote:

I am using the Tomcat user database to hold information for users. What I need to do is retrieve the group a user is in from the database. My problem comes when I have a servlet add a new user, assign it to a roll and a group, then try to access the user from another servlet running in the same context. I often get exceptions thrown when I call the save() method on the user object stating that Tomcat cannot rename the tomcat-users.xml to tomcat-users.xml.old. The user info is still in memory and if enough time passes or the server is stopped, the data eventually gets flushed to disk. There are methods for finding the user, finding a roll, and finding a group, but I don’t see a method for finding a group for a given user using the MBeanServer().

I had been using the XML libraries to load the database and then search through it finding the user then getting the assigned roll but it only works when the new user information is flushed to disk. What would be the best way to do this?

Use some kind of a database related realm:

   * http://tomcat.apache.org/tomcat-5.5-doc/realm-howto.html#JDBCRealm
   * http://tomcat.apache.org/tomcat-5.5-doc/realm-howto.html#DataSourceRealm

Memory realm (tomcat-users.xml file) is a very simple one, following documentation: "*MemoryRealm* is a simple demonstration implementation of the Tomcat 5 |Realm| interface. It is not designed for production use."

--
Mikolaj Rydzewski      <[EMAIL PROTECTED]>        http://ceti.pl/~miki/
                   PGP KeyID: 8b12ab02
There are three kinds of people: men, women and unix.

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to