1

This is a very strange behavior: I had a NoSuchMethodException (because the compile and runtime library versions did not match), and the container swallowed it and I did not have the chance to catch. Have a look at this code:

@MessageDriven(...)
public class NotificationReceiver implements MessageListener {
@Override
public void onMessage(Message message) {
    try {
        String textMessage = ((TextMessage) message).getText();
        logger.debug("NOTIFICATION RECEIVED: " + textMessage);
        ...
        String string = rootNode.get("id").asText();
        logger.debug("ID: " + string);

    } catch (Throwable e) {
        logger.debug("ERROR", e);
    }
}

This code is inteded to listen to text messages which are in JSON format, but whenever I receive it, I never get to point ID

DEBUG [p: thread-pool-1; w: 12] NotificationReceiver - NOTIFICATION RECEIVED: {"name":"X","id":"123"}

After this point I didn't receive any log...

Later I moved this code into another Stateless EJB inside an @Asynchronous method and called that from the MDB. Then I did receive the exception:

DEBUG [Ejb-Async-Thread-10] NotificationReceiverAsync - NOTIFICATION RECEIVED: {"name":"X","id":"123"}
DEBUG [Ejb-Async-Thread-10] NotificationReceiverAsync - ERROR java.lang.NoSuchMethodError: org.codehaus.jackson.JsonNode.asText()Ljava/lang/String;

How come that I never received the exception while in MDB?

Application Server: Glassfish 3.1.1

kavai77
  • 6,282
  • 7
  • 33
  • 48
  • Try setting up a breakpoint in the line with `String string = rootNode.has("id") ? rootNode.get("id").asText() : null;` and see what the sub-statements return. – LuGo Oct 29 '12 at 17:43

0 Answers0