我正在尝试调试当我尝试登录到JAVA Web应用程序时遇到的错误。列似乎有些问题。这是堆栈跟踪:
anager] (http--127.0.0.1-8080-4) Login failure: javax.security.auth.login.LoginE
xception: PB00019: Processing Failed:Query failed
at org.jboss.security.auth.spi.DbUtil.getRoleSets(DbUtil.java:166) [pick
etbox-4.0.6.final.jar:4.0.6.final]
at org.jboss.security.auth.spi.Util.getRoleSets(Util.java:158) [picketbo
x-4.0.6.final.jar:4.0.6.final]
at org.jboss.security.auth.spi.DatabaseServerLoginModule.getRoleSets(Dat
abaseServerLoginModule.java:265) [picketbox-4.0.6.final.jar:4.0.6.final]
at org.jboss.security.auth.spi.AbstractServerLoginModule.commit(Abstract
ServerLoginModule.java:228) [picketbox-4.0.6.final.jar:4.0.6.final]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1
.7.0_51]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57) [rt.jar:1.7.0_51]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43) [rt.jar:1.7.0_51]
at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_51]
at javax.security.auth.login.LoginContext.invoke(LoginContext.java:762)
[rt.jar:1.7.0_51]
at javax.security.auth.login.LoginContext.access$000(LoginContext.java:2
03) [rt.jar:1.7.0_51]
at javax.security.auth.login.LoginContext$4.run(LoginContext.java:690) [
rt.jar:1.7.0_51]
at javax.security.auth.login.LoginContext$4.run(LoginContext.java:688) [
rt.jar:1.7.0_51]
at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.
7.0_51]
at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:6
87) [rt.jar:1.7.0_51]
at javax.security.auth.login.LoginContext.login(LoginContext.java:596) [
rt.jar:1.7.0_51]
at org.jboss.security.authentication.JBossCachedAuthenticationManager.de
faultLogin(JBossCachedAuthenticationManager.java:449) [picketbox-infinispan-4.0.
6.final.jar:4.0.6.final]
at org.jboss.security.authentication.JBossCachedAuthenticationManager.pr
oceedWithJaasLogin(JBossCachedAuthenticationManager.java:383) [picketbox-infinis
pan-4.0.6.final.jar:4.0.6.final]
at org.jboss.security.authentication.JBossCachedAuthenticationManager.au
thenticate(JBossCachedAuthenticationManager.java:371) [picketbox-infinispan-4.0.
6.final.jar:4.0.6.final]
at org.jboss.security.authentication.JBossCachedAuthenticationManager.is
Valid(JBossCachedAuthenticationManager.java:160) [picketbox-infinispan-4.0.6.fin
al.jar:4.0.6.final]
at org.jboss.as.web.security.JBossWebRealm.authenticate(JBossWebRealm.ja
va:215) [jboss-as-web-7.1.0.Final.jar:7.1.0.Final]
at org.apache.catalina.authenticator.FormAuthenticator.authenticate(Form
Authenticator.java:280) [jbossweb-7.0.10.Final.jar:]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
torBase.java:381) [jbossweb-7.0.10.Final.jar:]
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmC
loserValve.java:50) [jboss-as-jpa-7.1.0.Final.jar:7.1.0.Final]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(Secu
rityContextAssociationValve.java:154) [jboss-as-web-7.1.0.Final.jar:7.1.0.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:155) [jbossweb-7.0.10.Final.jar:]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:102) [jbossweb-7.0.10.Final.jar:]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:109) [jbossweb-7.0.10.Final.jar:]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:368) [jbossweb-7.0.10.Final.jar:]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:877) [jbossweb-7.0.10.Final.jar:]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ss(Http11Protocol.java:671) [jbossweb-7.0.10.Final.jar:]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:93
0) [jbossweb-7.0.10.Final.jar:]
at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]
Caused by: java.sql.SQLException: Column Index out of range, 2 > 1.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073) [mysql
-connector-java-5.1.30.jar:]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987) [mysql-
connector-java-5.1.30.jar:]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982) [mysql-
connector-java-5.1.30.jar:]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927) [mysql-
connector-java-5.1.30.jar:]
at com.mysql.jdbc.ResultSetImpl.checkColumnBounds(ResultSetImpl.java:818
) [mysql-connector-java-5.1.30.jar:]
at com.mysql.jdbc.ResultSetImpl.getStringInternal(ResultSetImpl.java:565
1) [mysql-connector-java-5.1.30.jar:]
at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5570) [mysq
l-connector-java-5.1.30.jar:]
at org.jboss.jca.adapters.jdbc.WrappedResultSet.getString(WrappedResultS
et.java:1338)
at org.jboss.security.auth.spi.DbUtil.getRoleSets(DbUtil.java:135) [pick
etbox-4.0.6.final.jar:4.0.6.final]
... 31 more
这是我的安全域名:
<security-domain name="product_app_realm">
<authentication>
<login-module code="Database" flag="required">
<module-option name="dsJndiName" value="java:/AuthorityDS"/>
<module-option name="principalsQuery" value="select password from product_database.users where username=?"/>
<module-option name="rolesQuery" value="select role from product_database.roles where username=?"/>
</login-module>
</authentication>
</security-domain>
知道问题是什么,我的安全域设置有问题吗?问题的根源似乎指出了我的列在用户或角色表中的问题。
答案 0 :(得分:2)
您需要从rolesQuery
返回两个值。
准备好的语句查询等效于:select Role,RoleGroup 来自角色,其中PrincipalID =?。如果没有指定,这是确切的 准备好的陈述将被使用。
尝试将您的查询更改为
select role, 'Roles' from product_database.roles where username=?
答案 1 :(得分:1)
rolesQuery
期望检索两列。 JBoss将仅使用第二列值为Roles
的记录。
使用它可以使用相同的表来存储其他“角色”以及用于JBoss的角色。很棘手,但这样的专栏清楚地显示在所有的例子中。
更多信息: http://docs.jboss.org/jbossas/getting_started/v2/startguide40/security.html