Bug 738658 - Cannot commit session in a servlet
Summary: Cannot commit session in a servlet
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise MRG
Classification: Red Hat
Component: qpid-jca
Version: 2.0
Hardware: All
OS: All
unspecified
urgent
Target Milestone: 2.0.4
: ---
Assignee: messaging-bugs
QA Contact: MRG Quality Engineering
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-09-15 13:35 UTC by Martin Vecera
Modified: 2011-09-15 14:45 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-09-15 14:45:47 UTC


Attachments (Terms of Use)

Description Martin Vecera 2011-09-15 13:35:22 UTC
If I want to send a backlog of messages in a queue and I want the consumer to start processing the messages once they are all send, I need to create a transacted session and commit it in the end. This works smoothly with JBoss Messaging but is not possible with MRG in a servlet.

Steps to Reproduce:
1. checkout https://svn.devel.redhat.com/repos/jboss-qa/mrg/tests/mdb
2. fix annotation in
/mdb-ejb/src/main/java/org/jboss/test/mdb/MRGJCAMessageBean.java to point to
your MRG server (this class is not used in the test, but could prevent
deployment)
3. compile with mvn -DskipTests clean package
4. copy mdb/mdb-test/target/mdb-test.ear to deploy directory of EAP 5.1.1
(profile production)
5. checkout https://svn.devel.redhat.com/repos/jboss-qa/mrg/qpid-java-jca
6. configure qpid-java-jca/qpid-jca-ds.xml to point to your MRG server
7. copy qpid-java-jca/qpid* to server's deploy directory
7. Start EAP
8. Go to http://localhost:8080/mdb-servlet/mrgbasic and see server log.

The exception mentiones JEE specification, but I did not find anything in the specification that forbids this action. The exception is:

15:33:16,031 ERROR [STDERR] javax.jms.TransactionInProgressException: XASession:  A direct invocation of the commit operation is probibited!
15:33:16,032 ERROR [STDERR] 	at org.apache.qpid.client.XASessionImpl.commit(XASessionImpl.java:109)
15:33:16,032 ERROR [STDERR] 	at org.apache.qpid.ra.QpidRASessionImpl.commit(QpidRASessionImpl.java:425)
15:33:16,032 ERROR [STDERR] 	at org.jboss.test.mdb.MRGBasicOpServlet.doGet(MRGBasicOpServlet.java:61)
15:33:16,032 ERROR [STDERR] 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
15:33:16,032 ERROR [STDERR] 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
15:33:16,032 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
15:33:16,032 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
15:33:16,032 ERROR [STDERR] 	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
15:33:16,032 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
15:33:16,032 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
15:33:16,032 ERROR [STDERR] 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
15:33:16,032 ERROR [STDERR] 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
15:33:16,032 ERROR [STDERR] 	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:183)
15:33:16,032 ERROR [STDERR] 	at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:95)
15:33:16,032 ERROR [STDERR] 	at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
15:33:16,032 ERROR [STDERR] 	at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
15:33:16,032 ERROR [STDERR] 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
15:33:16,032 ERROR [STDERR] 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
15:33:16,032 ERROR [STDERR] 	at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
15:33:16,032 ERROR [STDERR] 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
15:33:16,032 ERROR [STDERR] 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
15:33:16,032 ERROR [STDERR] 	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
15:33:16,032 ERROR [STDERR] 	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:599)
15:33:16,032 ERROR [STDERR] 	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:451)
15:33:16,032 ERROR [STDERR] 	at java.lang.Thread.run(Thread.java:619)
15:33:16,032 ERROR [STDERR] javax.jms.IllegalStateException: This method is not applicable inside the application server. See the J2EE spec, e.g. J2EE1.4 Section 6.6
15:33:16,032 ERROR [STDERR] 	at org.apache.qpid.ra.QpidRASessionFactoryImpl.stop(QpidRASessionFactoryImpl.java:587)
15:33:16,032 ERROR [STDERR] 	at org.jboss.test.mdb.MRGBasicOpServlet.doGet(MRGBasicOpServlet.java:110)
15:33:16,032 ERROR [STDERR] 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
15:33:16,032 ERROR [STDERR] 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
15:33:16,032 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
15:33:16,032 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
15:33:16,032 ERROR [STDERR] 	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
15:33:16,032 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
15:33:16,032 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
15:33:16,032 ERROR [STDERR] 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
15:33:16,032 ERROR [STDERR] 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
15:33:16,032 ERROR [STDERR] 	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:183)
15:33:16,032 ERROR [STDERR] 	at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:95)
15:33:16,032 ERROR [STDERR] 	at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
15:33:16,032 ERROR [STDERR] 	at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
15:33:16,032 ERROR [STDERR] 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
15:33:16,032 ERROR [STDERR] 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
15:33:16,032 ERROR [STDERR] 	at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
15:33:16,032 ERROR [STDERR] 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
15:33:16,032 ERROR [STDERR] 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
15:33:16,032 ERROR [STDERR] 	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
15:33:16,032 ERROR [STDERR] 	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:599)
15:33:16,032 ERROR [STDERR] 	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:451)
15:33:16,032 ERROR [STDERR] 	at java.lang.Thread.run(Thread.java:619)

Comment 1 Weston M. Price 2011-09-15 13:58:12 UTC
If your using an XA ConnectionFactory, you will in turn create an XASession. Calling commit() on an XASession is prohibited as per the API:

http://java.sun.com/javaee/5/docs/api/javax/jms/XASession.html#commit()

For what you want to do, you need to use a notx-connection-factory since you are managing the transactions yourself. Config would look something like:


 <notx-connection-factory>
    <jndi-name>QpidJMS</jndi-name>
     .
     .
     .
  </notx-connection-factory>

Comment 2 Weston M. Price 2011-09-15 14:18:52 UTC
Sorry, that should read:

<no-tx-connection-factory>
    <jndi-name>QpidJMS</jndi-name>
     .
     .
     .
  </no-tx-connection-factory>

Comment 3 Weston M. Price 2011-09-15 14:45:47 UTC
See above comments for explanation.


Note You need to log in before you can comment on or make changes to this bug.