One more thing, I have tried as you said, but it gave me the below exception, (Looks Transaction Manager is not set CONTAINER
@TransactionManagement(value= TransactionManagementType.CONTAINER)
@TransactionAttribute(value= TransactionAttributeType.REQUIRED)
@ResourceAdapter("genericra.rar")
@MessageDriven(mappedName = "NextWABMDB")
public class NextWABMDB implements MessageListener , MessageDrivenBean{
private MessageDrivenContext context;
private static final Logger LOG = Logger.getLogger(NextWABMDB.class);
private final MessageProcessor messageProcessor;
public NextWABMDB() {
this.messageProcessor = new MessageProcessor();
StatisticExceptionDetector statisticExceptionDetector = new StatisticExceptionDetector();
Thread.setDefaultUncaughtExceptionHandler(statisticExceptionDetector);
}
public void setMessageDrivenContext(MessageDrivenContext ctx){
this.context = ctx;
}
public void ejbRemove() {
// implement the method just like a PreDestroy() method
}
@Override
public void onMessage(Message message){
UserTransaction utx= context.getUserTransaction();
try{
try {
if (message instanceof TextMessage) {
TextMessage msg = (TextMessage) message;
this.messageProcessor.processNextWABXMLMessage(msg.getText());
int i = 2/0;
} else if (message instanceof ObjectMessage) {
LOG.error("Received message was an ObjectMessage and will be ignored!");
} else {
LOG.error("Received message was not an Object- or TextMessage and will be ignored!");
}
} catch (JMSException e) {
LOG.error("JMSException during onMessage.", e);
}
catch (Throwable t) {
LOG.error("Exception during onMessage New.", t);
utx.setRollbackOnly();
LOG.error("RollBack Done");
throw new Exception(t.getMessage());
}
}catch (Exception e) {
LOG.error("Exception during onMessage.", e);
}
}
}