Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JMSSampler closes InitialContext too early #3409

Closed
asfimport opened this issue Aug 4, 2014 · 2 comments
Closed

JMSSampler closes InitialContext too early #3409

asfimport opened this issue Aug 4, 2014 · 2 comments

Comments

@asfimport
Copy link
Collaborator

Bradford Hovinen (Bug 56809):
JMSSampler closes the InitialContext in threadStarted, before the individual requests are sent. When authentication is required for the queue, the credentials are then lost with the closure of the InitialContext. As a result, all send-operations run into the following error:

JMSSecurityException: Access denied to resource: type=<jms>, application=xxxx, destinationType=queue, resource=xxxx, action=send
at weblogic.jms.dispatcher.DispatcherAdapter.convertToJMSExceptionAndThrow(DispatcherAdapter.java:110)
at weblogic.jms.dispatcher.DispatcherAdapter.dispatchSyncTran(DispatcherAdapter.java:53)
at weblogic.jms.client.JMSProducer.toFEProducer(JMSProducer.java:1300)
at weblogic.jms.client.JMSProducer.deliveryInternal(JMSProducer.java:807)
at weblogic.jms.client.JMSProducer.sendInternal(JMSProducer.java:543)
at weblogic.jms.client.JMSProducer.sendWithListener(JMSProducer.java:394)
at weblogic.jms.client.JMSProducer.send(JMSProducer.java:384)
at weblogic.jms.client.WLProducerImpl.send(WLProducerImpl.java:970)
at org.apache.jmeter.protocol.jms.sampler.FixedQueueExecutor.sendAndReceive(FixedQueueExecutor.java:87)
at org.apache.jmeter.protocol.jms.sampler.JMSSampler.sample(JMSSampler.java:151)
at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:429)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:257)
at java.lang.Thread.run(Thread.java:744)
Caused by: weblogic.jms.common.JMSSecurityException: Access denied to resource: type=<jms>, application=ppit-jms-module, destinationType=queue, resource=Sebula.Prepaid.Asynch.Request, action=send
at weblogic.utils.StackTraceDisabled.unknownMethod()
Caused by: weblogic.jms.common.JMSSecurityException: Access denied to resource: type=<jms>, application=ppit-jms-module, destinationType=queue, resource=Sebula.Prepaid.Asynch.Request, action=send
... 1 more
Caused by: weblogic.jms.common.JMSSecurityException: Access denied to resource: type=<jms>, application=ppit-jms-module, destinationType=queue, resource=Sebula.Prepaid.Asynch.Request, action=send
... 1 more

The solution is to close the InitialContext in threadFinished instead. A patch is attached.

(Running against a JMS-queue on Weblogic 12.1.2)

Created attachment jmeter.patch: Patch to fix problem

jmeter.patch
diff -ru a/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/JMSSampler.java b/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/JMSSampler.java
--- a/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/JMSSampler.java	2014-08-04 14:33:11.451584550 +0200
+++ b/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/JMSSampler.java	2014-08-04 14:33:39.005584637 +0200
@@ -124,6 +124,8 @@
 
     private transient Throwable thrown = null;
 
+    private transient Context context = null;
+
     /**
      * {@inheritDoc}
      */
@@ -313,7 +315,6 @@
     public void threadStarted() {
         logThreadStart();
 
-        Context context = null;
         thrown = null;
         try {
             context = getInitialContext();
@@ -383,14 +384,6 @@
         } catch (NoClassDefFoundError e) {
             thrown = e;
             LOGGER.error(e.getLocalizedMessage(), e);
-        } finally {
-            if (context != null) {
-                try {
-                    context.close();
-                } catch (NamingException ignored) {
-                    // ignore
-                }
-            }
         }
     }
 
@@ -468,6 +461,14 @@
     public void threadFinished() {
         LOGGER.debug("Thread ended " + new Date());
 
+        if (context != null) {
+            try {
+                context.close();
+            } catch (NamingException ignored) {
+                // ignore
+            }
+        }
+
         Utils.close(session, LOGGER);
         Utils.close(connection, LOGGER);
         if (receiverThread != null) {

Severity: normal
OS: All

@asfimport
Copy link
Collaborator Author

@pmouawad (migrated from Bugzilla):
Date: Fri Aug 22 21:11:17 2014
New Revision: 1619932

URL: http://svn.apache.org/r1619932
Log:
#3409 - JMSSampler closes InitialContext too early
#3409

Modified:
jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/JMSSampler.java
jmeter/trunk/xdocs/changes.xml

@asfimport
Copy link
Collaborator Author

@pmouawad (migrated from Bugzilla):
Thanks for contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant