tags:

views:

3173

answers:

2

For some reason Eclipse doesn't remember source lookup path for some java projects, and every time during debugging (after redeploying) I need to press "Edit source lookup path" button and add current project to the list.

Does anyone know how to make it remember selected source location?

EDIT: It is a tomcat project, built with ant. Eclipse version is 3.2.2

.classpath looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="output" path="web/WEB-INF/classes"/>
    <classpathentry kind="lib" path="web/WEB-INF/lib/commons-collections-3.2.jar"/>
    ... bunch of libs here
</classpath>

UPDATE: I found required setting - it is under General Preferences -> Tomcat -> Source path.

+2  A: 

Try looking at the Run/Debug configuration for what you are executing, and check the source tab. You can add elements manually, but that is really not recommended.

The elements in the source tab are based on the classpath of the project containing the element that you run. In the case of running tomcat, the source path simply contains all the web projects that are associated with tomcat (and their dependencies).

Yoni
I looked in run/debug dialog and looks like my app (tomcat 6.x) is not even listed there. How do I edit list of projects that are associated with tomcat? Thanks.
serg
when you start tomcat you usually use some add/remove dialog (from the server view) to add projects to it, right?
Yoni
Also, it looks like your classpath is missing some entries. Are you perhaps starting tomcat with sysdeo instead of eclipse/wtp?
Yoni
build.xml copies generated WAR file into tomcat webapps folder. Usually all build setting are set via right click on build.xml -> run as -> ant build... but I don't see there where I can set source lookup path. Then I just start tomcat itself (through eclipse toolbar)
serg
Ok I found where source path lookup is set for tomcat (see update in the first post). Thank you for your help :)
serg
You are welcome :)From your description of the toolbar and the preferences it seems like you are using sysdeo, that's a shame. with Eclipse+wtp the whole deployment phase (build.xml, etc) is transparent.
Yoni
How to setup it the right way?
serg
I'd start with downloading the Eclipse EE distribution from the Eclipse website, it comes bundled with wtp already. You can also look at eclipse.org/webtools and google for various tutorials.
Yoni
A: 

Solution is:
Window / Preferences
Tomcat / Source Path

Click your project name. Don't forget to change it if you cahnge to another project!

Vilmos Kiss