Doh ! Found that my ejb-jar.xml was missing the ejb-role-ref element, however I am still getting the same Exception .....
Good news and bad news.
Good news is that you are not alone.
Bad news is you have another fellow programmer who spent more than 10 hours and still cannot solve this problem. I have ruled out database problems (I use mysql and Jboss 3.0.6). It has nothing to do with the login-config.xml (I switched to flat-file and it worked fine). For some reasons, the role is not passed to the system some of the time (not all the time, in some cases, it did work out). I plan to update my jboss to the latest version and see what will happen.
I appreciate your response. I have now tried the 3.0.7 release and I get exactly the same behaviour. Inspecting the log output of my JDBC driver it is clear that both the principalsQuery, and the rolesQuery are being executed - but presumably the login module is not able to retrieve the values from the result set ...
Thanks and regards,
The rolesQuery in your login-config.xml must be
<module-option name="rolesQuery">select role, 'Roles' from user_role ur, user_regn u where ur.user_id = u.user_id and user_login = ?</module-option>
Many thanks Harald - you solved it - it works now!!!
I was resorting to instrumenting the source to try and figure out the problem - so you've saved me a lot of time.