Debugging openHAB 2 / or how to view threads

Is there a way to attach a debugger to openHAB 2 in Eclipse? OpenHAB seems to be running out of threads in a thread pool, and I would like to see which binding is hogging all the threads. I have 5 custom bindings, so it’s very impractical to try to reproduce it, because it sometimes takes days to happen.

If it’s not possible to use a debugger, how would I go about troubleshoot something like this? When I get this condition, no command will run at all (not just the item in the output below).

2016-03-05 17:44:49.710 [WARN ] [.core.common.ThreadPoolManager:192  ] - Thread pool 'safeCall' rejected execution of class java.util.concurrent.FutureTask
2016-03-05 17:44:54.710 [DEBUG] [s.core.common.SafeMethodCaller:188  ] - Timeout of 5000ms exceeded with no thread info available.
2016-03-05 17:44:54.711 [WARN ] [.c.thing.internal.ThingManager:301  ] - Handler for thing 'folding:slot:4e43fad8' takes more than 5000ms for processing event
2016-03-05 17:44:54.711 [DEBUG] [s.core.common.SafeMethodCaller:184  ] - Timeout of 5000ms exceeded, thread ESH-safeCall-124 (1590) in state TIMED_WAITING is at sun.misc.Unsafe.park(Unsafe.java:-2).
2016-03-05 17:44:54.711 [WARN ] [.s.c.i.events.OSGiEventManager:198  ] - Dispatching event to subscriber 'org.eclipse.smarthome.core.thing.internal.ThingManager@4fa86eb0' takes more than 5000ms.
2016-03-05 17:44:54.711 [INFO ] [arthome.event.ItemCommandEvent:43   ] - Item 'folding_slot_4e43fad8_pause' received command OFF
2016-03-05 17:44:54.712 [DEBUG] [.c.thing.internal.ThingManager:290  ] - Delegating command 'OFF' for item 'folding_slot_cd16eff6_pause' to handler for channel 'folding:slot:cd16eff6:pause'
2016-03-05 17:44:54.712 [WARN ] [.core.common.ThreadPoolManager:192  ] - Thread pool 'safeCall' rejected execution of class java.util.concurrent.FutureTask
2016-03-05 17:44:59.712 [DEBUG] [s.core.common.SafeMethodCaller:188  ] - Timeout of 5000ms exceeded with no thread info available.
2016-03-05 17:44:59.712 [WARN ] [.c.thing.internal.ThingManager:301  ] - Handler for thing 'folding:slot:cd16eff6' takes more than 5000ms for processing event
2016-03-05 17:44:59.712 [DEBUG] [s.core.common.SafeMethodCaller:184  ] - Timeout of 5000ms exceeded, thread ESH-safeCall-124 (1590) in state TIMED_WAITING is at sun.misc.Unsafe.park(Unsafe.java:-2).

Yes, there absolutely is!
Just start the instance with start_debug.sh and it will listen to remote debugging on port 5005.
See here on how to do remote debugging of Java applications with Eclipse.

Thanks for the reply! With the “Addon development” setup I don’t actually have karaf where the start.sh script expects it. I did found a debug configuration in Eclipse though, which worked. That was the first thing I looked for before I posted here, so I don’t understand how I could have overlooked that. Anyway, I have debugging, so it’s all good.