Uploaded image for project: 'Bamboo Data Center'
  1. Bamboo Data Center
  2. BAM-16043

[MavenUtils] Failed to get Maven version, command timed out

      Replicate issue

      1. Download and Install CentOS 7.1 1503 x86_64
      2. under "/etc/yum.repos.d/" you should have the following .repo files by default (repos.zip)
      3. install Maven and check version
        [root@localhost service]# yum -y install maven-local apache-parent maven-plugin-bundle
        
        [root@localhost service]# which mvn
        /usr/bin/mvn
        
        [root@localhost service]# ls -l /usr/bin/mvn
        -rwxr-xr-x. 1 root root 219 Jun  9  2014 /usr/bin/mvn
        
        [root@localhost service]# ls -l /usr/share/maven
        total 4
        drwxr-xr-x. 2 root root   58 Jun 17 17:56 bin
        drwxr-xr-x. 2 root root   35 Jun 17 17:56 boot
        drwxr-xr-x. 2 root root   25 Jun 17 17:56 conf
        drwxr-xr-x. 3 root root 4096 Jun 17 17:56 lib
        
        [root@localhost ~]# /usr/bin/mvn --version
        Apache Maven 3.0.5 (Red Hat 3.0.5-16)
        Maven home: /usr/share/maven
        Java version: 1.8.0_45, vendor: Oracle Corporation
        Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.45-30.b13.el7_1.x86_64/jre
        Default locale: en_US, platform encoding: ANSI_X3.4-1968
        OS name: "linux", version: "3.10.0-229.el7.x86_64", arch: "amd64", family: "unix"
        
      4. configure Java to 1.8
        [root@localhost ~]# alternatives --config java
        
        [root@localhost ~]# java -version
        openjdk version "1.8.0_45"
        OpenJDK Runtime Environment (build 1.8.0_45-b13)
        OpenJDK 64-Bit Server VM (build 25.45-b02, mixed mode)
        
      5. open Bamboo connector port (8085)
        [root@localhost ~]# firewall-cmd --add-port=8085/tcp
        [root@localhost ~]# firewall-cmd --permanent --add-port=8090/tcp
        
        [root@localhost ~]# iptables -n -L
        ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:8085 ctstate NEW
        
      6. install wget
        [root@localhost ~]# yum -y install wget
        
      7. download Bamboo and install Bamboo
        [root@localhost ~]# cd /opt
        
        # create directory to Bamboo service
        [root@localhost ~]# mkdir /opt/service
        
        # create directory to Bamboo home
        [root@localhost ~]# mkdir /opt/home
        
        [root@localhost ~]# cd /opt/service
        [root@localhost service]# wget https://www.atlassian.com/software/bamboo/downloads/binary/atlassian-bamboo-5.8.1.tar.gz
        
        # extract Bamboo
        [root@localhost service]# tar -zxvf atlassian-bamboo-5.8.1.tar.gz
        
        # set up Bamboo home directory
        [root@localhost service]# vi atlassian-bamboo-5.8.1/atlassian-bamboo/WEB-INF/classes/bamboo-init.properties
        bamboo.home=/opt/home/bamboo-5.8.1
        
        # start Bamboo
        [root@localhost service]# cd atlassian-bamboo-5.8.1
        [root@localhost atlassian-bamboo-5.8.1]# ./bin/start-bamboo.sh
        
      8. logs from Bamboo while installation running catalina.out
        # in my example, I was not thrown with original issue raised as my Virtual Machine ran out of space before it happened.
        # however, you could be experiencing the following entry in the logs:
        
        2015-06-10 15:52:30,386 WARN [localhost-startStop-1] [MavenUtils] Failed to get Maven version, command timed out
        2015-06-10 15:52:30,390 WARN [localhost-startStop-1] [MavenUtils] Unable to get Maven version from /usr/bin/mvn
        
      9. extra information:
        [bamboo@localhost atlassian-bamboo-5.8.1]$ ps -AF | grep mvn | wc -l
        2117
        [bamboo@localhost atlassian-bamboo-5.8.1]$ px aux | grep bamboo
        ...
        bamboo    8902  0.0  0.0 113248   324 pts/1    S    19:05   0:00 /bin/sh /usr/bin/mvn --version
        bamboo    8905  0.0  0.0 113248   328 pts/1    S    19:05   0:00 /bin/sh /usr/bin/mvn --version
        bamboo    8908  0.0  0.0 113248   328 pts/1    S    19:05   0:00 /bin/sh /usr/bin/mvn --version
        bamboo    8911  0.0  0.0 113248   328 pts/1    S    19:05   0:00 /bin/sh /usr/bin/mvn --version
        bamboo    8914  0.0  0.0 113248   324 pts/1    S    19:05   0:00 /bin/sh /usr/bin/mvn --version
        bamboo    8917  0.0  0.0 113248   324 pts/1    S    19:05   0:00 /bin/sh /usr/bin/mvn --version
        bamboo    8920  0.0  0.0 113248   280 pts/1    S    19:05   0:00 /bin/sh /usr/bin/mvn --version
        bamboo    8923  0.0  0.0 113248   324 pts/1    S    19:05   0:00 /bin/sh /usr/bin/mvn --version
        bamboo    8926  0.0  0.0 113248   316 pts/1    S    19:05   0:00 /bin/sh /usr/bin/mvn --version
        bamboo    8929  0.0  0.0 113248   324 pts/1    S    19:05   0:00 /bin/sh /usr/bin/mvn --version
        bamboo    8932  0.0  0.0 113248   320 pts/1    S    19:05   0:00 /bin/sh /usr/bin/mvn --version
        bamboo    8935  0.0  0.0 113248   292 pts/1    S    19:05   0:00 /bin/sh /usr/bin/mvn --version
        bamboo    8938  0.0  0.0 113248   328 pts/1    S    19:05   0:00 /bin/sh /usr/bin/mvn --version
        bamboo    8941  0.0  0.0 113248   320 pts/1    S    19:05   0:00 /bin/sh /usr/bin/mvn --version
        bamboo    8944  0.0  0.0 113248   304 pts/1    S    19:05   0:00 /bin/sh /usr/bin/mvn --version
        bamboo    8947  0.0  0.0 113248   316 pts/1    S    19:05   0:00 /bin/sh /usr/bin/mvn --version
        bamboo    8950  0.0  0.0 113248   328 pts/1    S    19:05   0:00 /bin/sh /usr/bin/mvn --version
        bamboo    8953  0.0  0.0 113248   316 pts/1    S    19:05   0:00 /bin/sh /usr/bin/mvn --version
        bamboo    8956  0.0  0.0 113248   328 pts/1    S    19:05   0:00 /bin/sh /usr/bin/mvn --version
        bamboo    8959  0.0  0.0 113248   324 pts/1    S    19:05   0:00 /bin/sh /usr/bin/mvn --version
        ...
        

      Workaround

      1. please, download Apache Maven 3.0.5
        # download Maven
        wget ftp://mirror.reverse.net/pub/apache/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.tar.gz
        
      2. please, extract it under a directory (i.e.: /opt/maven)
        cd /opt/maven
        
        # extract Maven
        tar -zxvf apache-maven-3.0.5-bin.tar.gz
        
      3. please, set up M2_HOME environment variable
        export M2_HOME=/opt/maven/apache-maven-3.0.5
        
      4. please, add environment variable above to PATH
        export PATH=$M2_HOME/bin:$PATH
        
      5. please, run the following:
        mvn -version
        
        # command
        which mvn
        
        # response
        /opt/maven/apache-maven-3.0.5/bin/mvn
        

        1. catalina.out
          179 kB
        2. repos.zip
          4 kB

            [BAM-16043] [MavenUtils] Failed to get Maven version, command timed out

            Just upgraded to Bamboo 6.4.1 and noticed this on my Red Hat 7 Agents.  I initially thought something was fork bombing my servers with the number of maven processing being invoked.

            I assume that it's just a simple string parsing error in the agent?  It's probably not expecting the (Red Hat 3.0.5-REV) part in the output, especially if switching to a vanilla (not provided by Red Hat / CentOS) copy of maven doesn't have this issue.

            Jeffrey Thornsen added a comment - Just upgraded to Bamboo 6.4.1 and noticed this on my Red Hat 7 Agents.  I initially thought something was fork bombing my servers with the number of maven processing being invoked. I assume that it's just a simple string parsing error in the agent?  It's probably not expecting the (Red Hat 3.0.5-REV) part in the output, especially if switching to a vanilla (not provided by Red Hat / CentOS) copy of maven doesn't have this issue.

            atlassian1092 added a comment -

            The mvn executable is actually a wrapper script. Is there something odd about the way Bamboo tries to fork mvn --version? It shouldn't matter if the command is a wrapper script or not.

             

            [2017-07-20 09:25:57 bamboo@nyzls226d ~]$ which mvn
            /opt/rh/rh-maven33/root/usr/bin/mvn
            [2017-07-20 09:26:00 bamboo@nyzls226d ~]$ cat /opt/rh/rh-maven33/root/usr/bin/mvn
            #!/bin/sh
            if [ -f /opt/rh/rh-maven33/root/usr/share/java-utils/java-functions ] ; then
            . /opt/rh/rh-maven33/root/usr/share/java-utils/java-functions
            set_jvm
            set_javacmd
            fi
            export M2_HOME="${M2_HOME:-/opt/rh/rh-maven33/root/usr/share/maven}"
            export JAVA_HOME; $M2_HOME/bin/mvn "$@"

             

             

            atlassian1092 added a comment - The mvn executable is actually a wrapper script. Is there something odd about the way Bamboo tries to fork mvn --version ? It shouldn't matter if the command is a wrapper script or not.   [2017-07-20 09:25:57 bamboo@nyzls226d ~]$ which mvn /opt/rh/rh-maven33/root/usr/bin/mvn [2017-07-20 09:26:00 bamboo@nyzls226d ~]$ cat /opt/rh/rh-maven33/root/usr/bin/mvn #!/bin/sh if [ -f /opt/rh/rh-maven33/root/usr/share/java-utils/java-functions ] ; then . /opt/rh/rh-maven33/root/usr/share/java-utils/java-functions set_jvm set_javacmd fi export M2_HOME="${M2_HOME:-/opt/rh/rh-maven33/root/usr/share/maven}" export JAVA_HOME; $M2_HOME/bin/mvn "$@"    

            atlassian1092 added a comment -

            This also affects software collections rh-maven33 on CentOS 7. We have the following in our Bamboo agent's ~/.bashrc:

            source scl_source enable rh-maven33
            export M2_HOME="${M2_HOME:-/opt/rh/rh-maven33/root/usr/share/maven}"

            When we start the Bamboo agent it creates thousands of /bin/sh /opt/rh/rh-maven33/root/usr/bin/mvn --version processes, and we see the same error repeated in the logs 'Unable to get Maven version'.

             

            atlassian1092 added a comment - This also affects software collections rh-maven33  on CentOS 7. We have the following in our Bamboo agent's ~/.bashrc: source scl_source enable rh-maven33 export M2_HOME="${M2_HOME:-/opt/rh/rh-maven33/root/usr/share/maven}" When we start the Bamboo agent it creates thousands of /bin/sh /opt/rh/rh-maven33/root/usr/bin/mvn --version processes, and we see the same error repeated in the logs 'Unable to get Maven version'.  

            This is still broken on 6.0.1

            Andreas Rogge added a comment - This is still broken on 6.0.1

            domenic_palazzolo848184226 that's a slightly different bug that was fixed in 5.10: https://jira.atlassian.com/browse/BAM-15758

            Jeremy Owen added a comment - domenic_palazzolo848184226 that's a slightly different bug that was fixed in 5.10: https://jira.atlassian.com/browse/BAM-15758

            I'm getting this in Ubuntu 14.04 as well.  Any help would be appreciated!

            Here is my output from Bamboo:

            INFO | jvm 1 | 2017/02/13 11:46:30 | 2017-02-13 11:46:30,926 WARN [Thread-0] [MavenUtils] Unable to get Maven version from /usr/share/maven/bin/mvn
            INFO | jvm 1 | 2017/02/13 11:46:31 | 2017-02-13 11:46:31,660 WARN [Thread-0] [MavenUtils] Failed to get Maven version, unable to analyze output:
            INFO | jvm 1 | 2017/02/13 11:46:31 | Apache Maven 3.0.5
            INFO | jvm 1 | 2017/02/13 11:46:31 | Maven home: /usr/share/maven

             

             

             

            Domenic Palazzolo added a comment - I'm getting this in Ubuntu 14.04 as well.  Any help would be appreciated! Here is my output from Bamboo: INFO | jvm 1 | 2017/02/13 11:46:30 | 2017-02-13 11:46:30,926 WARN [Thread-0] [MavenUtils] Unable to get Maven version from /usr/share/maven/bin/mvn INFO | jvm 1 | 2017/02/13 11:46:31 | 2017-02-13 11:46:31,660 WARN [Thread-0] [MavenUtils] Failed to get Maven version, unable to analyze output: INFO | jvm 1 | 2017/02/13 11:46:31 | Apache Maven 3.0.5 INFO | jvm 1 | 2017/02/13 11:46:31 | Maven home: /usr/share/maven      

            The easiest solution with CentOS is to rename the mvn shell script in /usr/bin and make a symlink to the real mvn binary.

            mv /usr/bin/mvn /usr/bin/mvn.orig

             ln -s /usr/share/maven/bin/mvn /usr/bin/mvn

            Andy Wallis added a comment - The easiest solution with CentOS is to rename the mvn shell script in /usr/bin and make a symlink to the real mvn binary. mv /usr/bin/mvn /usr/bin/mvn.orig  ln -s /usr/share/maven/bin/mvn /usr/bin/mvn

            This still an ongoing issue, I am running Bamboo Agent on CentOS and have the same problem:

            [adrian@bamboo1 ~]$ uname -r
            3.10.0-327.28.3.el7.x86_64
            

            Tried the above workaround however no luck:

            INFO   | jvm 1    | 2016/10/12 11:59:01 | 2016-10-12 11:59:01,457 WARN [Thread-0] [MavenUtils] Unable to get Maven version from /usr/bin/mvn
            

            Have around 25000 threads with Bamboo trying to get the mvn version:

            [adrian@bamboo1 ~]$ ps aux | grep mvn | wc -l
            24646
            

            Not sure why it is still trying to reach maven on /bin/usr, as I set M2_HOME=/opt/maven/apache-maven-3.0.5 and which retuns the correct path:

            root     32766  0.0  0.0 113252  1596 ?        S    12:00   0:00 /bin/sh /usr/bin/mvn --version
            
            

            Any other workarounds?

            Adrian Tasca added a comment - This still an ongoing issue, I am running Bamboo Agent on CentOS and have the same problem: [adrian@bamboo1 ~]$ uname -r 3.10.0-327.28.3.el7.x86_64 Tried the above workaround however no luck: INFO | jvm 1 | 2016/10/12 11:59:01 | 2016-10-12 11:59:01,457 WARN [ Thread -0] [MavenUtils] Unable to get Maven version from /usr/bin/mvn Have around 25000 threads with Bamboo trying to get the mvn version: [adrian@bamboo1 ~]$ ps aux | grep mvn | wc -l 24646 Not sure why it is still trying to reach maven on /bin/usr, as I set M2_HOME=/opt/maven/apache-maven-3.0.5 and which retuns the correct path: root 32766 0.0 0.0 113252 1596 ? S 12:00 0:00 /bin/sh /usr/bin/mvn --version Any other workarounds?

            The issue was first diagnosed on my install about a year ago. After the workaround fixed the problem for me, I never took the time to investigate the deeper cause for the issue with the default maven install on CentOS. I'm surprised though that the Atlassian guys also didn't come up with a solution since then... especially since CentOS is a quite popular server distro.

            Josef Stöckl added a comment - The issue was first diagnosed on my install about a year ago. After the workaround fixed the problem for me, I never took the time to investigate the deeper cause for the issue with the default maven install on CentOS. I'm surprised though that the Atlassian guys also didn't come up with a solution since then... especially since CentOS is a quite popular server distro.

            jmo added a comment -

            So what is it this workaround is doing? There's something wrong with the yum supplied version of maven 3.0.5 that the official tarball fixes?

            jmo added a comment - So what is it this workaround is doing? There's something wrong with the yum supplied version of maven 3.0.5 that the official tarball fixes?

              mgardias Marcin Gardias
              rsperafico Rafael Sperafico (Inactive)
              Affected customers:
              11 This affects my team
              Watchers:
              25 Start watching this issue

                Created:
                Updated:
                Resolved: