Karaf
  1. Karaf
  2. KARAF-1574

When two karaf containers are started locally, an exception is displayed at startup. A nicer message would be better.

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.7
    • Fix Version/s: 2.2.9, 2.3.0, 3.0.0
    • Component/s: None
    • Labels:
      None

      Description

      
      gnodet:~/work/apps/apache-karaf-2.2.8$ bin/karaf 
      Exception in thread "JMX Connector Thread [service:jmx:rmi://0.0.0.0:44444/jndi/rmi://0.0.0.0:1099/karaf-root]" java.lang.RuntimeException: Could not start JMX connector server
      	at org.apache.karaf.management.ConnectorServerFactory$1.run(ConnectorServerFactory.java:233)
      Caused by: java.rmi.server.ExportException: Port already in use: 44444; nested exception is: 
      	java.net.BindException: Address already in use
      	at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:310)
      	at sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:218)
      	at sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:393)
      	at sun.rmi.transport.LiveRef.exportObject(LiveRef.java:129)
      	at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:188)
      	at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:293)
      	at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:256)
      	at javax.management.remote.rmi.RMIJRMPServerImpl.export(RMIJRMPServerImpl.java:82)
      	at javax.management.remote.rmi.RMIJRMPServerImpl.export(RMIJRMPServerImpl.java:75)
      	at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:388)
      	at org.apache.karaf.management.ConnectorServerFactory$1.run(ConnectorServerFactory.java:231)
      Caused by: java.net.BindException: Address already in use
      	at java.net.PlainSocketImpl.socketBind(Native Method)
      	at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:383)
      	at java.net.ServerSocket.bind(ServerSocket.java:328)
      	at java.net.ServerSocket.<init>(ServerSocket.java:194)
      	at java.net.ServerSocket.<init>(ServerSocket.java:106)
      	at sun.rmi.transport.proxy.RMIDirectSocketFactory.createServerSocket(RMIDirectSocketFactory.java:27)
      	at sun.rmi.transport.proxy.RMIMasterSocketFactory.createServerSocket(RMIMasterSocketFactory.java:333)
      	at sun.rmi.transport.tcp.TCPEndpoint.newServerSocket(TCPEndpoint.java:649)
      	at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:299)
      	... 10 more
              __ __                  ____      
             / //_/____ __________ _/ __/      
            / ,<  / __ `/ ___/ __ `/ /_        
           / /| |/ /_/ / /  / /_/ / __/        
          /_/ |_|\__,_/_/   \__,_/_/         
      
        Apache Karaf (2.2.8)
      
      Hit '<tab>' for a list of available commands
      and '[cmd] --help' for help on a specific command.
      Hit '<ctrl-d>' or 'osgi:shutdown' to shutdown Karaf.
      
      karaf@root> 
      

      Catching this exception and displaying a nicer and more informative message would be a good idea.

      1. karaf-3.0_1574.diff
        2 kB
        Heath Kesler
      2. karaf-2.3_1574.diff
        2 kB
        Heath Kesler

        Activity

        Hide
        Jean-Baptiste Onofré added a comment -

        When I do that, I update 1099 and 44444 port in the etc/org.apache.karaf.management.cfg file.

        Is it not good enough ?

        Show
        Jean-Baptiste Onofré added a comment - When I do that, I update 1099 and 44444 port in the etc/org.apache.karaf.management.cfg file. Is it not good enough ?
        Hide
        Jean-Baptiste Onofré added a comment -

        Ah sorry, I guess that you talk about the message displayed ?

        Show
        Jean-Baptiste Onofré added a comment - Ah sorry, I guess that you talk about the message displayed ?
        Hide
        Guillaume Nodet added a comment -

        Yeah, we should display a better message indicating the usual cause (i.e. you started two containers) and indicating a way to solve that, maybe pouting to the online user manual page, or briefly explaining the steps.

        Show
        Guillaume Nodet added a comment - Yeah, we should display a better message indicating the usual cause (i.e. you started two containers) and indicating a way to solve that, maybe pouting to the online user manual page, or briefly explaining the steps.
        Hide
        Heath Kesler added a comment -

        I updated the exception handling to check for a bind exception and adds a more detailed explanation of what causes a port binding issue.

        NOTE: I do not add in the bind exception to the runtime, let me know if you think that should still be displayed and I will add it back in.

        if this is patch is approved I will update 2.2.9 and 2.3.0.

        Show
        Heath Kesler added a comment - I updated the exception handling to check for a bind exception and adds a more detailed explanation of what causes a port binding issue. NOTE: I do not add in the bind exception to the runtime, let me know if you think that should still be displayed and I will add it back in. if this is patch is approved I will update 2.2.9 and 2.3.0.
        Hide
        Freeman Fang added a comment -

        Hi Heath,

        It's OK for me basically, I don't think we need the whole original BindException, but if you can indicate which port can't bind, that would be great, something like
        It is unable to bind to port xxx...
        Thanks for the patch.

        Freeman

        Show
        Freeman Fang added a comment - Hi Heath, It's OK for me basically, I don't think we need the whole original BindException, but if you can indicate which port can't bind, that would be great, something like It is unable to bind to port xxx... Thanks for the patch. Freeman
        Hide
        Heath Kesler added a comment -

        updated the patch to show the port number and added some newline feeds in order to make it a little more readable.

        Show
        Heath Kesler added a comment - updated the patch to show the port number and added some newline feeds in order to make it a little more readable.
        Hide
        Heath Kesler added a comment -

        added patch for 2.3 as well.

        Show
        Heath Kesler added a comment - added patch for 2.3 as well.
        Hide
        Freeman Fang added a comment -

        The patch looks good to me, I will apply the patch soon.
        Thanks
        Freeman

        Show
        Freeman Fang added a comment - The patch looks good to me, I will apply the patch soon. Thanks Freeman
        Hide
        Freeman Fang added a comment -
        Show
        Freeman Fang added a comment - apply patch on behalf of Heath Kesler with thanks http://svn.apache.org/viewvc?rev=1370601&view=rev for trunk http://svn.apache.org/viewvc?rev=1370602&view=rev for 2.3.x branch http://svn.apache.org/viewvc?rev=1370603&view=rev for 2.2.x branch

          People

          • Assignee:
            Freeman Fang
            Reporter:
            Guillaume Nodet
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development