2012-06-13 51 views
1

我试图让我的登录表单与MySQL数据库,并不断收到以下错误:重度:jdbcrealm.invaliduserreason WEB9102:网页登录失败

[更新] - >我今天做了一些修改这是我现在得到的:

SEVERE: jdbcrealm.invaliduserreason 
WARNING: WEB9102: Web Login Failed: com.sun.enterprise.security.auth.login.common.LoginException: Login failed: Security Exception 
WARNING: WEB9102: Web Login Failed: com.sun.enterprise.security.auth.login.common.LoginException: Login failed: Security Exception 
WARNING: WEB9102: Web Login Failed: com.sun.enterprise.security.auth.login.common.LoginException: Login failed: Security Exception 

这就是我从堆栈跟踪得到的。我下面这个教程:http://blog.eisele.net/2011/01/jdbc-security-realm-and-form-based.html

这是在GlassFish-web.xml中我映射:

<security-role-mapping> 
    <role-name>user</role-name> 
    <group-name>user</group-name> 
    </security-role-mapping> 

这是我的web.xml:

<security-constraint> 
    <display-name>user</display-name> 
    <web-resource-collection> 
     <web-resource-name>Users Area</web-resource-name> 
     <description>Protected Users Area</description> 
     <url-pattern>/user/*</url-pattern> 
     <http-method>GET</http-method> 
     <http-method>PUT</http-method> 
     <http-method>HEAD</http-method> 
     <http-method>POST</http-method> 
     <http-method>OPTIONS</http-method> 
     <http-method>TRACE</http-method> 
     <http-method>DELETE</http-method> 
    </web-resource-collection> 
    <auth-constraint> 
     <description/> 
     <role-name>user</role-name> 
    </auth-constraint> 
</security-constraint> 
<login-config> 
    <auth-method>FORM</auth-method> 
    <realm-name>jdbcRealm</realm-name> 
    <form-login-config> 
     <form-login-page>/login.jsp</form-login-page> 
     <form-error-page>/login-error.jsp</form-error-page> 
    </form-login-config> 
</login-config> 
<security-role> 
    <description>user security role</description> 
    <role-name>user</role-name> 
</security-role> 

这是我的登录表单:

<form action="j_security_check" class="form" method="post"> 

      <p class="email"> 
        <input type="text" name="j_username" id="j_username"/> 
        <label for="j_username">E-mail/Username</label> 
      </p> 

      <p class="pwd"> 
        <input type="password" name="j_password" id="j_password" /> 
        <label for="j_password">Password</label> 
      </p> 

      <p class="submit"> 
        <input name="login" type="submit" value="Login" /> 
        <input name="reset_pwd" type="submit" value="Reset Password">                                
      </p> 

    </form> 

这是我在服务器中设置领域的屏幕截图。我目前没有使用加密来简化事情: Realm

由于我没有其他任何东西在堆栈中,但我上面发布。我真的不确定有什么问题。如果有人能朝正确的方向推动,我将不胜感激。

+0

你找到解决方案吗?我的问题和你几乎一样,但皮埃尔的回答对我来说并不合适。 –

+1

我做了皮埃尔C.在这篇文章的答案中提出的建议。此外,重复了这个教程两次,并在算法字段中使用'None',我能够弄明白。教程的链接是:[jdbc-security-realm-and-form-b​​ased](http:// blog .eisele.net/2011/01/jdbc-security-realm-and-form-b​​ased.html) – lv10

回答

3

在Glassfish中的jdbcRealm设置中,一定要在算法中写入“none”(而不是SHA-256或其他任何内容)。如果将该字段留空,则不起作用。

希望这会有所帮助...

+1

我必须将MD5放在“密码加密算法”和“摘要算法”中。 –

1

为我固定它的愚蠢和整洁的东西;领域是小写字母,特别是表和coloumn名称,他们在我的MySQL数据库中的大写字母。请记住在你的领域检查你的表格是否区分大小写。

+0

这只与MySQL相关,我相信,因为表名也是存储数据的文件名。这对于区分大小写的文件系统很重要。不确定这在Windows中也会出现问题。如果是这样,那么MySQL将以区分大小写的方式查找表文件。 –

1

如果您使用的是GlassFish 4,你需要完成的字段数据库用户和数据库密码,出现在设置 - >服务器配置 - >安全 - >国度 - >(jdbcRealm)

enter image description here