This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 176246 - Debugger uses .jsp files from wrong project
Summary: Debugger uses .jsp files from wrong project
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Debugger (show other bugs)
Version: 6.x
Hardware: PC All
: P2 normal (vote)
Assignee: Martin Entlicher
URL:
Keywords: REGRESSION
Depends on:
Blocks:
 
Reported: 2009-11-09 08:03 UTC by Martin Schovanek
Modified: 2009-11-11 02:39 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Schovanek 2009-11-09 08:03:12 UTC
[#200911071423, GF v3 b71, jdk1.6, Mac OS X]

to reproduce:
-------------
1) create two web projects WebA and WebB
2) modify index.jsp files in both projects to be able to distinguish them
3) set BP at title tag at both index.jsp files
3) right click the WebA Project Node and choose Debug

ERROR: debugger stops at index.jsp from WebB project.
Comment 1 Martin Entlicher 2009-11-10 08:26:07 UTC
Reproduced.
Comment 2 Martin Entlicher 2009-11-10 08:52:26 UTC
It's caused by the insufficient sourcepath of the project.
Sourcepath is just ".../WebApplicationA/src/java" and that does not contain index.jsp file. Therefore that file is found through GlobalPathRegistry, which returns randomly index.jsp either from WebApplicationA or WebApplicationB.
That sourcepath is retrieved from classpath ".../WebApplicationA/build/web/WEB-INF/classes/".

We need to have ".../WebApplicationA/web" on the sourcepath.
Comment 3 Petr Jiricka 2009-11-10 09:04:22 UTC
Cc'ing David for his opinion. 
Is this a regression?
Comment 4 Martin Entlicher 2009-11-10 10:17:48 UTC
nbjpdaconnect task get sourcepath element, which is set to "${web.docbase.dir}"
According ANT verbose output  web.docbase.dir = web
I thought that this is not sufficient, that we need to have absolute path in the sourcepath. But apparently not, because this works fine when I replace JPDAStart.Sourcepath with Path. So this is a regression.
Comment 5 Martin Entlicher 2009-11-10 10:18:47 UTC
The regression is caused by the fix of issue #52920.
Comment 6 Martin Entlicher 2009-11-10 10:19:50 UTC
Why it does not create link? What about bug #52920?
Comment 7 Martin Entlicher 2009-11-10 10:20:42 UTC
Yes, of course. We no longer works with issues, but with bugs.
Comment 8 Martin Entlicher 2009-11-10 10:35:22 UTC
Well, this is not really true, this regression is caused by fix of bug 167941. We get correct Sourcepath object, but fail to extract the Path from it. This look like something that can not be correctly written. So it looks like we have to workaround just the refid case.
Comment 9 Martin Entlicher 2009-11-10 13:17:55 UTC
Fixed in changeset:   152863:e40ff48d304d
http://hg.netbeans.org/main/rev/e40ff48d304d
Comment 10 David Konecny 2009-11-10 14:18:16 UTC
Martin, couple of comments/questions:

* looking at http://hg.netbeans.org/main/rev/ea89e1fab816 (bug 52920) I wonder
if you tried to just reorder classpath instead of implementing "exclusive
attribute". I mean prior ea89e1fab816 code was "new ClassPath[] {cp, sp}" but
if that was changed to "new ClassPath[] {sp, cp}" that should give source path
preference over compilation path and should resolve original problem user was
complaining about, no?

* problem reported in bug 167941 ("org.apache.tools.ant.types.Path is not a
subclass of class org.netbeans.modules.debugger.jpda.ant.JPDAStart$Sourcepath")
makes sense to me but I cannot explain it in detail as I do not know enough on
how Ant decides when to instantiate org.apache.tools.ant.types.Path and when to
instantiate org.netbeans.modules.debugger.jpda.ant.JPDAStart$Sourcepath.
Perhaps JPDAStart.addSourcepath signature should accept Path instead of
JPDAStart$Sourcepath and the method should try to cast it to
JPDAStart$Sourcepath and if successful use isExclusive flag. Perhaps that would
resolve issue 167941 correctly.

* if isExclusive() is really needed then rather then introducing <sourcepath>
in NB which overlaps with Ant <sourcepath> I would use different tag name for
NB one, eg. <exclusivesourcepath> which would have exclusive always set to true
and JPDAStart would have addSourcepath and addExclusiveSourcepath method.
Again, just idea, I cannot guarantee it will work as it is about 8 years since
I last looked at Ant sources.
Comment 11 Martin Entlicher 2009-11-11 02:39:29 UTC
Thanks for comments David

* I did not want to reorder class-path as I was afraid of side-effects it can have, it can break other modules and someone might easily come with opposite demand. And it would not fulfill the request from bug 52920 "use these sources and ONLY these."

* I do not know the ANT in such detail as well. But what do you suggest does not work. ANT fails with "sourcepath doesn't support the "exclusive" attribute"

* This looks much more ugly to me and changing that now would be incompatible change. NB 6.7 uses exclusive attribute, if we delete it, we would break user's projects.

I know that what I do with Sourcepath and Path to fix bug 167941 is not nice at all, but I consider it to be a workaround for ANT limitation. And as far as workarounds in implementation are possible I prefer to have clean and compatible APIs.