当我尝试重新启动服务器时,我遇到了以下异常。
2012-06-07 17:46:14,872 ERROR [http-0.0.0.0-8080-25]-[org.jboss.web.tomcat.security.JBossWebRealm] Error during authenticate
java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
at java.util.AbstractList$Itr.next(AbstractList.java:343)
at org.jboss.security.plugins.JBossAuthorizationManager.getRolesAsSet(JBossAuthorizationManager.java:317)
at org.jboss.security.plugins.JBossAuthorizationManager.getUserRoles(JBossAuthorizationManager.java:233)
at org.jboss.security.plugins.auth.JaasSecurityManagerBase.getUserRoles(JaasSecurityManagerBase.java:457)
at org.jboss.security.plugins.JaasSecurityManager.getUserRoles(JaasSecurityManager.java:208)
at org.jboss.web.tomcat.security.JBossWebRealm.getCachingPrincipal(JBossWebRealm.java:669)
at org.jboss.web.tomcat.security.JBossWebRealm.authenticate(JBossWebRealm.java:409)
at org.apache.catalina.authenticator.BasicAuthenticator.authenticate(BasicAuthenticator.java:181)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:491)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:662)
JBOSS的JBossAuthorizationManager中的getRolesAsSet方法代码如下: //私人方法
private HashSet<Principal> getRolesAsSet(RoleGroup roles)
{
HashSet<Principal> userRoles = null;
if( roles != null )
{
userRoles = new HashSet<Principal>();
List<Role> rolesList = roles.getRoles();
for(Role r: rolesList)
{
userRoles.add(new SimplePrincipal(r.getRoleName()));
}
}
return userRoles;
}
正如我所知(并且已经对该方法做了一些简单的测试),如果有一些线程在调用roleList上的迭代器的同时添加或删除RoleGroup“roles”的角色,我们将得到如上所述的ConcurrentModificationException 。
我认为这是JBOSS的一个错误。不确定我们是否可以在JBOSS中进行一些配置以避免这种情况。 我的JBOSS服务器版本是“jboss-5.1.0.GA”
请给我一些建议。感谢。