[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Tomcat issue: How to get a realm stored in a database rather than from a file

Posted on 2004-11-02
Medium Priority
Last Modified: 2010-04-01
hi all,

how to get a realm stored in a database rather than from a file
i m using struts 1.1, tomcat 5.0.28, mysql...

1. so far this works fine for me (with basic j_security_check)

    <Resource name="MyUsers" auth="Container"
            description="User database that can be updated and saved">
    <ResourceParams name="MyUsers">

2. but i prefer to get the username and password from the datebase,
    after refer to the document, i did sth like this in serverl.xml (but it doesnt work)... please help

<!-- (Comment out!!)
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
                 debug="0" resourceName="UserDatabase"/>
      <Realm  className="org.apache.catalina.realm.JDBCRealm" debug="0"
         connectionName="xxx" connectionPassword="xxx"
              userTable="user" userNameCol="username" userCredCol="password"
          userRoleTable="user" roleNameCol="depname" />

Question by:tsunpo
  • 6
  • 3
LVL 35

Accepted Solution

TimYates earned 2000 total points
ID: 12481560
Does this step-by-step guide help any?

LVL 35

Expert Comment

ID: 12481568
Also, make sure your connect string is in the format:


And check catalina.out for JDBC errors on startup...

Author Comment

ID: 12481632
Hi TimYates,

Thats what I refered to... but doesnt work...  :p

Accidentally found the solution by wild guess... knackered

        <Context path="/bioinfo" docBase="bioinfo" debug="0" reloadable="true">
          <Realm  className="org.apache.catalina.realm.JDBCRealm" debug="0"
             connectionName="xxx" connectionPassword="xxx"
                  userTable="users" userNameCol="user_name" userCredCol="user_pass"
              userRoleTable="user_roles" roleNameCol="role_name"/>

Me is doing bioinfomatics as well, hope to ask you other questions somedays.

Thanks anyway,
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 35

Expert Comment

ID: 12481648
Ahhh...wrong driver class eh?  Yeah, it's confusing as there are 2 out there...  and it's hard to tell which one you have (I have even seen them combined) ;-)

Yay!  Bioinformatics :-) whereabouts are you doing it?
LVL 35

Expert Comment

ID: 12481650
Oooooh!  Thanks for the points too!!

I'll have to help extra hard with your next question ;-)


Author Comment

ID: 12481806
Hi Tim,

no no no no... did u see the <Context> part, thats the right place to put <Realm> :p
it seems either port number or driver is not the main issue of this problem...

i don know if it is the proper way to do with Struts. Say, what will u do to cope with
the login logout via a database rather than MemoryUserDatabaseFactory  :)

my company is doing genotyping, mapping and all the SNP things
LVL 35

Expert Comment

ID: 12481834
Ooooh, SNP :-)

Ahhh, the way I do it is with my own classes and table of users and encrypted passwords (then using the session to store the user's details), and not via the Tomcat realm...

Your way would work just as well (afaik)

Author Comment

ID: 12481909
any step-by-step articles??  :p  thanks in advance

SNP, microarray, AoD, Sequencing, FP...
LVL 35

Expert Comment

ID: 12482078
I do my login "kinda" like this:


Heh, as you can see, I currently use Struts (though I am now looking into JSF, which seems like an immprovement, but I'll know more after I read my 200 page book I just bought) ;-)

I store the passwords as MD5 hashes in the database, so they cannot be extracted if anyone just views the table...

Basically, take username, encrypt password, send to business layer, if that returns a user, then add that user object to the session (so I can then display information like fullname, address, etc ;-)

But as I said, your way is cool too :-)

> SNP, microarray, AoD, Sequencing, FP...

We do similar stuff to you from the sound of it :-)

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
Strategic internal linking is often considered an SEO power technique, especially for content marketing. Do you need to hire an SEO agency to optimize you internal linking? No, this article will help you understand the basics of internal linking and…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month19 days, 14 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question