users@glassfish.java.net

Re: Can't get JDBCRealm to work with MySQL

From: <glassfish_at_javadesktop.org>
Date: Mon, 23 Apr 2007 13:03:33 PDT

I got this working and finally did figure out the problem -- at least with my installation. I suspect that there are many different ways for this not to work.

In my case, the problem was that I followed a JDBCRealm example that used uppercase names for database tables and fields. I am using EJB annotations with default table and field name mappings. So, my Contact object maps to database table, Contact, not CONTACT, as I had used in my JDBCRealm definition in domain.xml. This is fine in Windows, which from what I can gather is case insensitive, but did not work in Linux/Redhat, which appears to be case sensitive.

To fix this, I changed my realm definition from #1 to #2, below:

#1:
<auth-realm classname="com.sun.enterprise.security.auth.realm.jdbc.JDBCRealm" name="smash-users">
<property name="jaas-context" value="jdbcRealm"/>
<property name="datasource-jndi" value="jdbc/smashmysql"/>
<property name="user-table" value="CONTACT"/>
<property name="user-name-column" value="USERNAME"/>
<property name="password-column" value="PASSWORD"/>
<property name="group-table" value="USERGROUP"/>
<property name="group-name-column" value="GROUPNAME"/>
<property name="digest-algorithm" value="MD5"/>
</auth-realm>

#2:
    </auth-realm>
        <auth-realm classname="com.sun.enterprise.security.auth.realm.jdbc.JDBCRealm" name=
"smash-users">
          <property name="jaas-context" value="jdbcRealm"/>
          <property name="datasource-jndi" value="jdbc/smashmysql"/>
          <property name="user-table" value="Contact"/>
          <property name="user-name-column" value="username"/>
          <property name="password-column" value="password"/>
          <property name="group-table" value="UserGroup"/>
          <property name="group-name-column" value="groupName"/>
          <property name="digest-algorithm" value="MD5"/>
        </auth-realm>

I suggest that you turn Security logging to FINEST, as Shing Wai Chan suggested, and I also suggest using Shing Wai's blog post as a guide:
http://blogs.sun.com/swchan/entry/jdbcrealm_in_glassfish.

I have not marked this question closed yet, as it is clearly not closed for at least one other person.

Rick
[Message sent by forum member 'rickhoro' (rickhoro)]

http://forums.java.net/jive/thread.jspa?messageID=213820