The Runtime.correlateMessage(msg) method throws an exception when the subscribed message is on a sub process boundary.
To recreate, create a subprocess with a user task (or some other wait state) and add a boundary message event to the subprocess. Use a separate process to generate the message event via say runtime.correlateMessage(messageName). Using a script task, I get a null pointer exception. To confirm that its not the script task, if I put the boundary event on the user task, then correlation works as expected.
I suspect the same applies to a boundary event on a transaction