Results 1 to 6 of 6

Thread: ConcurrentModificationException HibernateTransactionManager.

  1. #1

    Default ConcurrentModificationException HibernateTransactionManager.

    I upgraded to Spring 1.2 Final and hibernate 3.0 and now all my saveOrUpdates throw a ConcurrentModificationException. I followed this post http://opensource.atlassian.com/proj...browse/SPR-907 and turned debugging off entirely, but it still occurs. Any idea as to why?

    Stack trace:

    java.util.ConcurrentModificationException
    at java.util.HashMap$HashIterator.nextEntry(HashMap.j ava:782)
    at java.util.HashMap$EntryIterator.next(HashMap.java: 824)
    at java.util.AbstractMap.toString(AbstractMap.java:58 6)
    at java.lang.String.valueOf(String.java:2131)
    at java.lang.StringBuffer.append(StringBuffer.java:37 0)
    at org.hibernate.engine.PersistenceContext.toString(P ersistenceContext.java:10

    at java.lang.String.valueOf(String.java:2131)
    at java.lang.StringBuffer.append(StringBuffer.java:37 0)
    at org.hibernate.impl.SessionImpl.toString(SessionImp l.java:1493)
    at java.lang.String.valueOf(String.java:2131)
    at java.lang.StringBuffer.append(StringBuffer.java:37 0)
    at org.springframework.orm.hibernate3.HibernateTransa ctionManager.doGetTransac
    ager.java:361)
    at org.springframework.transaction.support.AbstractPl atformTransactionManager.
    ormTransactionManager.java:199)
    at org.springframework.transaction.interceptor.Transa ctionAspectSupport.create
    actionAspectSupport.java:219)
    at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(T
    0)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(Reflec
    4)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopPr

    at $Proxy63.createOrSaveRecord(Unknown Source)
    at org.lds.ics.base.logic.AbstractBaseLogic.createOrS aveRecord(AbstractBaseLog

    at org.lds.ics.pfd.fmat.property.action.MobileUnitAct ion.save(MobileUnitAction

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:3

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImp

    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.apache.struts.actions.DispatchAction.dispatchM ethod(DispatchAction.java

    at org.apache.struts.actions.LookupDispatchAction.exe cute(LookupDispatchAction

  2. #2
    Join Date
    Sep 2004
    Location
    San Diego, CA
    Posts
    49

    Default

    I'm getting the exact same stack trace.

    If you look at HibernateTransactionManager line 361 you'll see that it really is a debug log message inside an isDebugEnabled() call. So your problem is still occurring because debug logging isn't turned off.

    What app server are you deployed in? I'm using JBoss and found it very difficult to turn off debug logging. My web app has its own log4j.xml and log4j jar file so I control the logging. However, no matter what settings I used, I found that DEBUG log messages were always being output to server.log.

    I ended up editing JBoss's log file at server/default/conf/log4j.xml and added a threshold="info" attribute to the log4j:configuration element. That seemed to turn off debug logging, and avoided this stack trace.

    Maybe try doing that to see if your problem goes away.


    Meanwhile now I have a web app with no debug log messages! Is there any way that HibernateTransactionManager could be modified to avoid calling Session.toString()?

    Alternatively, does anyone know of a modification I could make to my code to avoid this issue? is there a best practice of writing a toString() method for a hibernate persistent object that won't cause it to access the Session? I've simply been using Commonclipse to generate toString() methods.

    Tim

  3. #3
    Join Date
    Aug 2004
    Location
    Linz, Austria
    Posts
    391

    Default

    Quote Originally Posted by timmorrow
    Meanwhile now I have a web app with no debug log messages! Is there any way that HibernateTransactionManager could be modified to avoid calling Session.toString()?
    Well, you can always configure your logging to turn debug log off for the "org.springframework.orm.hibernate3.HibernateTrans actionManager" category. Every other category can still be at debug level. I know you're aware of this, just wanted to point it out in response to the above :-)

    Anyway, I'm about to have a detailed look at this. Seems that Hibernate won't change their Session.toString behavior. The Hibernate guys saying that Spring shouldn't call Session.toString() is about the silliest I've heard from them in a while, but hey, what can we do about it...

    Juergen

  4. #4
    Join Date
    Aug 2004
    Location
    Linz, Austria
    Posts
    391

    Default

    I've refined our HibernateTransactionManager for Hibernate3 to not call "Session.toString", which is broken in Hibernate3 (and won't be fixed). See the corresponding Hibernate issue, which has been prematurely closed by the Hibernate team.

    This workaround will be available in the next nightly snapshot and will be part of the upcoming 1.2.1 release (scheduled for this Friday).

    Juergen

  5. #5
    Join Date
    Sep 2004
    Location
    San Diego, CA
    Posts
    49

    Default

    Excellent, thanks.

    Of course, you're right about turning off debug for that category only. For JBoss it has to be done in both JBoss's log4j.xml and my own web app's log4j.xml. I'd gotten so frustrated trying to figure out JBoss's logging setup that I just turned debug of entirely!

    Cheers,

    Tim

  6. #6

    Default JBoss 3.2.7

    Quote Originally Posted by timmorrow
    What app server are you deployed in? I'm using JBoss and found it very difficult to turn off debug logging. My web app has its own log4j.xml and log4j jar file so I control the logging. However, no matter what settings I used, I found that DEBUG log messages were always being output to server.log.
    I am using JBoss 3.2.7 and tried the same thing. I finally got fed up with it and back reved our code until I could branch it and work on it by itself.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •