3 Replies Latest reply on Oct 21, 2013 4:31 AM by flyaway_921

    Maven + Surefire + Byteman + java.io.tmpdir = Tests failures


      Hi all,


        We are using in our project Byteman with our Junit Tests Managed by Maven and its surefire plugin to add some additionnal controls (number of jdbc queries used for ex).

        Cleaning up our build I wanted to apply this maven recommandation : http://olamy.blogspot.fr/2012/08/maven-surefire-configuration-for-ci.html

         It is to avoid to have all builds using the same /tmp directory thus I wanted to put that in our coporate pom to be sure that it is used by all projects.

         Adding this setting broke all our tests using byteman

        It is now always failing to connect with an error like this :

      java.net.ConnectException: Connection refused

                at java.net.PlainSocketImpl.socketConnect(Native Method)

                at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)

                at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)

                at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)

                at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)

                at java.net.Socket.connect(Socket.java:529)

                at java.net.Socket.connect(Socket.java:478)

                at java.net.Socket.<init>(Socket.java:375)

                at java.net.Socket.<init>(Socket.java:189)

                at org.jboss.byteman.agent.submit.Submit$Comm.<init>(Submit.java:797)

                at org.jboss.byteman.agent.submit.Submit.submitRequest(Submit.java:735)

                at org.jboss.byteman.agent.submit.Submit.addScripts(Submit.java:574)

                at org.jboss.byteman.agent.submit.Submit.addRulesFromFiles(Submit.java:547)

                at org.jboss.byteman.contrib.bmunit.BMUnit.loadScriptFile(BMUnit.java:305)

                at org.exoplatform.social.core.test.AbstractCoreTest.setUp(AbstractCoreTest.java:60)

                at org.exoplatform.social.core.storage.cache.CachedIdentityStorageTestCase.setUp(CachedIdentityStorageTestCase.java:46)

                at junit.framework.TestCase.runBare(TestCase.java:132)

                at org.exoplatform.component.test.AbstractGateInTest.runBare(AbstractGateInTest.java:87)

                at junit.framework.TestResult$1.protect(TestResult.java:110)

                at junit.framework.TestResult.runProtected(TestResult.java:128)

                at junit.framework.TestResult.run(TestResult.java:113)

                at junit.framework.TestCase.run(TestCase.java:124)

                at junit.framework.TestSuite.runTest(TestSuite.java:243)

                at junit.framework.TestSuite.run(TestSuite.java:238)



        I don't see at all the relation between the system property java.io.tmpdir and byteman.

        I looked at your code and saw nothing strange like an hardcoded tmp directory.


        Is it something that someone already saw ?

         Are there some others users who may try this setting to see if they have the same problem ?


        All advices are welcome





        • 1. Re: Maven + Surefire + Byteman + java.io.tmpdir = Tests failures

          Hi Arnaud,


          No, this problem has not been reported already.


          I don't really know what is happening here but I suspect that it is something to do with file/directory permissions. The default socket host used by class BMSubmit is localhost. So, this means the native socketConnect call under which the error oocurs will be trying to open and connect on an AF_UNIX socket in java.io.tmpdir.


          If that is the case then I would have expected other operations which use the TMP dir to have problems though. Maybe you could try opening a regular file or creating a subdir in java.io.tmpdir to see if they work.


          Another possibility might be that your Java security policy is disallowing file operations in whatever directory you have chosen as the value of java.io.tmpdir.


          Is the agent running in the same JVM as the one running the BMSubmit call? (n.b. if you are simply using BMUNit and have not disabled agent loading -- yes you can do that -- then the answer is yes). The agent opens a listener socket which the connect call is trying to connect to. I ask that because if the problem is socket permissions then I would have expected the agent should load to fail when it tries to open the listener socket. I think that ought to print a warning to the console but maybe you could run the test with proeprty org.jboss.byteman.verbose set and see if you get any errors printed to the console.

          • 2. Re: Maven + Surefire + Byteman + java.io.tmpdir = Tests failures

            Hi Andrew,


              In my case I set java.io.tmpdir to the maven property value ${project.build.directory} thus it is sure I can write in it (as maven does it). I didn't notice any other issue with tmp dir orperation nor errors reported by byteman (I'll do a new test to give you the debug output).

               For the java security policy I will verify. I'm using the default one (from Macos JDK).

               Yes, the agent is in the same JVM as we are calling directly BMUNit from our tests.


               Thx for your help. I will try to have more logs to diagnose the issue





            • 3. Re: Maven + Surefire + Byteman + java.io.tmpdir = Tests failures

              I meet the same problem



              java.net.ConnectException: Connection refused

                  at java.net.PlainSocketImpl.socketConnect(Native Method)

                  at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:327)

                  at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:193)

                  at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180)

                  at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:385)

                  at java.net.Socket.connect(Socket.java:546)

                  at java.net.Socket.connect(Socket.java:495)

                  at java.net.Socket.<init>(Socket.java:392)

                  at java.net.Socket.<init>(Socket.java:206)

                  at org.jboss.byteman.agent.submit.Submit$Comm.<init>(Submit.java:871)

                  at org.jboss.byteman.agent.submit.Submit.submitRequest(Submit.java:777)

                  at org.jboss.byteman.agent.submit.Submit.addScripts(Submit.java:595)

                  at org.jboss.byteman.contrib.bmunit.BMUnit.loadScriptText(BMUnit.java:384)

                  at org.jboss.byteman.contrib.bmunit.BMUnitRunner$8.evaluate(BMUnitRunner.java:344)

                  at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)

                  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)

                  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)

                  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)

                  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)

                  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)

                  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)

                  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)

                  at org.junit.runners.ParentRunner.run(ParentRunner.java:309)

                  at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)

                  at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

                  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

                  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

                  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

                  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)



              java.io.FileNotFoundException: Install : ${BYTEMAN_HOME} does not identify a directory


              How to deal with it..