From: William R. L. <wr...@ex...> - 2003-09-27 04:12:06
|
Fellow Hibernaters, I'm receiving an Exception in a Hibernate application I've built, and I'm a bit confused as to why this might be happening. The code at where the Exception is thrown is quite simple, and I think this might be a bug in Hibernate itself. I've searched Google for this to no avail, and I'm using the latest recommended Hibernate release as available on the site. The exception I receive has a stacktrace as follows: java.util.ConcurrentModificationException at java.util.AbstractList$Itr.checkForComodification(Unknown Source) at java.util.AbstractList$Itr.remove(Unknown Source) at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2101) at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2061) at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2005) at net.sf.hibernate.transaction.JDBCTransaction.commit( JDBCTransaction.java:57 ) at org.express.ftpsrv.ConnectionHandler.<init>(ConnectionHandler.java:72) at org.express.ftpsrv.ConnectionListener.accept(ConnectionListener.java:56) at org.express.ftpsrv.ConnectionListener.main(ConnectionListener.java:19) And the code at ConnectionHandler.java:72 that causes this looks like: 52:this.ftpSession = new FtpSession(); 53: 54:/* ftpSession.setSessionId() does not operate on the unique 55: * 'id' field that is also part of the ftpSession object. 56: */ 57:ftpSession.setSessionId(UniqueGenerator.makeUniqueNumber()); 58: 59:Date currentDate = new Date(); 60:currentDate.setTime(System.currentTimeMillis()); 61:this.ftpSession.setBegTime(currentDate); 62: 63:net.sf.hibernate.Session hSession = null; 64:Transaction transaction = null; 65: 66:try 67:{ 68: hSession = SessionHolder.getSession(); 69: 70: transaction = hSession.beginTransaction(); 71: hSession.save(this.session); 72: transaction.commit(); 73:} catch (HibernateException e) 74:{ 75: transaction.rollback(); 76:} I'd like to point out that this seems to be an intermittent thing, occurring more often when I instantiate many objects quickly (the quoted lines 52-72, above, are within a cronstructor in the Object). Does anyone have any ideas as to what might be happening or where I might look for additional information in order to track down this bug? Thanks, in advance, for any response on this. -- _ __ __ ___ _| | William R. Lorenz <wr...@ex...> \ V V / '_| | http://www.clevelandlug.net/ ; "Every revolution was \./\./|_| |_| first a thought in one man's mind." - Ralph Waldo Emerson |
From: Gavin K. <ga...@hi...> - 2003-09-27 10:49:45
|
We seem to be having some problems like this in more than one section of code. I really don't understand it at all; we suspect some kind of JVM bug. Unfortunately, no-one has been able to deliver a testcase that will help me reproduce this on my machine. I can't really do much, until I can reproduce it. P.S. You might also get this if you share a session between two threads - but at least some occurrences of this problem do not seem to be caused by this.... William R. Lorenz wrote: >Fellow Hibernaters, > >I'm receiving an Exception in a Hibernate application I've built, and I'm >a bit confused as to why this might be happening. The code at where the >Exception is thrown is quite simple, and I think this might be a bug in >Hibernate itself. I've searched Google for this to no avail, and I'm >using the latest recommended Hibernate release as available on the site. > >The exception I receive has a stacktrace as follows: > > java.util.ConcurrentModificationException > at java.util.AbstractList$Itr.checkForComodification(Unknown Source) > at java.util.AbstractList$Itr.remove(Unknown Source) > at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2101) > at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2061) > at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2005) > at net.sf.hibernate.transaction.JDBCTransaction.commit( > JDBCTransaction.java:57 > ) > at org.express.ftpsrv.ConnectionHandler.<init>(ConnectionHandler.java:72) > at org.express.ftpsrv.ConnectionListener.accept(ConnectionListener.java:56) > at org.express.ftpsrv.ConnectionListener.main(ConnectionListener.java:19) > >And the code at ConnectionHandler.java:72 that causes this looks like: > > 52:this.ftpSession = new FtpSession(); > 53: > 54:/* ftpSession.setSessionId() does not operate on the unique > 55: * 'id' field that is also part of the ftpSession object. > 56: */ > 57:ftpSession.setSessionId(UniqueGenerator.makeUniqueNumber()); > 58: > 59:Date currentDate = new Date(); > 60:currentDate.setTime(System.currentTimeMillis()); > 61:this.ftpSession.setBegTime(currentDate); > 62: > 63:net.sf.hibernate.Session hSession = null; > 64:Transaction transaction = null; > 65: > 66:try > 67:{ > 68: hSession = SessionHolder.getSession(); > 69: > 70: transaction = hSession.beginTransaction(); > 71: hSession.save(this.session); > 72: transaction.commit(); > 73:} catch (HibernateException e) > 74:{ > 75: transaction.rollback(); > 76:} > >I'd like to point out that this seems to be an intermittent thing, >occurring more often when I instantiate many objects quickly (the quoted >lines 52-72, above, are within a cronstructor in the Object). > >Does anyone have any ideas as to what might be happening or where I might >look for additional information in order to track down this bug? > >Thanks, in advance, for any response on this. > >-- _ >__ __ ___ _| | William R. Lorenz <wr...@ex...> >\ V V / '_| | http://www.clevelandlug.net/ ; "Every revolution was > \./\./|_| |_| first a thought in one man's mind." - Ralph Waldo Emerson > > > >------------------------------------------------------- >This sf.net email is sponsored by:ThinkGeek >Welcome to geek heaven. >http://thinkgeek.com/sf >_______________________________________________ >hibernate-devel mailing list >hib...@li... >https://lists.sourceforge.net/lists/listinfo/hibernate-devel > > |
From: Juozas B. <ba...@ce...> - 2003-09-28 12:30:16
|
It must be bug in "SessionHolder". ----- Original Message ----- From: "Gavin King" <ga...@hi...> To: "William R. Lorenz" <wr...@ex...> Cc: <hib...@li...>; <hib...@li...> Sent: Saturday, September 27, 2003 1:48 PM Subject: Re: [Hibernate] Hibernate Bug? [ConcurrentModificationException] > We seem to be having some problems like this in more than one section > of code. I really don't understand it at all; we suspect some kind of > JVM bug. Unfortunately, no-one has been able to deliver a testcase > that will help me reproduce this on my machine. > > I can't really do much, until I can reproduce it. > > P.S. You might also get this if you share a session between two > threads - but at least some occurrences of this problem do not seem > to be caused by this.... > > William R. Lorenz wrote: > > >Fellow Hibernaters, > > > >I'm receiving an Exception in a Hibernate application I've built, and I'm > >a bit confused as to why this might be happening. The code at where the > >Exception is thrown is quite simple, and I think this might be a bug in > >Hibernate itself. I've searched Google for this to no avail, and I'm > >using the latest recommended Hibernate release as available on the site. > > > >The exception I receive has a stacktrace as follows: > > > > java.util.ConcurrentModificationException > > at java.util.AbstractList$Itr.checkForComodification(Unknown Source) > > at java.util.AbstractList$Itr.remove(Unknown Source) > > at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2101) > > at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2061) > > at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2005) > > at net.sf.hibernate.transaction.JDBCTransaction.commit( > > JDBCTransaction.java:57 > > ) > > at org.express.ftpsrv.ConnectionHandler.<init>(ConnectionHandler.java:72) > > at org.express.ftpsrv.ConnectionListener.accept(ConnectionListener.java:56) > > at org.express.ftpsrv.ConnectionListener.main(ConnectionListener.java:19) > > > >And the code at ConnectionHandler.java:72 that causes this looks like: > > > > 52:this.ftpSession = new FtpSession(); > > 53: > > 54:/* ftpSession.setSessionId() does not operate on the unique > > 55: * 'id' field that is also part of the ftpSession object. > > 56: */ > > 57:ftpSession.setSessionId(UniqueGenerator.makeUniqueNumber()); > > 58: > > 59:Date currentDate = new Date(); > > 60:currentDate.setTime(System.currentTimeMillis()); > > 61:this.ftpSession.setBegTime(currentDate); > > 62: > > 63:net.sf.hibernate.Session hSession = null; > > 64:Transaction transaction = null; > > 65: > > 66:try > > 67:{ > > 68: hSession = SessionHolder.getSession(); > > 69: > > 70: transaction = hSession.beginTransaction(); > > 71: hSession.save(this.session); > > 72: transaction.commit(); > > 73:} catch (HibernateException e) > > 74:{ > > 75: transaction.rollback(); > > 76:} > > > >I'd like to point out that this seems to be an intermittent thing, > >occurring more often when I instantiate many objects quickly (the quoted > >lines 52-72, above, are within a cronstructor in the Object). > > > >Does anyone have any ideas as to what might be happening or where I might > >look for additional information in order to track down this bug? > > > >Thanks, in advance, for any response on this. > > > >-- _ > >__ __ ___ _| | William R. Lorenz <wr...@ex...> > >\ V V / '_| | http://www.clevelandlug.net/ ; "Every revolution was > > \./\./|_| |_| first a thought in one man's mind." - Ralph Waldo Emerson > > > > > > > >------------------------------------------------------- > >This sf.net email is sponsored by:ThinkGeek > >Welcome to geek heaven. > >http://thinkgeek.com/sf > >_______________________________________________ > >hibernate-devel mailing list > >hib...@li... > >https://lists.sourceforge.net/lists/listinfo/hibernate-devel > > > > > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > hibernate-devel mailing list > hib...@li... > https://lists.sourceforge.net/lists/listinfo/hibernate-devel |
From: William R. L. <wr...@ex...> - 2003-09-27 18:29:21
|
On Sat, 27 Sep 2003, Juozas Baliuka wrote: > It must be bug in "SessionHolder". Hi, Juozas. That code below was actuallly incorrect in my last email, and I have corrected it in-line below: I am actually storing this.ftpSession instead of this.session (line 71 in the original quoted code below). As for the SessionHolder object, I'm using that so that I don't have hundreds of connections to the back-end PostgreSQL database. I've include the code beow -- it should connect to the database if needed and just return a connected net.sf.hibernate.Session object from its method. 01:public class SessionHolder 02:{ 03: private static final boolean DEBUG = true; 04: private static Session session; 05: 06: public static Session getSession() 07: { 08: SessionHolder.connect(); 09: 10: return(SessionHolder.session); 11: } 12: 13: public static void connect() 14: { 15: if (SessionHolder.session == null) 16: { 17: try 18: { 19: SessionFactory sessionFactory = new Configuration() 20: .configure().buildSessionFactory(); 21: SessionHolder.session = sessionFactory.openSession(); 22: } catch (HibernateException e) 23: { 24: if (SessionHolder.DEBUG) e.printStackTrace(); 25: } 26: } else 27: { 28: try 29: { 30: SessionHolder.session.reconnect(); 31: } catch (Exception e) {} 32: } 33: } 34: 35: public static void disconnect() 36: { 37: if (SessionHolder.session != null) 38: { 39: try 40: { 41: SessionHolder.session.close(); 42: SessionHolder.session.disconnect(); 43: } catch (HibernateException e) {} 44: } 45: } 46:} QHat do you think? Is there a better way that I should be doing this without rewriting a heck of a lot of code? I like the idea of having the session establishment self-contained within the SessionHolder object? Does this SessionHolder seem to be the culprit behind the ConcurrentModificationException issues? > > We seem to be having some problems like this in more than one section > > of code. I really don't understand it at all; we suspect some kind of > > JVM bug. Unfortunately, no-one has been able to deliver a testcase > > that will help me reproduce this on my machine. > > I can't really do much, until I can reproduce it. > > P.S. You might also get this if you share a session between two > > threads - but at least some occurrences of this problem do not seem to > > be caused by this.... > > >I'm receiving an Exception in a Hibernate application I've built, and > > >I'm a bit confused as to why this might be happening. The code at > > >where the Exception is thrown is quite simple, and I think this might > > >be a bug in Hibernate itself. I've searched Google for this to no > > >avail, and I'm using the latest recommended Hibernate release as > > >available on the site. > > >The exception I receive has a stacktrace as follows: > > > java.util.ConcurrentModificationException > > > at java.util.AbstractList$Itr.checkForComodification(Unknown Source) > > > at java.util.AbstractList$Itr.remove(Unknown Source) > > > at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2101) > > > at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2061) > > > at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2005) > > > at net.sf.hibernate.transaction.JDBCTransaction.commit( > > > JDBCTransaction.java:57 > > > ) > > > at > org.express.ftpsrv.ConnectionHandler.<init>(ConnectionHandler.java:72) > > > at > org.express.ftpsrv.ConnectionListener.accept(ConnectionListener.java:56) > > > at > org.express.ftpsrv.ConnectionListener.main(ConnectionListener.java:19) > > > > > >And the code at ConnectionHandler.java:72 that causes this looks like: > > > > > > 52:this.ftpSession = new FtpSession(); > > > 53: > > > 54:/* ftpSession.setSessionId() does not operate on the unique > > > 55: * 'id' field that is also part of the ftpSession object. > > > 56: */ > > > 57:ftpSession.setSessionId(UniqueGenerator.makeUniqueNumber()); > > > 58: > > > 59:Date currentDate = new Date(); > > > 60:currentDate.setTime(System.currentTimeMillis()); > > > 61:this.ftpSession.setBegTime(currentDate); > > > 62: > > > 63:net.sf.hibernate.Session hSession = null; > > > 64:Transaction transaction = null; > > > 65: > > > 66:try > > > 67:{ > > > 68: hSession = SessionHolder.getSession(); > > > 69: > > > 70: transaction = hSession.beginTransaction(); > > > 71: hSession.save(this.ftpSession); > > > 72: transaction.commit(); > > > 73:} catch (HibernateException e) > > > 74:{ > > > 75: transaction.rollback(); > > > 76:} > > >I'd like to point out that this seems to be an intermittent thing, > > >occurring more often when I instantiate many objects quickly (the > > >quoted lines 52-72, above, are within a cronstructor in the Object). > > >Does anyone have any ideas as to what might be happening or where I > > >might look for additional information in order to track down this > > >bug? Thanks, in advance, for any response on this. -- _ __ __ ___ _| | William R. Lorenz <wr...@ex...> \ V V / '_| | http://www.clevelandlug.net/ ; "Every revolution was \./\./|_| |_| first a thought in one man's mind." - Ralph Waldo Emerson |
From: Juozas B. <ba...@ce...> - 2003-09-27 18:46:21
|
Yes, it is problem in SessionHolder implementation, but it is trivial to fix: > > 01:public class SessionHolder > 02:{ > 03: private static final boolean DEBUG = true; > 04: private static ThreadLocal session; > 05: > 06: public static Session getSession() > 07: { > 08: SessionHolder.connect(); > 09: > 10: return((Session )SessionHolder.session.get()); > 11: } > 12: > 13: public static void connect() > 14: { > 15: if (SessionHolder.session.get() == null) > 16: { > 17: try > 18: { > 19: SessionFactory sessionFactory = new Configuration() > 20: .configure().buildSessionFactory(); > 21: SessionHolder.session.set( sessionFactory.openSession() ); > 22: } catch (HibernateException e) > 23: { > 24: throw new RuntimeException(e); } > 26: } } > 34: > 35: public static void disconnect() > 36: { > 37: if (SessionHolder.session.get() != null) > 38: { > 39: try > 40: { > 41: SessionHolder.session.close(); > 42: } catch (HibernateException e) { throw new RuntimeException(e); } > 44: } > 45: } > 46:} > > QHat do you think? Is there a better way that I should be doing this > without rewriting a heck of a lot of code? I like the idea of having the > session establishment self-contained within the SessionHolder object? > > Does this SessionHolder seem to be the culprit behind the > ConcurrentModificationException issues? > > > > We seem to be having some problems like this in more than one section > > > of code. I really don't understand it at all; we suspect some kind of > > > JVM bug. Unfortunately, no-one has been able to deliver a testcase > > > that will help me reproduce this on my machine. > > > > I can't really do much, until I can reproduce it. > > > > P.S. You might also get this if you share a session between two > > > threads - but at least some occurrences of this problem do not seem to > > > be caused by this.... > > > > >I'm receiving an Exception in a Hibernate application I've built, and > > > >I'm a bit confused as to why this might be happening. The code at > > > >where the Exception is thrown is quite simple, and I think this might > > > >be a bug in Hibernate itself. I've searched Google for this to no > > > >avail, and I'm using the latest recommended Hibernate release as > > > >available on the site. > > > > >The exception I receive has a stacktrace as follows: > > > > > java.util.ConcurrentModificationException > > > > at java.util.AbstractList$Itr.checkForComodification(Unknown Source) > > > > at java.util.AbstractList$Itr.remove(Unknown Source) > > > > at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2101) > > > > at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2061) > > > > at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2005) > > > > at net.sf.hibernate.transaction.JDBCTransaction.commit( > > > > JDBCTransaction.java:57 > > > > ) > > > > at > > org.express.ftpsrv.ConnectionHandler.<init>(ConnectionHandler.java:72) > > > > at > > org.express.ftpsrv.ConnectionListener.accept(ConnectionListener.java:56) > > > > at > > org.express.ftpsrv.ConnectionListener.main(ConnectionListener.java:19) > > > > > > > >And the code at ConnectionHandler.java:72 that causes this looks like: > > > > > > > > 52:this.ftpSession = new FtpSession(); > > > > 53: > > > > 54:/* ftpSession.setSessionId() does not operate on the unique > > > > 55: * 'id' field that is also part of the ftpSession object. > > > > 56: */ > > > > 57:ftpSession.setSessionId(UniqueGenerator.makeUniqueNumber()); > > > > 58: > > > > 59:Date currentDate = new Date(); > > > > 60:currentDate.setTime(System.currentTimeMillis()); > > > > 61:this.ftpSession.setBegTime(currentDate); > > > > 62: > > > > 63:net.sf.hibernate.Session hSession = null; > > > > 64:Transaction transaction = null; > > > > 65: > > > > 66:try > > > > 67:{ > > > > 68: hSession = SessionHolder.getSession(); > > > > 69: > > > > 70: transaction = hSession.beginTransaction(); > > > > 71: hSession.save(this.ftpSession); > > > > 72: transaction.commit(); > > > > 73:} catch (HibernateException e) > > > > 74:{ > > > > 75: transaction.rollback(); > > > > 76:} > > > > >I'd like to point out that this seems to be an intermittent thing, > > > >occurring more often when I instantiate many objects quickly (the > > > >quoted lines 52-72, above, are within a cronstructor in the Object). > > > > >Does anyone have any ideas as to what might be happening or where I > > > >might look for additional information in order to track down this > > > >bug? Thanks, in advance, for any response on this. > > -- _ > __ __ ___ _| | William R. Lorenz <wr...@ex...> > \ V V / '_| | http://www.clevelandlug.net/ ; "Every revolution was > \./\./|_| |_| first a thought in one man's mind." - Ralph Waldo Emerson > > |