Yeah, as JB mentioned, Karaf mode in Pax Exam is forked so the classpath
from the test bootstrap itself does not spill over into the container (for
native pax exam, you can choose between forked mode or not).
Anyway, remote debugging seems to be a bit easier in Intellij (I stopped
using Eclipse several years ago). Remote debugging is turned on by adding
the following VM option (regardless of IDE, obviously):
vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005")
Then when the test is launched in debug mode, Intellij emits:
Listening for transport dt_socket at address: 5005
And next to that log statement, there is something akin to a button that
says "Attach debugger", which I can just click to be able to debug the
container (it takes a few seconds to attach).
No need to create a special debug configuration
However, I did notice that all log output from then on doesn't seem to
appear anywhere, which is a bit annoying, but I'm sure that can be
resolved. Inspecting all objects etc, which is the important stuff, works
fine, however.
- Eric L
On Tue, Jun 6, 2023 at 7:27 PM Steinar Bang <[email protected]> wrote:
> >>>>> Jean-Baptiste Onofré <[email protected]>:
>
> > As pax-exam can fork the JVM to start Karaf, you need remote debugger.
>
> Hm... but does it fork the JUnit test also?
>
> That's where I'm trying to debug...?
>
> Ah, but you're right! To be able to run the way it does, i.e. access
> OSGi services created in karaf as Java objects, the JUnit test has to be
> in the same JVM as karaf is running.
>
> > Is it what you are doing ?
>
> No, I think that would be hard here.
>
> I use the remote debugger all the time with karaf proper, where it works
> perfectly, I might add.
>
> But in a pax exam karaf test I have time to set up remote debugging,
> from the time the test starts and it ends.
>
> I had hoped there was an eclipse run configuration that could be used,
> maybe...?
>
> I googled "pax exam eclipse run configuration" and found these two:
> https://stackoverflow.com/a/43149241
>
> https://confluence.i2cat.net/m/mobile.action#page/17567089#HowtomakeanintegrationtestwithPaxExam-Debuggingyourtest
>
> I'll dig deeper into these two.
>
> Thanks!
>
>