是你的事务处理的有问题!修改你的事务处理!public UserInfo authenticate() throws Exception {
Transaction t = null;
try {
Session session = HibernateUtil.currentSession();
t = session.beginTransaction();
Query q = session.createQuery("select u from u in class UserInfo where u.email=:email and u.password=:password");
q.setParameter("email", getEmail());
q.setParameter("password", getPassword());
List result = q.list();
if (!result.isEmpty()) {
return (UserInfo)result.iterator().next();
}
else {
ValidationDelegate delegate = (ValidationDelegate) getBeans().getBean("delegate");
delegate.setFormComponent(null);
delegate.record("Login failed, wrong username or password", null);

}
t.commit();
} catch (HibernateException e) {
t.rollback();
e.printStackTrace();
} finally {
if (HibernateUtil.currentSession() != null)
try {
HibernateUtil.currentSession().flush();
HibernateUtil.closeSession();
} catch (Exception e) {
e.printStackTrace();
}
} return null;
}

解决方案 »

  1.   

    楼上的那位说的有一定根据的,分析日志的时候我也发现有roll back失败的问题。楼主用什么数据库?
      

  2.   

    数据库是mysql吧???这个是mysql的8小时问题,
    超过8小时没任何操作的连接被服务器端强制断开连接,
    而此时连接池中认为该连接还是有效的。解决办法参考下面这篇blog:http://bjzhanghao.cnblogs.com/archive/2004/12/10/75145.html
      

  3.   

    谢谢楼上各位兄弟支持,小弟用的正是Mysql数据库,正在揣摩中……
      

  4.   

    pigo(p) ( ) 信誉:130 说的很有道理,以前记得在哪里也曾见过的。另外,如果使用c3p0的话,也要注意连接池的配置,不正确的配置仍然会让你系统变的很慢,甚至web容器没有响应。这些我都领教过的。
      

  5.   

    是的,这是连接池的问题,换成容器自己的连接池会好的,这是因为mysql在连接timeout的时候会断开,而连接池自身如果不能自动判断和重新连接就会出问题的。