I was doing some serious stress testing on a bean with cmr, and in that process I found some strange behaviour. My test does the following:
1. Creates a logincontext (database login module)
2. Logs in
3. Creates an initialcontext
4. Looks up a stateless session bean
5. Calls home.create()
6. Calls a method getCustomerById() on the remote interface
7. Calls getData() on the resulting entity bean
8. Logs out
This is done in many simultaneous threads to test concurrency, tx settings, locking etc. Now, what I found, was that using 100 threads works fine on the first run. Subsequent runs after appr. 20-30 seconds fail after 40-50 threads. The failure is reported as a JAAS login exception, where the session bean complains about incorrect role memberships (that are null), but the real reason is that the database has no more connections, and therefore JAAS cannot the role memberships for the user since I am using the database login module.
Somewhere along the line an exception is caught and JAAS continues, thinking the user had no roles, which is wrong. Anyone care to elaborate on this issue?
Should we perhaps add some "system" connections that are reserved in the pool, so that system-critical things like JAAS aren't affected by connection stuff like this?
You could configure a separate datasource (pool) that you configure for your database login module, no?
Have JAAS login module use java:/authenticationSource and your beans use java:/dataSource connecting to same database...