Define which library's source / version is used in debugging

Hi, I am using Idea 11. I habe a project with multiple modules, and some of them use the same library, but in different versions (it is very bad, I know, this will be fixed). When I put a breakpoint in one of the classes, during debugging, Idea takes the first library (I think alphabetically), which in this case is unfortunately wrong.
The thing is, the libraries from all modules seem to be mixed in one bag for the whole project, not scoped per module, and idea lists the multiple versions there (again, from multiple modules). When I debug code in a module that uses a later version, Idea shows me the code from the earlier version. Can I specifically link the correct version somehow?

wujek

2
9 comments
Avatar
Permanently deleted user

Actually, the same happens when there are two classes with the same names - setting breakpoints in one of them results in code from the other one, which is useless. There must be some way...

0
Avatar
Permanently deleted user

Hi Wujek,

You need to instruct your run configuration what classpath should be used with it ('Use classpath of module' combobox).

Denis

0
Avatar
Permanently deleted user

Thanks for your answer.

It's a remote debugging configuration that debugs tomcat, and I deploy these 2 applications there. So, if I tell tomcat to use the classpath of one module, the other one cannot be really debugged, can it? Which sources / classpath would it use, then?

0
Avatar
Permanently deleted user

AFAIK the IDE doesn't offer an ability to distinguish between two different library versions during a single debug session. Will ask our 'debugger guys' to have a look here.

Denis

0
Avatar
Permanently deleted user

Hi Wujek,
> So, if I tell tomcat to use the classpath of one module
You actually tell this to run configuration: this is the "starting point" for IDEA to search for classes and sources.
You may have 2 run configurations for each application deployed in Tomcat

Regards
  Eugene.

0
Avatar
Permanently deleted user

Yes, I didn't mean I set the classpath on tomcat, but on the run configuration.
But can I really have 2 run configurations for the same tomcat? If I debug the first application, the remote debugger attaches to the JVM. By second attempt, I will get the 'cannot bind' error, as there already is some JPDA debugger attached - at lest that's my understanding. I would need two tomcats, one for each application, and start them (and their debugger servers) on different ports to avoid conflicts.

0
Avatar
Permanently deleted user

That's what I get when I try this, which is consistent what I said before:

        Error running tomcat-ext:
Unable to open debugger port :      java.net.ConnectException "Connection refused     

after I already attached another remote debugging.

Please note that I am using the generic 'Remote' congiguration, not the tomcat specific ones.

0
Avatar
Permanently deleted user

Sorry, I understood your situation a little bit differently.
One VM allows only one debugger connection at a time.
So if you have 2 separate applications each using its own version of the library, this approach will work, but in order to connect with second configuration you'll have to disconnect the first one.

If the same application uses both library versions, and you need to debug them at the same time, I think there is no general solution yet.
The problem is that debugger gets the fully qualified class name and line number as a location in the source code. IDEA searches for sources in the sourcepath beginning from the module specified in the run configuration, the same way the JVM searches for classes when it loads them.  
While it is possible to locate all places that correspond to the pair [classname, line number], the IDE must deside what to show. The current behaviour is to show the first one because this corresponds to the way VM loads classes.
If you have any suggestions of how this behaviour could be extended or improved, we'll be glad to discuss.

Regars,

   Eugene.

0
Avatar
Permanently deleted user

I have two apps, each uses a different version of the library (or a class with the same name in the same package - yes, we do have such abominations, hopefully only during transition...). Yes, it is true only one debugger can attach at a time, that's what I showed before. And yes, you are right, I can attach, debug, detach, attach another configuration, debug, detach, and so on.
My use case is different - one application has a web service server, which the other application calls (implemneted with apache cxf)/. I want to debug the conversation - I deploy both applications, then I debug the outgoing connection of the client application, it hangs during the call, in which time I debug the server side, and when the server side is ready, I can go back to debugging the client side. This is currently not possible if the apps use classes in the same packages (be it library jars, or our own classes).
I think this could be possible, as:
1. tomcat can handle it no problem, so there is no mixing in stuff, because:
2. both apps have different app classloaders
3. both classes named identically (again, jars or our code) come from different codebases (for example, we use maven 3, so they come from <project>/target/myapp, which is an exploded war)

The requirement is that JPDA can give you the codebases as well to be able to tell classes apart (at least, that's what I would consider the easiest solution, as you can match the codebase to the jars that IDEA knows about). I don't know whether this is the case, though, I haven't read the spec. That's also why I can't really suggest anything, as I simply don't know this stuff. If it really so, that the debugger only gets the full classname / line tuple, then of course there is nothing to be done, and it's a problem of JPDA, not the debugger. I will take a look when I find some time.

Until then, thank you very much for your assistence, I allowed me to improve my case considerably.

wujek

0

Please sign in to leave a comment.