activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mihai Osian <Mihai.Os...@gmail.com>
Subject JMSException: The resource is allready being used in transaction context.
Date Fri, 18 Nov 2011 13:27:49 GMT
  Hello, 

I get the exception from the subject when running a very simple test
application deployed in Glassfish, if there are multiple  JMS connections
created in parallel. 

. The issue has been encountered before by other users:
  
http://activemq.2283324.n4.nabble.com/Suspect-a-race-condition-in-TransactionContext-td3780046.html
and maybe 
  http://activemq.2283324.n4.nabble.com/Transaction-issues-td3549910.html

  but I have a test case to reproduce it. Shortly: I have a JaxRS
application that receives HTTP POSTs. The application calls an EJB whose
only purpose is to place a message in a JMS queue. A new JMS connection and
session is created for each individual send. When there are multiple
requests coming in at the same time, the Glassfish logs show the following
exception: 

[#|2011-11-18T13:43:57.304+0100|SEVERE|glassfish3.1|com.sun.jersey.spi.container.ContainerResponse|_ThreadID=27;_ThreadName=Thread-1;|The
exception contained within MappableContainerException could not be mapped to
a response, re-throwing to the HTTP container
javax.jms.JMSException: The resource is allready being used in transaction
context.
        at
org.apache.activemq.ra.ManagedTransactionContext.setUseSharedTxContext(ManagedTransactionContext.java:47)
        at
org.apache.activemq.ra.ManagedSessionProxy.setUseSharedTxContext(ManagedSessionProxy.java:67)
        at
org.apache.activemq.ra.ManagedConnectionProxy.createSessionProxy(ManagedConnectionProxy.java:122)
        at
org.apache.activemq.ra.ManagedConnectionProxy.createSession(ManagedConnectionProxy.java:105)
        at com.test.MessagingBean.postMessage(MessagingBean.java:34)
        at sun.reflect.GeneratedMethodAccessor465.invoke(Unknown Source)
     ....

The test application is attached to this mail (and also at
http://199.91.152.87/yq4mduia8qng/e8n9cxn8a7ujwlm/TestAMQ.tgz ). 

A Linux script that should download/install/configure all the required bits
and pieces: 
=========================================
mkdir tmp
cd tmp
wget http://download.java.net/glassfish/3.1/release/glassfish-3.1.zip
wget
http://apache.belnet.be//activemq/apache-activemq/5.5.1/apache-activemq-5.5.1-bin.tar.gz
wget --user-agent="Mozilla"
http://repo1.maven.org/maven2/org/apache/activemq/activemq-rar/5.5.1/activemq-rar-5.5.1.rar
wget http://slf4j.org/dist/slf4j-1.6.4.tar.gz

unzip glassfish-3.1.zip
tar -xzf apache-activemq-5.5.1-bin.tar.gz
tar -xzf slf4j-1.6.4.tar.gz

apache-activemq-5.5.1/bin/activemq start 

## install logging in glassfish
cp slf4j-1.6.4/slf4j-api-1.6.4.jar
glassfish3/glassfish/domains/domain1/lib/ext/
cp slf4j-1.6.4/slf4j-jdk14-1.6.4.jar
glassfish3/glassfish/domains/domain1/lib/ext/

glassfish3/bin/asadmin start-domain
glassfish3/bin/asadmin deploy activemq-rar-5.5.1.rar
glassfish3/bin/asadmin create-resource-adapter-config --threadpoolid
thread-pool-1 --property
UseInboundSession=false:Clientid=\"\":UserName=defaultUser:Password=defaultPassword:ServerUrl=tcp\\://localhost\\:61616

activemq-rar-5.5.1
glassfish3/bin/asadmin create-admin-object --restype javax.jms.Queue
--raname activemq-rar-5.5.1 --enabled=true --property PhysicalName=TestQueue
TestQueue
glassfish3/bin/asadmin create-connector-connection-pool --raname
activemq-rar-5.5.1 --connectiondefinition javax.jms.ConnectionFactory
jms/ActiveMQMsgPool
glassfish3/bin/asadmin create-connector-resource --poolname
jms/ActiveMQMsgPool ActiveMQConnResource

# install/deploy test app
tar -xzf TestAMQ.tgz
cd TestAMQ
mvn install
cd ../
glassfish3/bin/asadmin deploy --force
TestAMQ/testamq-ear/target/testamq-ear-0.0.1-SNAPSHOT.ear

# install Apache benchmark tool
sudo apt-get install apache2-utils

# create test file
echo "dummy test" > post.txt

# send it 100 times on 10 parallel threads
ab -n 100  -T text/plain  -p post.txt -c 10  
http://localhost:8080/TestAmqJaxrs/app/test

==============================

Thanks for any help, 
Mihai

http://activemq.2283324.n4.nabble.com/file/n4083218/TestAMQ.tgz TestAMQ.tgz 

  

--
View this message in context: http://activemq.2283324.n4.nabble.com/JMSException-The-resource-is-allready-being-used-in-transaction-context-tp4083218p4083218.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Mime
View raw message