2012-06-13 57 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