Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stack traces without line numbers

 
dave taubler
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am deploying a Web application (including EJBs, Servlets, JSPs, etc) on the Orion application server. Everything is packaged up into the standard JAR / WAR / EAR format, which Orion then unpacks. Works great, except when it comes to stack traces. Orion only has access to the binary code, not the source code, so its stack traces cannot report the line number on which an error occurs. Can anyone provide help (either Orion-specific help, or just the general concept of what I'd need to do) to tell Orion where to look for the source code? For development/testing, everything is all on one machine, which I assume would make this easy to do.

Thanks!
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34372
345
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave,
Why do you need the line numbers?

In any event, you don't need to point to the source code. Just set the compilation switch to compile with line numbers. I'm not familiar enough with Orion to be more specific.
 
krishnakumar ramamurthy
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not familiar with orion. But it does not need to be pointed to the source code for line numbers. The jvm when run interpreted will give the line numbers in the stack trace but when the piece of code is compiled the stack trace will not show line numbers. You can set the jvm to run in interpreted mode but that setting is jvm dependent.
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To clarify, it's the javac compiler that puts in the line numbers and name of the source file that eventually appear in stack traces. If you're using javac directly, you want to use the option "-g:{source,lines}" (this is the default). If you're using Ant, there are attributes on the <javac> task, you want to add these:
  • debug="on"
  • debuglevel="source,lines"

  • The other option with both is "vars" which includes variable names for interactive debuggers.

    I believe krishnakumar was alluding to the use of a native compilter (either gcj or a just-in-time compiler). I would hope that neither would strip such useful information, but it's possible. Regardless, if you don't compile to bytecode with that information, the second-level compiler cannot hope to have access to it. Thus, checking your compilation settings is the first step.

    Jeanne, it may be just me, but I'd like to nominate "Why do you need the line numbers?" as the Silliest Statement of the Year for 2005.
     
    dave taubler
    Ranch Hand
    Posts: 132
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Well, to be honest, I was getting pretty good at debugging with the line numbers, so technically I didn't need them. But they definitely make life easier!

    Thanks for the info. I think the reason I was thinking that I needed to point to the source code was because, IIRC, that's what is needed for stepping through code, e.g. with JSwat. Anyhow, the compiler switch worked, so thanks!
     
    Jeanne Boyarsky
    author & internet detective
    Marshal
    Posts: 34372
    345
    Eclipse IDE Java VI Editor
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by David Harkness:
    Jeanne, it may be just me, but I'd like to nominate "Why do you need the line numbers?" as the Silliest Statement of the Year for 2005.

    After rereading your post, I realize why you need the line numbers (ie - it's a test box.) For us, the server is only for post-development. Also, I use the approach of keeping methods really small. If a method is less than 10 lines, the line number isn't as useful. Where I'm coming from, the line numbers aren't as valuable. As a result, we don't include the line numbers in server stack traces. But thanks for the nomination I'm sure someone will say something sillier. The year's still young!
     
    David Harkness
    Ranch Hand
    Posts: 1646
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Jeanne Boyarsky:
    Also, I use the approach of keeping methods really small. If a method is less than 10 lines, the line number isn't as useful. Where I'm coming from, the line numbers aren't as valuable.
    Good point. Unfortunately, I'm not so lucky to only have to deal with my code but must debug methods several hundred lines long (seriously). I think some of the developers here believe there are awards for "longest method ever."
    But thanks for the nomination I'm sure someone will say something sillier. The year's still young!
    No doubt. Heck, it may be me!
    [ January 12, 2005: Message edited by: David Harkness ]
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic