Jmeter in distributed mode: JVM doesn't stop because of BeanShell server





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















WHAT I HAVE:



Jmeter network created for tests in distributed mode: one Jmeter master plus few Jmeter slaves. BeanShell Server disabled. Everything works fine.



WHAT I WANT TO DO:



I want to enable BeanShell server to be able to modify properties on the fly.



ACTUAL RESULT:



BeanShell server starts and works successfully.
Once the test is done, the following message appears in the log:



The JVM should have exited but did not.
The following non-daemon threads are still running (DestroyJavaVM is OK):
Thread[Thread-7,5,main], stackTrace:java.net.PlainSocketImpl#socketAccept
java.net.AbstractPlainSocketImpl#accept at line:409
java.net.ServerSocket#implAccept at line:545
java.net.ServerSocket#accept at line:513
bsh.util.Sessiond#run at line:65
java.lang.Thread#run at line:748

Thread[Thread-5,5,main], stackTrace:java.net.PlainSocketImpl#socketAccept
java.net.AbstractPlainSocketImpl#accept at line:409
java.net.ServerSocket#implAccept at line:545
java.net.ServerSocket#accept at line:513
bsh.util.Httpd#run at line:64
java.lang.Thread#run at line:748


It's clear that it happens because of BeanShell server that is running and doesn't exit for some reason.
As a result, java process will never exit and will hang.



QUESTION:



Any ideas why it happens? How to avoid it? I don't connect to beanshell server, neither by http nor by telnet.



MORE DETAILS:



All the nodes are running as Docker containers.
All nodes are deployed in AWS.
Can't reproduce the same issue locally on my machine. Even with BeanShell server enabled, all works smooth, and java exists as it should.



WHAT I TRIED:



Tried to set up the following properties:



jmeterengine.remote.system.exit=true    
jmeterengine.stopfail.system.exit=true
jmeterengine.force.system.exit=true


Doesn't help, java process still hangs.
The same for



bsh.system.shutdownOnExit = true;


Any ideas are very much appreciated.










share|improve this question































    0















    WHAT I HAVE:



    Jmeter network created for tests in distributed mode: one Jmeter master plus few Jmeter slaves. BeanShell Server disabled. Everything works fine.



    WHAT I WANT TO DO:



    I want to enable BeanShell server to be able to modify properties on the fly.



    ACTUAL RESULT:



    BeanShell server starts and works successfully.
    Once the test is done, the following message appears in the log:



    The JVM should have exited but did not.
    The following non-daemon threads are still running (DestroyJavaVM is OK):
    Thread[Thread-7,5,main], stackTrace:java.net.PlainSocketImpl#socketAccept
    java.net.AbstractPlainSocketImpl#accept at line:409
    java.net.ServerSocket#implAccept at line:545
    java.net.ServerSocket#accept at line:513
    bsh.util.Sessiond#run at line:65
    java.lang.Thread#run at line:748

    Thread[Thread-5,5,main], stackTrace:java.net.PlainSocketImpl#socketAccept
    java.net.AbstractPlainSocketImpl#accept at line:409
    java.net.ServerSocket#implAccept at line:545
    java.net.ServerSocket#accept at line:513
    bsh.util.Httpd#run at line:64
    java.lang.Thread#run at line:748


    It's clear that it happens because of BeanShell server that is running and doesn't exit for some reason.
    As a result, java process will never exit and will hang.



    QUESTION:



    Any ideas why it happens? How to avoid it? I don't connect to beanshell server, neither by http nor by telnet.



    MORE DETAILS:



    All the nodes are running as Docker containers.
    All nodes are deployed in AWS.
    Can't reproduce the same issue locally on my machine. Even with BeanShell server enabled, all works smooth, and java exists as it should.



    WHAT I TRIED:



    Tried to set up the following properties:



    jmeterengine.remote.system.exit=true    
    jmeterengine.stopfail.system.exit=true
    jmeterengine.force.system.exit=true


    Doesn't help, java process still hangs.
    The same for



    bsh.system.shutdownOnExit = true;


    Any ideas are very much appreciated.










    share|improve this question



























      0












      0








      0








      WHAT I HAVE:



      Jmeter network created for tests in distributed mode: one Jmeter master plus few Jmeter slaves. BeanShell Server disabled. Everything works fine.



      WHAT I WANT TO DO:



      I want to enable BeanShell server to be able to modify properties on the fly.



      ACTUAL RESULT:



      BeanShell server starts and works successfully.
      Once the test is done, the following message appears in the log:



      The JVM should have exited but did not.
      The following non-daemon threads are still running (DestroyJavaVM is OK):
      Thread[Thread-7,5,main], stackTrace:java.net.PlainSocketImpl#socketAccept
      java.net.AbstractPlainSocketImpl#accept at line:409
      java.net.ServerSocket#implAccept at line:545
      java.net.ServerSocket#accept at line:513
      bsh.util.Sessiond#run at line:65
      java.lang.Thread#run at line:748

      Thread[Thread-5,5,main], stackTrace:java.net.PlainSocketImpl#socketAccept
      java.net.AbstractPlainSocketImpl#accept at line:409
      java.net.ServerSocket#implAccept at line:545
      java.net.ServerSocket#accept at line:513
      bsh.util.Httpd#run at line:64
      java.lang.Thread#run at line:748


      It's clear that it happens because of BeanShell server that is running and doesn't exit for some reason.
      As a result, java process will never exit and will hang.



      QUESTION:



      Any ideas why it happens? How to avoid it? I don't connect to beanshell server, neither by http nor by telnet.



      MORE DETAILS:



      All the nodes are running as Docker containers.
      All nodes are deployed in AWS.
      Can't reproduce the same issue locally on my machine. Even with BeanShell server enabled, all works smooth, and java exists as it should.



      WHAT I TRIED:



      Tried to set up the following properties:



      jmeterengine.remote.system.exit=true    
      jmeterengine.stopfail.system.exit=true
      jmeterengine.force.system.exit=true


      Doesn't help, java process still hangs.
      The same for



      bsh.system.shutdownOnExit = true;


      Any ideas are very much appreciated.










      share|improve this question
















      WHAT I HAVE:



      Jmeter network created for tests in distributed mode: one Jmeter master plus few Jmeter slaves. BeanShell Server disabled. Everything works fine.



      WHAT I WANT TO DO:



      I want to enable BeanShell server to be able to modify properties on the fly.



      ACTUAL RESULT:



      BeanShell server starts and works successfully.
      Once the test is done, the following message appears in the log:



      The JVM should have exited but did not.
      The following non-daemon threads are still running (DestroyJavaVM is OK):
      Thread[Thread-7,5,main], stackTrace:java.net.PlainSocketImpl#socketAccept
      java.net.AbstractPlainSocketImpl#accept at line:409
      java.net.ServerSocket#implAccept at line:545
      java.net.ServerSocket#accept at line:513
      bsh.util.Sessiond#run at line:65
      java.lang.Thread#run at line:748

      Thread[Thread-5,5,main], stackTrace:java.net.PlainSocketImpl#socketAccept
      java.net.AbstractPlainSocketImpl#accept at line:409
      java.net.ServerSocket#implAccept at line:545
      java.net.ServerSocket#accept at line:513
      bsh.util.Httpd#run at line:64
      java.lang.Thread#run at line:748


      It's clear that it happens because of BeanShell server that is running and doesn't exit for some reason.
      As a result, java process will never exit and will hang.



      QUESTION:



      Any ideas why it happens? How to avoid it? I don't connect to beanshell server, neither by http nor by telnet.



      MORE DETAILS:



      All the nodes are running as Docker containers.
      All nodes are deployed in AWS.
      Can't reproduce the same issue locally on my machine. Even with BeanShell server enabled, all works smooth, and java exists as it should.



      WHAT I TRIED:



      Tried to set up the following properties:



      jmeterengine.remote.system.exit=true    
      jmeterengine.stopfail.system.exit=true
      jmeterengine.force.system.exit=true


      Doesn't help, java process still hangs.
      The same for



      bsh.system.shutdownOnExit = true;


      Any ideas are very much appreciated.







      jmeter beanshell






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 26 '18 at 17:10







      Konstantin Dobroliubov

















      asked Nov 26 '18 at 16:36









      Konstantin DobroliubovKonstantin Dobroliubov

      3581316




      3581316
























          2 Answers
          2






          active

          oldest

          votes


















          1














          I don't think there is a way of stopping the Beanshell Server along with the test as it runs in an endless-loop Thread



          I would recommend stopping your test and the Beanshell server using a .bsh file like:



          stopEngine();
          Thread.sleep(5000L); // just in case wait for 5 seconds for graceful shutdown
          System.exit(0);


          where:





          • stopEngine() is a shorthand for StandardJMeterEngine.stopEngine(), it's defined in startup.bsh


          • System.exit(0); - basically shuts down the whole JVM with 0 exit status code


          So you will be able to turn everything off the same way you amend the properties in the runtime.



          You can also achieve the same by executing the System.exit(0); command automatically from i.e. tearDown Thread Group using OS Process Sampler, however in this case make sure to set the following property:



          jmeter.save.saveservice.autoflush=true


          otherwise you can loose some results which have not been written to disk yet






          share|improve this answer
























          • Thanks for so quick answer! That's exactly what I do now. But it doesn't help in a case when test already stopped by itself, not by stop command. The idea with TearDown thread looks great in this case, so will add it.

            – Konstantin Dobroliubov
            Nov 26 '18 at 17:26











          • However, still don't have answer for a question why it doesn't stop by itself. The same docker container with beanshell server exits fine locally. So, it seems like something establishes a connection on AWS side, and since connection is opened, it doesn't allow to stop java properly. That is really weird as I don't allow any external connection by FW rules, so connection is done to localhost inside container only.

            – Konstantin Dobroliubov
            Nov 26 '18 at 17:29



















          0














          Finally, I found a workaround, so posting it as an answer here.



          Actually, it doesn't answer the original question in fact, but don't want to waste time trying to find an original root cause as it seems to be related to AWS structure (just because I can't reproduce it locally inside the same container I launch remotely).



          So, the final schema is:




          1. To update properties on the fly, I don't have to launch BeanShell on slave and master both. Real property change happens on slave, so master is not required. It solves my specific case.


          2. To stop test, you can use existent shutdown.sh and stoptest.sh scripts. No need to do it over beanshell server.


          3. If the test was properly stopped, then -X option (server.exitaftertest=true) also works fine, so force shutdown for JVM is not required, and you don't have to add tearDown thread group that does System.exit. But the idea is nice.


          4. It's worth to have a shutdown.bsh script to force kill it anyway as a tool.







          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53485433%2fjmeter-in-distributed-mode-jvm-doesnt-stop-because-of-beanshell-server%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            I don't think there is a way of stopping the Beanshell Server along with the test as it runs in an endless-loop Thread



            I would recommend stopping your test and the Beanshell server using a .bsh file like:



            stopEngine();
            Thread.sleep(5000L); // just in case wait for 5 seconds for graceful shutdown
            System.exit(0);


            where:





            • stopEngine() is a shorthand for StandardJMeterEngine.stopEngine(), it's defined in startup.bsh


            • System.exit(0); - basically shuts down the whole JVM with 0 exit status code


            So you will be able to turn everything off the same way you amend the properties in the runtime.



            You can also achieve the same by executing the System.exit(0); command automatically from i.e. tearDown Thread Group using OS Process Sampler, however in this case make sure to set the following property:



            jmeter.save.saveservice.autoflush=true


            otherwise you can loose some results which have not been written to disk yet






            share|improve this answer
























            • Thanks for so quick answer! That's exactly what I do now. But it doesn't help in a case when test already stopped by itself, not by stop command. The idea with TearDown thread looks great in this case, so will add it.

              – Konstantin Dobroliubov
              Nov 26 '18 at 17:26











            • However, still don't have answer for a question why it doesn't stop by itself. The same docker container with beanshell server exits fine locally. So, it seems like something establishes a connection on AWS side, and since connection is opened, it doesn't allow to stop java properly. That is really weird as I don't allow any external connection by FW rules, so connection is done to localhost inside container only.

              – Konstantin Dobroliubov
              Nov 26 '18 at 17:29
















            1














            I don't think there is a way of stopping the Beanshell Server along with the test as it runs in an endless-loop Thread



            I would recommend stopping your test and the Beanshell server using a .bsh file like:



            stopEngine();
            Thread.sleep(5000L); // just in case wait for 5 seconds for graceful shutdown
            System.exit(0);


            where:





            • stopEngine() is a shorthand for StandardJMeterEngine.stopEngine(), it's defined in startup.bsh


            • System.exit(0); - basically shuts down the whole JVM with 0 exit status code


            So you will be able to turn everything off the same way you amend the properties in the runtime.



            You can also achieve the same by executing the System.exit(0); command automatically from i.e. tearDown Thread Group using OS Process Sampler, however in this case make sure to set the following property:



            jmeter.save.saveservice.autoflush=true


            otherwise you can loose some results which have not been written to disk yet






            share|improve this answer
























            • Thanks for so quick answer! That's exactly what I do now. But it doesn't help in a case when test already stopped by itself, not by stop command. The idea with TearDown thread looks great in this case, so will add it.

              – Konstantin Dobroliubov
              Nov 26 '18 at 17:26











            • However, still don't have answer for a question why it doesn't stop by itself. The same docker container with beanshell server exits fine locally. So, it seems like something establishes a connection on AWS side, and since connection is opened, it doesn't allow to stop java properly. That is really weird as I don't allow any external connection by FW rules, so connection is done to localhost inside container only.

              – Konstantin Dobroliubov
              Nov 26 '18 at 17:29














            1












            1








            1







            I don't think there is a way of stopping the Beanshell Server along with the test as it runs in an endless-loop Thread



            I would recommend stopping your test and the Beanshell server using a .bsh file like:



            stopEngine();
            Thread.sleep(5000L); // just in case wait for 5 seconds for graceful shutdown
            System.exit(0);


            where:





            • stopEngine() is a shorthand for StandardJMeterEngine.stopEngine(), it's defined in startup.bsh


            • System.exit(0); - basically shuts down the whole JVM with 0 exit status code


            So you will be able to turn everything off the same way you amend the properties in the runtime.



            You can also achieve the same by executing the System.exit(0); command automatically from i.e. tearDown Thread Group using OS Process Sampler, however in this case make sure to set the following property:



            jmeter.save.saveservice.autoflush=true


            otherwise you can loose some results which have not been written to disk yet






            share|improve this answer













            I don't think there is a way of stopping the Beanshell Server along with the test as it runs in an endless-loop Thread



            I would recommend stopping your test and the Beanshell server using a .bsh file like:



            stopEngine();
            Thread.sleep(5000L); // just in case wait for 5 seconds for graceful shutdown
            System.exit(0);


            where:





            • stopEngine() is a shorthand for StandardJMeterEngine.stopEngine(), it's defined in startup.bsh


            • System.exit(0); - basically shuts down the whole JVM with 0 exit status code


            So you will be able to turn everything off the same way you amend the properties in the runtime.



            You can also achieve the same by executing the System.exit(0); command automatically from i.e. tearDown Thread Group using OS Process Sampler, however in this case make sure to set the following property:



            jmeter.save.saveservice.autoflush=true


            otherwise you can loose some results which have not been written to disk yet







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 26 '18 at 17:20









            Dmitri TDmitri T

            74.9k33765




            74.9k33765













            • Thanks for so quick answer! That's exactly what I do now. But it doesn't help in a case when test already stopped by itself, not by stop command. The idea with TearDown thread looks great in this case, so will add it.

              – Konstantin Dobroliubov
              Nov 26 '18 at 17:26











            • However, still don't have answer for a question why it doesn't stop by itself. The same docker container with beanshell server exits fine locally. So, it seems like something establishes a connection on AWS side, and since connection is opened, it doesn't allow to stop java properly. That is really weird as I don't allow any external connection by FW rules, so connection is done to localhost inside container only.

              – Konstantin Dobroliubov
              Nov 26 '18 at 17:29



















            • Thanks for so quick answer! That's exactly what I do now. But it doesn't help in a case when test already stopped by itself, not by stop command. The idea with TearDown thread looks great in this case, so will add it.

              – Konstantin Dobroliubov
              Nov 26 '18 at 17:26











            • However, still don't have answer for a question why it doesn't stop by itself. The same docker container with beanshell server exits fine locally. So, it seems like something establishes a connection on AWS side, and since connection is opened, it doesn't allow to stop java properly. That is really weird as I don't allow any external connection by FW rules, so connection is done to localhost inside container only.

              – Konstantin Dobroliubov
              Nov 26 '18 at 17:29

















            Thanks for so quick answer! That's exactly what I do now. But it doesn't help in a case when test already stopped by itself, not by stop command. The idea with TearDown thread looks great in this case, so will add it.

            – Konstantin Dobroliubov
            Nov 26 '18 at 17:26





            Thanks for so quick answer! That's exactly what I do now. But it doesn't help in a case when test already stopped by itself, not by stop command. The idea with TearDown thread looks great in this case, so will add it.

            – Konstantin Dobroliubov
            Nov 26 '18 at 17:26













            However, still don't have answer for a question why it doesn't stop by itself. The same docker container with beanshell server exits fine locally. So, it seems like something establishes a connection on AWS side, and since connection is opened, it doesn't allow to stop java properly. That is really weird as I don't allow any external connection by FW rules, so connection is done to localhost inside container only.

            – Konstantin Dobroliubov
            Nov 26 '18 at 17:29





            However, still don't have answer for a question why it doesn't stop by itself. The same docker container with beanshell server exits fine locally. So, it seems like something establishes a connection on AWS side, and since connection is opened, it doesn't allow to stop java properly. That is really weird as I don't allow any external connection by FW rules, so connection is done to localhost inside container only.

            – Konstantin Dobroliubov
            Nov 26 '18 at 17:29













            0














            Finally, I found a workaround, so posting it as an answer here.



            Actually, it doesn't answer the original question in fact, but don't want to waste time trying to find an original root cause as it seems to be related to AWS structure (just because I can't reproduce it locally inside the same container I launch remotely).



            So, the final schema is:




            1. To update properties on the fly, I don't have to launch BeanShell on slave and master both. Real property change happens on slave, so master is not required. It solves my specific case.


            2. To stop test, you can use existent shutdown.sh and stoptest.sh scripts. No need to do it over beanshell server.


            3. If the test was properly stopped, then -X option (server.exitaftertest=true) also works fine, so force shutdown for JVM is not required, and you don't have to add tearDown thread group that does System.exit. But the idea is nice.


            4. It's worth to have a shutdown.bsh script to force kill it anyway as a tool.







            share|improve this answer




























              0














              Finally, I found a workaround, so posting it as an answer here.



              Actually, it doesn't answer the original question in fact, but don't want to waste time trying to find an original root cause as it seems to be related to AWS structure (just because I can't reproduce it locally inside the same container I launch remotely).



              So, the final schema is:




              1. To update properties on the fly, I don't have to launch BeanShell on slave and master both. Real property change happens on slave, so master is not required. It solves my specific case.


              2. To stop test, you can use existent shutdown.sh and stoptest.sh scripts. No need to do it over beanshell server.


              3. If the test was properly stopped, then -X option (server.exitaftertest=true) also works fine, so force shutdown for JVM is not required, and you don't have to add tearDown thread group that does System.exit. But the idea is nice.


              4. It's worth to have a shutdown.bsh script to force kill it anyway as a tool.







              share|improve this answer


























                0












                0








                0







                Finally, I found a workaround, so posting it as an answer here.



                Actually, it doesn't answer the original question in fact, but don't want to waste time trying to find an original root cause as it seems to be related to AWS structure (just because I can't reproduce it locally inside the same container I launch remotely).



                So, the final schema is:




                1. To update properties on the fly, I don't have to launch BeanShell on slave and master both. Real property change happens on slave, so master is not required. It solves my specific case.


                2. To stop test, you can use existent shutdown.sh and stoptest.sh scripts. No need to do it over beanshell server.


                3. If the test was properly stopped, then -X option (server.exitaftertest=true) also works fine, so force shutdown for JVM is not required, and you don't have to add tearDown thread group that does System.exit. But the idea is nice.


                4. It's worth to have a shutdown.bsh script to force kill it anyway as a tool.







                share|improve this answer













                Finally, I found a workaround, so posting it as an answer here.



                Actually, it doesn't answer the original question in fact, but don't want to waste time trying to find an original root cause as it seems to be related to AWS structure (just because I can't reproduce it locally inside the same container I launch remotely).



                So, the final schema is:




                1. To update properties on the fly, I don't have to launch BeanShell on slave and master both. Real property change happens on slave, so master is not required. It solves my specific case.


                2. To stop test, you can use existent shutdown.sh and stoptest.sh scripts. No need to do it over beanshell server.


                3. If the test was properly stopped, then -X option (server.exitaftertest=true) also works fine, so force shutdown for JVM is not required, and you don't have to add tearDown thread group that does System.exit. But the idea is nice.


                4. It's worth to have a shutdown.bsh script to force kill it anyway as a tool.








                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 27 '18 at 10:40









                Konstantin DobroliubovKonstantin Dobroliubov

                3581316




                3581316






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53485433%2fjmeter-in-distributed-mode-jvm-doesnt-stop-because-of-beanshell-server%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Wiesbaden

                    Marschland

                    Dieringhausen