8 Replies Latest reply on Dec 11, 2001 5:04 PM by Michel de Groot

    Invalid transaction id

    Michel de Groot Newbie

      I'm trying to post a message from within a session bean to a topic. I'm getting JMSException: invalid transaction id, and I'm really stuck now. Please help!

      I've followed the JMS with managed resource example in the free documentation, running on JBoss 2.4.0.

      This is (part of) the ejb-jar.xml:

      The Transaction managed Topic ConnectionFactory
      Daisy Store change topic

      This is the jboss.xml:



      <configuration-name>Standard Stateless SessionBean</configuration-name>


      This is the session ejb implementation:
      (init is called first, then publish)

      * Publish the given String as a JMS message to the topic.
      private void doPublish(String action, String name)
      throws JMSException {
      TopicSession topicSession = null;
      TopicPublisher topicPublisher;

      Log log = new Log(this.getClass());
      log.debug("Publish in session bean called");

      try {
      // Create the session; transaction managed if this thread has
      // an associated transaction; must be recreated for
      // each transaction (we do it for each call)
      try {
      log.debug("creating session for transaction "+
      topicSession = topicConnection.createTopicSession(
      } catch (SystemException e) {
      // Create a publisher
      topicPublisher = topicSession.createPublisher(topic);

      // Create a message
      TextMessage message = topicSession.createTextMessage();
      message.setStringProperty(EventConstants.ACTION_KEY, action);
      message.setStringProperty(EventConstants.NAME_KEY, name);

      // Publish the message
      topicPublisher.publish(topic, message);
      } finally {
      // close the session; it is pooled by the container
      if (topicSession != null) {

      // close the

      public void init()
      throws JMSException, NamingException {

      // Get the initial context
      Context context = new InitialContext();

      // Get the connection factory
      TopicConnectionFactory topicFactory = (TopicConnectionFactory)context.lookup(CONNECTION_FACTORY);

      // Create the connection
      topicConnection = topicFactory.createTopicConnection();

      // Look up the destination
      topic = (Topic)context.lookup(TOPIC);

      Some jndi definitions:
      private static String CONNECTION_FACTORY = "java:/INVMXATopicConnectionFactory";

      /** The topic to use; defined in ejb-jar.xml */
      private static String TOPIC = "java:comp/env/jms/DaisyStoreChanges";

      In jbossmq.xml:

      There are no ClassCast, NullPointer, NamingExceptions.

      I need the JMS messages to be in the transaction context, because they must only be delivered on successful commit, and not before the commit (otherwise a nasty deadlock results).

      Any suggestions are welcome!

      Michel de Groot