aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Stack traces without line numbers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Stack traces without line numbers" Watch "Stack traces without line numbers" New topic
Author

Stack traces without line numbers

dave taubler
Ranch Hand

Joined: May 15, 2001
Posts: 132
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!


Dave Taubler<br />Specializing in <a href="http://taubler.com/articles/" target="_blank" rel="nofollow">Java and Web Development</a>
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31074
    
232

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
krishnakumar ramamurthy
Greenhorn

Joined: Jan 10, 2005
Posts: 7
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

Joined: Aug 07, 2003
Posts: 1646
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

    Joined: May 15, 2001
    Posts: 132
    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

    Joined: May 26, 2003
    Posts: 31074
        
    232

    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

    Joined: Aug 07, 2003
    Posts: 1646
    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 ]
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Stack traces without line numbers