I compiled and ran your SecurityTest project.
I made 2 changes:
1) I changed the name of the realm to my realm (userauth)
2) I changed the name of the groups in sun-web.xml like so:
before
<security-role-mapping>
<role-name>USERS</role-name>
<group-name>users</group-name>
</security-role-mapping>
after
<security-role-mapping>
<role-name>USERS</role-name>
<group-name>USERS</group-name>
</security-role-mapping>
-- these changes are to match my system.
The servlet ran just fine. You have everything set up perfectly in the web module.
Your problem *may* be the "USERS" versus "users". The <group-name> value must match the name of the group in the DB table -- exactly. Case matters!
If that isn't the problem then the problem is in how you set up the JDBC Pool, jdbc-resource and realm in GlassFish.
Here is my advice:
1) Look in your DB group table -- if the name of the group is "USERS" rather than "users" than you can quickly solve the problem by editing sun-web.xml
2)If that isn't the problem -- then recreate the server side stuff. It shouldn't take more than a few minutes. Read my blogs for step-by-step instructions.
3)If you don't want to do (2) then you need to make some JDBC calls using the jdbc-resource that the realm is using. If you look through all the postings in theis thread you'll see exactly how to do that.
I attached a screenshot of the successful run of your test app.
good luck!
[Message sent by forum member 'bnevins' (bnevins)]
http://forums.java.net/jive/thread.jspa?messageID=239230