6 Replies Latest reply on Mar 18, 2014 11:32 AM by Clebert Suconic

    Address already in use with NettyAcceptor

    D P Newbie

      I am developing one Spring application server with HotnetQ embedded to pubsub service. I have the next class described more below to manager HornetQ server.

      But, when I deploy my application I get the next error in tomcat console.

      I have been changing Netty acceptor port number, but problem persist, If I use other acceptor instead Netty it work fine, but I am interested in Netty Acceptor type.

      Setting ServerMQ configuration...
      Initializing ServerMQ...
      mar
      12, 2014 1:42:44 PM org.hornetq.core.server.impl.HornetQServerImpl start
      INFO
      : HQ221000: live server is starting with configuration HornetQ Configuration (clustered=false,backup=false,sharedStore=true,journalDirectory=data/journal,bindingsDirectory=data/bindings,largeMessagesDirectory=data/largemessages,pagingDirectory=data/paging)
      mar
      12, 2014 1:42:44 PM org.hornetq.core.server.impl.HornetQServerImpl initialisePart1
      WARN
      : HQ222007: Security risk! HornetQ is running with the default cluster admin user and default password. Please see the HornetQ user guide, cluster chapter, for instructions on how to change this.
      mar
      12, 2014 1:42:44 PM org.hornetq.core.remoting.server.impl.RemotingServiceImpl <init>
      INFO
      : HQ221043: Adding protocol support CORE
      ServerMQ initialized!
      mar
      12, 2014 1:42:44 PM org.hornetq.core.server.impl.HornetQServerImpl$SharedNothingLiveActivation run
      ERROR
      : HQ224000: Failure in initialisation
      java
      .net.BindException: Address already in use: bind
        at sun
      .nio.ch.Net.bind0(Native Method)
        at sun
      .nio.ch.Net.bind(Net.java:444)
        at sun
      .nio.ch.Net.bind(Net.java:436)
        at sun
      .nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
        at sun
      .nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
        at io
      .netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:102)
        at io
      .netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:479)
        at io
      .netty.channel.DefaultChannelPipeline$HeadHandler.bind(DefaultChannelPipeline.java:1000)
        at io
      .netty.channel.DefaultChannelHandlerContext.invokeBind(DefaultChannelHandlerContext.java:457)
        at io
      .netty.channel.DefaultChannelHandlerContext.bind(DefaultChannelHandlerContext.java:442)
        at io
      .netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:842)
        at io
      .netty.channel.AbstractChannel.bind(AbstractChannel.java:194)
        at io
      .netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:331)
        at io
      .netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354)
        at io
      .netty.channel.nio.NioEventLoop.run(NioEventLoop.java:353)
        at io
      .netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
        at java
      .lang.Thread.run(Thread.java:744)

      mar
      12, 2014 1:42:44 PM org.hornetq.core.server.impl.HornetQServerImpl start
      INFO
      : HQ221001: HornetQ Server version 2.4.1.Final (Fast Hornet, 124) [a681c9b2-a83a-11e3-b8ef-531df38c9cfa
      ]

      Here is my class implementation.

      @Component(value = "serverMQ")

      public class ServerMQ {

       

          private Configuration configuration;

       

          private ClientSessionFactory clientSessionFactory;

       

          private HornetQServer HornetQ;

       

          public ServerMQ() {

       

              System.out.println("Setting ServerMQ configuration...");

       

              // Instantiate server config.

              this.configuration = new ConfigurationImpl();

       

              // Server has persistence for messages.

              this.configuration.setPersistenceEnabled(false);

       

              // Server has user security authentication.

              this.configuration.setSecurityEnabled(false);

       

              Map<String, Object> nettyAcceptorAttrs = new HashMap<String, Object>();

              nettyAcceptorAttrs.put(TransportConstants.HOST_PROP_NAME, "localhost");

              nettyAcceptorAttrs.put(TransportConstants.PORT_PROP_NAME, 5555);

       

              this.configuration.getAcceptorConfigurations().clear();

              this.configuration.getAcceptorConfigurations().add(new TransportConfiguration(NettyAcceptorFactory.class.getName(), nettyAcceptorAttrs));

       

              this.init2();

          }

       

          public void init2() {

       

              try {

       

                  System.out.println("Initializing ServerMQ...");

       

                  this.HornetQ = HornetQServers.newHornetQServer(this.configuration);

                  this.HornetQ.start();

       

                  System.out.println("ServerMQ initialized!");

              } catch (Exception ex) {

       

                  try {

       

                      this.HornetQ.stop();

                  } catch (Exception exs) {

       

                      System.err.println("Stopping ServerMQ error:\n" + exs.getMessage());

                  }

       

                  System.err.println("ServerMQ initializing error:\n" + ex.getMessage());

              }

          }

       

       

          public ClientSessionFactory getClientSessionFactory() {

              return clientSessionFactory;

          }

       

       

      }