The problem I faced was, that JBoss is throwing a EJBAccessException when login failed but I neeed the LoginException thrown from my LoginModule to display the cause in the client.
There is a Bug open since March 2011 but no solution: https://issues.jboss.org/browse/JBAS-9203
And even in the newest JBoss 7 this case is not addressed.
So I created a patch and attached it to the bug JBAS-9203.
The way to get the LoginException thrown is easy:
sc.getData().get("org.jboss.security.exception");Hope this solution will help others as well.