有段時間我在本地主機(Windows 8.1)上開發了我的Wildfly 8.1 web應用程序,並且想要將我的Ubuntu服務器部署到Wildfly 8.2。Wildfly數據庫表單登錄模塊在生產中的失敗
本地表單登錄與ManagedBean一起使用,但在我的生產服務器上失敗。爲什麼?
- 數據庫連接工作。
因此,我暗示它與我在standalone.xml文件中配置的表單登錄有關。這顯然是非常類似於我的localhost standalone.xml文件。我檢查過,生產中的Wildfly 8.2是真正使用這個standalone.xml文件的!針對生產數據庫(與本地主機上的供應商和版本相同)執行主體查詢返回恰好爲1行。和我在本地開發環境中一樣。
但爲什麼principalsQuery
登錄模塊在生產中不起作用?任何人有任何線索?
<login-module code="Database" flag="required">
<module-option name="dsJndiName" value="java:jboss/datasources/CcmsDS"/>
<module-option name="principalsQuery" value="SELECT password FROM User WHERE username=?"/>
<module-option name="rolesQuery" value="SELECT role, 'Roles' FROM User JOIN User_Role ON User.id = User_Role.users_id JOIN role ON User_Role.roles_id = Role.id WHERE username=?"/>
</login-module>
我可以輸出確切的原因在我的prodcution服務器的日誌?
這裏是ManagedBean代碼:
try {
request.login(getUsername(), getPassword());
} catch (ServletException e) {
LOGGER.info("Failed to login with username " + username + " and password. " + e.getMessage() + ". ");
e.printStackTrace();
facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, "Login failed",
"Login failed when trying to authenticate with user " + getUsername() + "."));
// If this fails, return null.
return null;
}
...這裏從HttpServletRequestImpl錯誤消息:
2015-04-05 23:03:06,320 ERROR [stderr] (default task-12) L:71 javax.servlet.ServletException: UT010031: Login failed
2015-04-05 23:03:06,320 ERROR [stderr] (default task-12) L:71 at io.undertow.servlet.spec.HttpServletRequestImpl.login(HttpServletRequestImpl.java:440)
2015-04-05 23:03:06,321 ERROR [stderr] (default task-12) L:71 at com.johndoe.controller.security.LoginController.login(LoginController.java:239)
解決方案:rolesQuery不區分大小寫(Windows - > Ubuntu)。我糾正了它,並且prinicipals查詢工作。不知道他們爲什麼相互關聯。希望這可以幫助別人。 – feder 2015-04-05 21:41:24
我看不到你在哪裏陳述你使用的數據庫服務器,對於mysql來說,表名是區分大小寫的,因爲文件名在Linux上是區分大小寫的,但在Windows上不區分大小寫 – 2015-04-06 15:25:11