Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-14529

BindException when using --daemon with JMX

    Details

    • Similar Issues:

      Description

      java -Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -jar jenkins.war --deamon

      results in

      Forking into background to run as a daemon.
      Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 9999; nested exception is:
      java.net.BindException: Address already in use

      This means I cannot use VisualVM on a deamonized Jenkins instance.

      I encountered this problem when using the RPM installer to setup Jenkins and afterwards manually adding the -D options to JENKINS_JAVA_OPTIONS in /etc/sysconfig/jenkins.

        Attachments

          Issue Links

            Activity

            Hide
            jglick Jesse Glick added a comment -

            Note: fix only available in JDK 7u4+: http://bugs.sun.com/view_bug.do?bug_id=7110104

            Show
            jglick Jesse Glick added a comment - Note: fix only available in JDK 7u4+: http://bugs.sun.com/view_bug.do?bug_id=7110104
            Hide
            danielbeck Daniel Beck added a comment -

            Jesse Glick: Do you know whether Java 8 broke this? A user reports that the issue still occurs in 1.509.x with Java 8 in JENKINS-23023

            Show
            danielbeck Daniel Beck added a comment - Jesse Glick : Do you know whether Java 8 broke this? A user reports that the issue still occurs in 1.509.x with Java 8 in JENKINS-23023
            Hide
            jglick Jesse Glick added a comment -

            Not sure. I do not see any relevant changes in Agent.java in Java 8, and the JENKINS-23023 description does not mention the could not simulate … log message being printed. But of course behavioral changes here or in other classes could have broken my fix.

            Show
            jglick Jesse Glick added a comment - Not sure. I do not see any relevant changes in Agent.java in Java 8, and the JENKINS-23023 description does not mention the could not simulate … log message being printed. But of course behavioral changes here or in other classes could have broken my fix.
            Hide
            astaruch Andrej Staruch added a comment -

            Hi,

            I think that this problem still occurs in Java 11.

            $ java --version
            openjdk 11.0.6 2020-01-14
            OpenJDK Runtime Environment (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1)
            OpenJDK 64-Bit Server VM (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1, mixed mode, sharing)
            
            

            Jenkins:

            Jenkins ver. 2.204.2 

             

            Running Jenkins as daemon due to JMX:

            $ ps aux | grep daemon
            jenkins  30792  0.0  0.0  19096    24 ?        S    Feb26   0:00 /usr/bin/daemon --name=jenkins --inherit --env=JENKINS_HOME=/var/lib/jenkins --output=/var/log/jenkins/jenkins.log --pidfile=/var/run/jenkins/jenkins.pid -- /usr/bin/java -Djava.awt.headless=true -Dhudson.security.csrf.DefaultCrumbIssuer.EXCLUDE_SESSION_ID=true -Dhudson.model.ParametersAction.keepUndefinedParameters=true -Dhudson.remoting.ClassFilter=org.jenkinsci.plugins.fstrigger.triggers.FolderContentTrigger,org.jenkinsci.lib.xtrigger.AbstractTrigger -Dhudson.model.DirectoryBrowserSupport.CSP= -Xms2G -Xmx2G -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -jar /usr/share/jenkins/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080 --ajp13Port=-1
             

            Restarting Jenkins:

            sudo service jenkins restart 

            Log:

            Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 9010; nested exception is: 
            	java.net.BindException: Address already in use (Bind failed)
            jdk.internal.agent.AgentConfigurationError: java.rmi.server.ExportException: Port already in use: 9010; nested exception is: 
            	java.net.BindException: Address already in use (Bind failed)
            	at jdk.management.agent/sun.management.jmxremote.ConnectorBootstrap.startRemoteConnectorServer(ConnectorBootstrap.java:491)
            	at jdk.management.agent/jdk.internal.agent.Agent.startAgent(Agent.java:447)
            	at jdk.management.agent/jdk.internal.agent.Agent.startAgent(Agent.java:599)
            Caused by: java.rmi.server.ExportException: Port already in use: 9010; nested exception is: 
            	java.net.BindException: Address already in use (Bind failed)
            	at java.rmi/sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:335)
            	at java.rmi/sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:243)
            	at java.rmi/sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:412)
            	at java.rmi/sun.rmi.transport.LiveRef.exportObject(LiveRef.java:147)
            	at java.rmi/sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:234)
            	at java.rmi/sun.rmi.registry.RegistryImpl.setup(RegistryImpl.java:220)
            	at java.rmi/sun.rmi.registry.RegistryImpl.<init>(RegistryImpl.java:180)
            	at jdk.management.agent/sun.management.jmxremote.SingleEntryRegistry.<init>(SingleEntryRegistry.java:49)
            	at jdk.management.agent/sun.management.jmxremote.ConnectorBootstrap.exportMBeanServer(ConnectorBootstrap.java:836)
            	at jdk.management.agent/sun.management.jmxremote.ConnectorBootstrap.startRemoteConnectorServer(ConnectorBootstrap.java:479)
            	... 2 more
            Caused by: java.net.BindException: Address already in use (Bind failed)
            	at java.base/java.net.PlainSocketImpl.socketBind(Native Method)
            	at java.base/java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:436)
            	at java.base/java.net.ServerSocket.bind(ServerSocket.java:395)
            	at java.base/java.net.ServerSocket.<init>(ServerSocket.java:257)
            	at java.base/java.net.ServerSocket.<init>(ServerSocket.java:149)
            	at java.rmi/sun.rmi.transport.tcp.TCPDirectSocketFactory.createServerSocket(TCPDirectSocketFactory.java:45)
            	at java.rmi/sun.rmi.transport.tcp.TCPEndpoint.newServerSocket(TCPEndpoint.java:670)
            	at java.rmi/sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:324)
            	... 11 more
             
            Show
            astaruch Andrej Staruch added a comment - Hi, I think that this problem still occurs in Java 11. $ java --version openjdk 11.0.6 2020-01-14 OpenJDK Runtime Environment (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1) OpenJDK 64-Bit Server VM (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1, mixed mode, sharing) Jenkins: Jenkins ver. 2.204.2   Running Jenkins as daemon due to JMX: $ ps aux | grep daemon jenkins 30792 0.0 0.0 19096 24 ? S Feb26 0:00 /usr/bin/daemon --name=jenkins --inherit --env=JENKINS_HOME=/ var /lib/jenkins --output=/ var /log/jenkins/jenkins.log --pidfile=/ var /run/jenkins/jenkins.pid -- /usr/bin/java -Djava.awt.headless= true -Dhudson.security.csrf.DefaultCrumbIssuer.EXCLUDE_SESSION_ID= true -Dhudson.model.ParametersAction.keepUndefinedParameters= true -Dhudson.remoting.ClassFilter=org.jenkinsci.plugins.fstrigger.triggers.FolderContentTrigger,org.jenkinsci.lib.xtrigger.AbstractTrigger -Dhudson.model.DirectoryBrowserSupport.CSP= -Xms2G -Xmx2G -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.local.only= false -Dcom.sun.management.jmxremote.authenticate= false -Dcom.sun.management.jmxremote.ssl= false -jar /usr/share/jenkins/jenkins.war --webroot=/ var /cache/jenkins/war --httpPort=8080 --ajp13Port=-1 Restarting Jenkins: sudo service jenkins restart Log: Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 9010; nested exception is: java.net.BindException: Address already in use (Bind failed) jdk.internal.agent.AgentConfigurationError: java.rmi.server.ExportException: Port already in use: 9010; nested exception is: java.net.BindException: Address already in use (Bind failed) at jdk.management.agent/sun.management.jmxremote.ConnectorBootstrap.startRemoteConnectorServer(ConnectorBootstrap.java:491) at jdk.management.agent/jdk.internal.agent.Agent.startAgent(Agent.java:447) at jdk.management.agent/jdk.internal.agent.Agent.startAgent(Agent.java:599) Caused by: java.rmi.server.ExportException: Port already in use: 9010; nested exception is: java.net.BindException: Address already in use (Bind failed) at java.rmi/sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:335) at java.rmi/sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:243) at java.rmi/sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:412) at java.rmi/sun.rmi.transport.LiveRef.exportObject(LiveRef.java:147) at java.rmi/sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:234) at java.rmi/sun.rmi.registry.RegistryImpl.setup(RegistryImpl.java:220) at java.rmi/sun.rmi.registry.RegistryImpl.<init>(RegistryImpl.java:180) at jdk.management.agent/sun.management.jmxremote.SingleEntryRegistry.<init>(SingleEntryRegistry.java:49) at jdk.management.agent/sun.management.jmxremote.ConnectorBootstrap.exportMBeanServer(ConnectorBootstrap.java:836) at jdk.management.agent/sun.management.jmxremote.ConnectorBootstrap.startRemoteConnectorServer(ConnectorBootstrap.java:479) ... 2 more Caused by: java.net.BindException: Address already in use (Bind failed) at java.base/java.net.PlainSocketImpl.socketBind(Native Method) at java.base/java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:436) at java.base/java.net.ServerSocket.bind(ServerSocket.java:395) at java.base/java.net.ServerSocket.<init>(ServerSocket.java:257) at java.base/java.net.ServerSocket.<init>(ServerSocket.java:149) at java.rmi/sun.rmi.transport.tcp.TCPDirectSocketFactory.createServerSocket(TCPDirectSocketFactory.java:45) at java.rmi/sun.rmi.transport.tcp.TCPEndpoint.newServerSocket(TCPEndpoint.java:670) at java.rmi/sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:324) ... 11 more
            Hide
            jjathman Joe Athman added a comment -

            we have this problem with Java 11 as well, anyone have a workaround?

            Show
            jjathman Joe Athman added a comment - we have this problem with Java 11 as well, anyone have a workaround?

              People

              • Assignee:
                Unassigned
                Reporter:
                gsash Georg Sash
              • Votes:
                3 Vote for this issue
                Watchers:
                10 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: