These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Random LazyInitializationException in Swing App
PostPosted: Wed Dec 03, 2008 8:27 pm 
Newbie

Joined: Wed Dec 03, 2008 7:13 pm
Posts: 2
Location: Davenport, Iowa
Hibernate version: 3.3.1
Java version: jre 1.6_0_11
Database: PostgreSQL 8.1

I have a production Swing app with 20 users. I use a "main" session that remains open for the life of the app. I manage the session by clearing it at the appropriate times. Intermittently, a "LazyInitializationException - cannot initialize proxy - No session" will be thrown when hibernate attempts to initialize a proxy. However, the session is open and the entity was never removed. By going to another view and returning ( which effectively clears the session and reloads the entity without closing the app ), I can accomplish the same task that caused the exception. Frustratingly, the exception is apparently random, fairly frequent, and cannot be reproduced at will. An example stack trace:

org.hibernate.LazyInitializationException: could not initialize proxy - no Session:
org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:86)
org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:140)
org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190)
com.moms.models.HypersensitivityType_$$_javassist_20.toString(HypersensitivityType_$$_javassist_20.java)
javax.swing.table.DefaultTableCellRenderer.setValue(Unknown Source)
javax.swing.table.DefaultTableCellRenderer.getTableCellRendererComponent(Unknown Source)
javax.swing.JTable.prepareRenderer(Unknown Source)
javax.swing.plaf.basic.BasicTableUI.paintCell(Unknown Source)
javax.swing.plaf.basic.BasicTableUI.paintCells(Unknown Source)
javax.swing.plaf.basic.BasicTableUI.paint(Unknown Source)
javax.swing.plaf.ComponentUI.update(Unknown Source)
javax.swing.JComponent.paintComponent(Unknown Source)
javax.swing.JComponent.paint(Unknown Source)
javax.swing.JComponent.paintChildren(Unknown Source)
javax.swing.JComponent.paint(Unknown Source)
javax.swing.JViewport.paint(Unknown Source)
javax.swing.JComponent.paintChildren(Unknown Source)
javax.swing.JComponent.paint(Unknown Source)
javax.swing.JComponent.paintChildren(Unknown Source)
javax.swing.JComponent.paint(Unknown Source)
javax.swing.JComponent.paintChildren(Unknown Source)
javax.swing.JComponent.paint(Unknown Source)
javax.swing.JComponent.paintChildren(Unknown Source)
javax.swing.JComponent.paint(Unknown Source)
javax.swing.JComponent.paintChildren(Unknown Source)
javax.swing.JComponent.paint(Unknown Source)
javax.swing.JComponent.paintChildren(Unknown Source)
javax.swing.JComponent.paint(Unknown Source)
javax.swing.JComponent.paintChildren(Unknown Source)
javax.swing.JComponent.paint(Unknown Source)
javax.swing.JLayeredPane.paint(Unknown Source)
javax.swing.JComponent.paintChildren(Unknown Source)
javax.swing.JComponent.paint(Unknown Source)
javax.swing.JComponent.paintToOffscreen(Unknown Source)
javax.swing.BufferStrategyPaintManager.paint(Unknown Source)
javax.swing.RepaintManager.paint(Unknown Source)
javax.swing.JComponent._paintImmediately(Unknown Source)
javax.swing.JComponent.paintImmediately(Unknown Source)
javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source)
javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
java.awt.event.InvocationEvent.dispatch(Unknown Source)
java.awt.EventQueue.dispatchEvent(Unknown Source)
java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)


This issue was also present with Hibernate 3.2. Any help would be appreciated.

_________________
David J Rericha


Top
 Profile  
 
 Post subject: Clarification
PostPosted: Mon Dec 08, 2008 6:57 pm 
Newbie

Joined: Wed Dec 03, 2008 7:13 pm
Posts: 2
Location: Davenport, Iowa
To clarify my original post, the lazy-loading is occurring within a "long" transaction. When a session is opened, a transaction is begun. When the user performs a save or delete, the transaction is committed ( the session is configured to flush only on commit ) and a new transaction is immediately opened. From my research this "session-per-window/transaction-per-commit" seems to be the only workable pattern for transaction-demarcation in 2-tier GUI apps. Any comments pro or con would be welcomed.

_________________
David J Rericha


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.