-->
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.  [ 4 posts ] 
Author Message
 Post subject: Exception logging.
PostPosted: Sat Sep 09, 2006 9:24 am 
Newbie

Joined: Sat Sep 09, 2006 9:07 am
Posts: 2
At some point in my code hibernate sometimes throws an LazyInitializationException. This is perfectly reasonable because the session is not always available. Because this is not really a problem I catch the exception and log a simple warning in my logfile or just ignore the case and continue.

Something like this:
Code:
try {
  List<User> user = group.getUsers();
} catch (LazyInitializationException e) {
  // ignore
}


Because I catch this exception and consider it to be harmless (within my code) I don't want my logfiles spoiled with useless stacktraces. Although I catch it and ignore it, Hibernate still logs the stacktraces which is really annoyng:

Code:
...
INFO: building session factory
Sep 9, 2006 3:19:34 PM org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
Sep 9, 2006 3:19:34 PM org.hibernate.LazyInitializationException <init>
SEVERE: illegal access to loading collection
org.hibernate.LazyInitializationException: illegal access to loading collection
   at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:341)
   at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
   at org.hibernate.collection.AbstractPersistentCollection.readElementExistence(AbstractPersistentCollection.java:142)
...


Does anyone know why hibernate dumps stacktraces of exceptions that could possibly be catched later?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 09, 2006 10:22 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
LIE is definitly not something to ignore...and that is also a reason to why we log it to be able to always see it even with users try/catch/ignore constructs.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 09, 2006 6:13 pm 
Senior
Senior

Joined: Sun Jun 04, 2006 1:58 am
Posts: 136
turn off logging for that particular calss in hibernate

like

level.org.hibernate.... = off

but as said above LIE is one of the most important exceptions that hibernate throws ..not to be ignored

_________________
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 10, 2006 7:23 am 
Newbie

Joined: Sat Sep 09, 2006 9:07 am
Posts: 2
Ignoring or not ignoring exceptions has nothing todo with the type of exception. It depends primarilly on the logic of the context in which it is thrown/caught.

Thaks for the replies anyway.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.