I tried this tutorial http://java.dzone.com/articles/jdbc-realm-and-form-based with GlassFish 4 and getting the error:
SEVERE: jdbcrealm.invaliduserreason WARNING: WEB9102: Web Login Failed: com.sun.enterprise.security.auth.login.common.LoginException: Login failed: Security Exception
I tried many diffrent things such as setting the log level to Finest,took the case sensitivity on table/columnnames into consideration, added "none" in the Algorithm statment ( SEVERE: jdbcrealm.invaliduserreason WEB9102: Web Login Failed ), tried diffrent password hashes ( LoginException: Login failed: Security Exception), setSHA-256 in Password Encryption Algorithm and in Digest Alogirthm but none of suggested solutions worked for me.
I think the problem is connected to the "Password Encryption Algorithm:" statement, because this "Password Encryption Algorithm:" doesn't exist in the tutorial (he is using Glassfish 3.x)
This is my current Glassfish configuration.

Has someone an idea what I can try else?