users@glassfish.java.net

Re: Adding information for Transaction Rolled back.

From: sankara rao bhogi <Sankara.Rao_at_Sun.COM>
Date: Mon, 30 Jul 2007 11:11:25 +0530

Geoff,

Thanks for pointing this one. We will try to fix this for this release,
if not certainly for the next release.

regards
sankar

glassfish_at_javadesktop.org wrote:
> I have been fighting with saving some large object graphs. When there is an error in the object graphs sometimes the logging does not provide any useful information. I have changed all the logging levels in the logging part of the admin console, started the app server with --verbose, and in general tried everything I could do to get more information to help me debug the problem. I stepped through the code to figure out what the problem was and still could not find what was wrong with my objects and code.
>
> I did learn a lot in the process and so I checked out the glassfish source code, built glassfish, made some changes, built it again and solved my problem.
>
> I have the start of a suggestion for the J2EETransaction.commit() handling that might make debugging easier for people (I know it saved me. I instantly knew what the problem was after I implemented this fix).
>
> It goes something like this: If you have a large object graph you are saving you can get a stack trace that says Transaction Rolled back, but does not tell you what the error actually was. When I stepped through the code I found that in the synchronization loop (around line 420 of the J2EETransaction.java file) Exception is caught and nothing is done and RuntimeException is caught and setRollbackOnly() is called. Now this is all fine I'm sure for the handling of the transactions, but this is where the inner problem of my graph was buried and I was unable to get to it. Now if someone else knows a better way to get this error information that would be very valuable information, but what I did was change this code to:
>
>
> // call beforeCompletion
> for ( int i=0; i<syncs.size(); i++ ) {
> try {
> Synchronization sync = (Synchronization)syncs.elementAt(i);
> sync.beforeCompletion();
> } catch ( RuntimeException ex ) {
> System.out.println("\n\n\n\n\n\n\n\n\n\nRuntimeException during synchronization!\n\n\n\n\n\n\n\n");
> ex.printStackTrace();
> setRollbackOnly();
> } catch (Exception ex) {
> System.out.println("\n\n\n\n\n\n\n\n\n\nException during synchronization!\n\n\n\n\n\n\n\n");
> ex.printStackTrace();
> }
> }
>
> And by doing this I found the problem in my graph, easily fixed my code and away I went.
>
> This is not the solution I recommend exactly, but I do know that when my transaction rolls back I need this information. As I said I had set the logging level to fine, finer, finest everywhere I could find and never could get this info (I would probably even want this as INFO level logging).
>
> Maybe the stack trace isn't appropriate, but whatever the fix is -- I need it bad. For right now I will continue running on this branch I have built, but I would love to see something simple make it into b58 if at all possible.
>
> Thanks so much for your time and please let me know if I can be of any assistance.
>
> Thanks again,
> Geoff
> [Message sent by forum member 'gcruscoe' (gcruscoe)]
>
> http://forums.java.net/jive/thread.jspa?messageID=228681
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>