0 Replies Latest reply on Feb 5, 2013 10:36 AM by Akhbar Falafel

    Seam/JMS/HornetQ Problems -- "Only allowed one session per connection"?

    Akhbar Falafel Newbie

      I have a JBoss Seam 2.3 application that is trying to write events to a JMS queue on JBoss AS 7.1.  The writes are occurring within a stateless EJB, and use the standard Seam injection mechanism.  The code looks something like this (not an exact code snippet.  Just shows the type of thing I'm doing):






          public class MyEjb {










            private QueueSession queueSession;






            private QueueSender myQueueSender;










            public foo() {




                // Code to place a TextMessage on the queue








      However, I'm noticing that when the application is under load and this method is being called a lot, I get the following exception in the logs:


          21:58:57,800 ERROR [org.hornetq.ra.HornetQRASessionFactoryImpl] (http-- Could not create session: javax.jms.IllegalStateException: Only allowed one session per connection. See the J2EE spec, e.g. J2EE1.4 Section 6.6




          at org.hornetq.ra.HornetQRASessionFactoryImpl.allocateConnection(HornetQRASessionFactoryImpl.java:816)




          at org.hornetq.ra.HornetQRASessionFactoryImpl.createQueueSession(HornetQRASessionFactoryImpl.java:237)




          at org.jboss.seam.jms.QueueSession.create(QueueSession.java:38) [jboss-seam.jar:2.3.0.Final]




          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_07]




          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_07]




          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_07]




          at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_07]




          at org.jboss.seam.util.Reflections.invoke(Reflections.java:22) [jboss-seam.jar:2.3.0.Final]




          at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144) [jboss-seam.jar:2.3.0.Final]




          at org.jboss.seam.Component.callComponentMethod(Component.java:2313) [jboss-seam.jar:2.3.0.Final]




          at org.jboss.seam.Component.callCreateMethod(Component.java:2236) [jboss-seam.jar:2.3.0.Final]




          at org.jboss.seam.Component.newInstance(Component.java:2196) [jboss-seam.jar:2.3.0.Final]




          at org.jboss.seam.Component.getInstance(Component.java:2034) [jboss-seam.jar:2.3.0.Final]




          at org.jboss.seam.Component.getInstance(Component.java:1996) [jboss-seam.jar:2.3.0.Final]




          at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:60) [jboss-seam.jar:2.3.0.Final]




          at org.jboss.seam.Component.getInstanceInAllNamespaces(Component.java:2427) [jboss-seam.jar:2.3.0.Final]




          at org.jboss.seam.Component.getValueToInject(Component.java:2366) [jboss-seam.jar:2.3.0.Final]




          at org.jboss.seam.Component.injectAttributes(Component.java:1743) [jboss-seam.jar:2.3.0.Final]




          at org.jboss.seam.Component.inject(Component.java:1561) [jboss-seam.jar:2.3.0.Final]




          at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:61) [jboss-seam.jar:2.3.0.Final]




          at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) [jboss-seam.jar:2.3.0.Final]




          at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44) [jboss-seam.jar:2.3.0.Final]


      The foo() method is eventually being called after a request is sent to a RESTful service.  The client could potentially make a number of calls to this service in a row, but they are all distinct calls.


      Any idea what would be causing this Exception?  I've successfully used Seam and JMS in the past with no problem, but this application makes considerably more writes to the JMS queue than the ones I've written in the past.  My components.xml file is seutp correctly and I don't get any errors there.  Additionally, I have no problem making a single call to foo() and writing a message to the queue.  It only happens if I make a large number of sequential calls to the foo() method.  The messaging system I am using is HornetQ embedded within JBoss AS 7.1.  It *seems* to me to be some sort of issue around multiple threads trying to write messages to the queue.  I don't have any info beyond that, or any idea how to go about getting past this issue.  I would REALLY appreciate any help you can give.