如何在 ant build 创建的 jar 的错误堆栈跟踪中获取源行号? [英] How can I get the source line number in error stack trace of a jar created by ant build?

查看:22
本文介绍了如何在 ant build 创建的 jar 的错误堆栈跟踪中获取源行号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 ant 在 eclipse 中构建我的项目的 jar.我在 tomcat 上部署了那个 jar.但是每当我的代码(在 jar 内)中发生异常时,错误堆栈跟踪就会出现,但行号没有出现 - 而是说来源未知.

I am using ant to build a jar of my project in eclipse. I deploy that jar on tomcat. But whenever an exception happen in my code (which is inside jar), the error stack trace comes but the line number does not come -- instead it says unknown source.

如何获取错误堆栈跟踪中的行号?

How can I get the line numbers in error stack trace?

推荐答案

您需要使用调试信息编译 jar.具体来说,您需要找到编译您稍后 jar 的类的 javac 任务并添加一个 debug="on" 属性.示例:

You need to compile your jar with debug information. Specifically, you need to find the javac task that compiles the classes that you later jar and add a debug="on" attribute. Example:

<javac srcdir="${src}"
     destdir="${build}"
     classpath="xyz.jar"
     debug="on"
     source="1.4" />

可以在此处找到完整的详细信息.

Full details can be found here.

这篇关于如何在 ant build 创建的 jar 的错误堆栈跟踪中获取源行号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆