开发者

Can't find source for specific jar/class when debugging tomcat in eclipse

开发者 https://www.devze.com 2023-01-17 05:20 出处:网络
I\'m fairly new to java/eclipse development and I\'m having a bit of a problem debugging code from a specific jar in a web app that my company uses.

I'm fairly new to java/eclipse development and I'm having a bit of a problem debugging code from a specific jar in a web app that my company uses.

First off, I have Tomcat setup properly and can run the webapp successfully (other than the bug that I'm trying to find!). There are about two dozen jar files in the lib directory for the webapp, and when I've tried to debug files in other jars the debugger catches their breakpoints correctly and everything is happy. Breakpoints I set in code in the new jar are skipped, and when I catch a breakpoint further along the debug stack any attempt to click to the class I'm interested in results in "Source not found".

I click the "开发者_StackOverflow社区Edit Source Lookup Path..." button, click the project that contains the code, and it simply returns me to the "Source not found" error. I've tried setting up the lookup path both as a project as well as a File System Directory and a Workspace Project. Same result every time.

I'm a little fuzzy on how exactly the debugger ties a particular function call in the debug stack window to source code - is it simply based on the package and class name of the course file? If so, I can't see why it wouldn't be working.

Any ideas?


Make sure you are pointing at the right directory. If the class was com.foo.SomeClass then you need to set the src directory to the base directory such that Eclipse can find $basedir/com/foo/SomeClass.java. This isn't necessarily the root of the project, it might be $project/src, or even $project/src/main/java for Maven projects.


Turns out I was missing the fact that a project was renamed, moved to a different repo and had a nearly identical package name... operative word being "nearly". Thanks locka for the only response!

com.companyname.java.x.y.z.classname != com.companyname.java.y.z.classname


I hava a suggestion To resolve your problem in another way : if U want to debug something which donot inlude tomcat lib or other lib bind to Tomcat , like struts2 which need to process request and response .

please run program in main function even you use spring ;

public static void main(String[] args) { 

    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
                    "classpath*:/applicationContext.*.xml"); // check your applicationCntext formate , maybe applicationContext-*.xml ;

    context.afterPropertiesSet();
    find(context);
}
private static void find(ClassPathXmlApplicationContext context) {

    Map beans = getContext().getBeansOfType(SomeCLass.class);
 SomeCLass   bean=beans.values().iterator().next();
bean.callFunction();

} 
0

精彩评论

暂无评论...
验证码 换一张
取 消