Invalid transaction id error
jaikiran May 20, 2005 5:17 AMHi,
I am working on JBoss-3.2.3. I have a standalone class which tries writing to a JMS queue. I have been getting the following exception, every time i try sending a message:
Invalid Transaction Id
My code is as follows:
Context ctx = new InitialContext();
System.out.println("Got context");
QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) ctx.lookup("java:/JmsXA");
System.out.println("Got queue connection factory");
Queue queue = (Queue)ctx.lookup("queue/myQueue");
System.out.println("Got queue:"+queue);
QueueConnection queueConnection = queueConnectionFactory.createQueueConnection();
QueueSession queueSession = queueConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
QueueSender queueSender = queueSession.createSender(queue);
Message message = queueSession.createMessage();
message.setStringProperty("VMID",vmid.toString());
queueSender.send(message);
System.out.println("Sent message");I get the exception at the point :
queueSender.send();
I tried out by starting and committing a dummy transaction. But the same error occurs. Below is the code for the same:
UserTransaction transaction = new DummyUserTransaction(DummyTransactionManager.getInstance());
transaction.begin();
try {
Context ctx = new InitialContext();
System.out.println("Got context");
QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) ctx.lookup("java:/JmsXA");
System.out.println("Got queue connection factory");
Queue queue = (Queue)ctx.lookup("queue/Anamika");
System.out.println("Got queue:"+queue);
QueueConnection queueConnection = queueConnectionFactory.createQueueConnection();
QueueSession queueSession = queueConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
QueueSender queueSender = queueSession.createSender(queue);
Message message = queueSession.createMessage();
message.setStringProperty("VMID",vmid.toString());
queueSender.send(message);
commitTransaction(transaction);
System.out.println("Sent message");I have seen a lot of posts talking about the same error, but havent found a solution. Is there any solution for the same?
Thank you.