You might be setting it to late when you set it in your test code. The server is already started at that point.
Try setting it as a system property in Surefire if you use Maven. Then that property should be set when the container starts up.
Yeah that's right Aslak, I was setting the property lately and actually it was never taken into account , that's why even if I had a JDBCRealm in my login.conf, I was always getting an exception about fileRealm.
Actually, the problem was that in my domain.xml I defined several <auth-realm> fileRealm, JDBCRealm ... and it seems that it took the first realm that was defined (fileRealm).
Removing the setting up of the property and all realm in my domain except the JDBCRealm resolved my pbroblem.