I’m quite new in JavaEE and trying to deal with JMS stuff. Here is the MessageBean that implement MessageListener and Override onMessage where I consequently try to receive message from Queue My code snippet:
@Override
public void onMessage(Message message) {
try{
System.out.println(message.getBody(String.class));
}catch(JMSException e){
System.err.println(e.toString());
}
}
But unfortunately there is an compiling error that method getBody cannot be resolved and marked as red in IntelliJ. Help me figure out. Thanks in advance
The method
getBody(Class<T> c)
is new in JMS 2.0. Your project is almost certainly including the JMS 1.1 specification jar. Change your project so you include the JMS 2.0 specification jar instead and that error should go away.