Jan 26th, 2009, 07:51 PM
Can't debug a Message-Driven POJO, breakpoints ignored
I have a small application which sends messages to a queue and the queue is listened to by a Message-Driven POJO (MDP). I want to debug the MDP and I cannot do so when I run the code as a Java application, i.e. the code is within a main() method, however I can step into the MDP when I run the same exact code within a test method of a JUnit test case.
For example I have a file MyClass which has a public register() method which sends a message to the JMS destination to which the MDP is listening. I have set breakpoints in the MDP's onMessage() method. If I run a JUnit test which calls MyClass.register() then once the message has been received by the MDP the breakpoint in the MDP will be hit and execution stops as expected. However if I debug another class with the same exact code in a main() method then I don't get the debugger to stop at the expected breakpoints in the MDP onMessage().
In both cases I am using the same application context configuration file. I am using an embedded ActiveMQ broker to provide the destination.
It seems that when running as a JUnit test everything is happening within the same JVM, i.e. the MDP or MessageListenerContainer is running in the same JVM as the test case so the debugger can access it when the break point line gets hit, but when running the same code inside of a main() method it somehow can't access the MDP code and hence doesn't stop at the breakpoints in the onMessage() method of the MDP.
Does anyone know how this works, and/or how I might be able to debug the MDP when I run the code as a Java application?
Thanks in advance for any suggestions!
Tags for this Thread