2 Replies Latest reply on Feb 14, 2017 6:42 AM by baddeley84

    Close handler throws exception when closing CLI connection on JBoss 7.2

    fsy

      Hi,

       

      we recently upgraded from JBoss 7.1.3 to 7.2. Since we upgraded one of our applications, that uses the java CLI public API, throws NullPointerExceptions every time a connection is terminated through the CLI API.

       

      The following is our code to set up and close the connection to the JBoss CLI:

       

       

          private CommandContext ctx;
          private ModelControllerClient client; 
      
          public JBossCLITool() {
             try {
                  ctx = CommandContextFactory.getInstance().newCommandContext();
              } catch(CliInitializationException e) {
                  throw new IllegalStateException("Failed to initialize CLI context", e);
              }
          }
      
          public void establishConnection() {
              try {
                  ctx.connectController("localhost", 9999);
                  client = ctx.getModelControllerClient();
              } catch (CommandLineException e) {
                  LOG.debug(e.toString());
              }
          } 
      
          public void terminateConnection() {
              try {
                  if (!ctx.isTerminated()){
                      ctx.terminateSession();
                  }
              } catch (Exception e) {
                  LOG.debug(e.toString());
              }
          } 
      

       

      when calling ctx.terminateSession() the following Exception is thrown:

       

      13:46:58,691 ERROR [org.jboss.remoting.handler-errors] (Remoting "cli-client" read-1) Close handler threw an exception: java.lang.NullPointerException
          at org.jboss.as.cli.impl.CommandContextImpl.handleClose(CommandContextImpl.java:1206) [org-jboss-as-jboss-as-cli-7.2.0.Final.jar:7.2.0.Final]
          at org.jboss.as.cli.impl.CLIModelControllerClient$4.handleClose(CLIModelControllerClient.java:156) [org-jboss-as-jboss-as-cli-7.2.0.Final.jar:7.2.0.Final]
          at org.jboss.as.cli.impl.CLIModelControllerClient$4.handleClose(CLIModelControllerClient.java:153) [org-jboss-as-jboss-as-cli-7.2.0.Final.jar:7.2.0.Final]
          at org.jboss.remoting3.spi.SpiUtils.safeHandleClose(SpiUtils.java:54) [org-jboss-remoting3-jboss-remoting-3.2.14.GA.jar:3.2.14.GA]
          at org.jboss.remoting3.spi.AbstractHandleableCloseable$CloseHandlerTask.run(AbstractHandleableCloseable.java:501) [org-jboss-remoting3-jboss-remoting-3.2.14.GA.jar:3.2.14.GA]
          at org.jboss.remoting3.spi.AbstractHandleableCloseable.runCloseTask(AbstractHandleableCloseable.java:406) [org-jboss-remoting3-jboss-remoting-3.2.14.GA.jar:3.2.14.GA]
          at org.jboss.remoting3.spi.AbstractHandleableCloseable.closeComplete(AbstractHandleableCloseable.java:277) [org-jboss-remoting3-jboss-remoting-3.2.14.GA.jar:3.2.14.GA]
          at org.jboss.remoting3.ConnectionImpl.access$000(ConnectionImpl.java:38) [org-jboss-remoting3-jboss-remoting-3.2.14.GA.jar:3.2.14.GA]
          at org.jboss.remoting3.ConnectionImpl$1.handleClose(ConnectionImpl.java:55) [org-jboss-remoting3-jboss-remoting-3.2.14.GA.jar:3.2.14.GA]
          at org.jboss.remoting3.ConnectionImpl$1.handleClose(ConnectionImpl.java:53) [org-jboss-remoting3-jboss-remoting-3.2.14.GA.jar:3.2.14.GA]
          at org.jboss.remoting3.spi.SpiUtils.safeHandleClose(SpiUtils.java:54) [org-jboss-remoting3-jboss-remoting-3.2.14.GA.jar:3.2.14.GA]
          at org.jboss.remoting3.spi.AbstractHandleableCloseable$CloseHandlerTask.run(AbstractHandleableCloseable.java:501) [org-jboss-remoting3-jboss-remoting-3.2.14.GA.jar:3.2.14.GA]
          at org.jboss.remoting3.spi.AbstractHandleableCloseable.runCloseTask(AbstractHandleableCloseable.java:406) [org-jboss-remoting3-jboss-remoting-3.2.14.GA.jar:3.2.14.GA]
          at org.jboss.remoting3.spi.AbstractHandleableCloseable.closeComplete(AbstractHandleableCloseable.java:277) [org-jboss-remoting3-jboss-remoting-3.2.14.GA.jar:3.2.14.GA]
          at org.jboss.remoting3.remote.RemoteConnectionHandler.handleConnectionClose(RemoteConnectionHandler.java:117) [org-jboss-remoting3-jboss-remoting-3.2.14.GA.jar:3.2.14.GA]
          at org.jboss.remoting3.remote.RemoteReadListener.handleEvent(RemoteReadListener.java:78) [org-jboss-remoting3-jboss-remoting-3.2.14.GA.jar:3.2.14.GA]
          at org.jboss.remoting3.remote.RemoteReadListener.handleEvent(RemoteReadListener.java:45) [org-jboss-remoting3-jboss-remoting-3.2.14.GA.jar:3.2.14.GA]
          at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:72) [org-jboss-xnio-xnio-api-3.0.7.GA.jar:3.0.7.GA]
          at org.xnio.channels.TranslatingSuspendableChannel.handleReadable(TranslatingSuspendableChannel.java:189) [org-jboss-xnio-xnio-api-3.0.7.GA.jar:3.0.7.GA]
          at org.xnio.channels.TranslatingSuspendableChannel$1.handleEvent(TranslatingSuspendableChannel.java:103) [org-jboss-xnio-xnio-api-3.0.7.GA.jar:3.0.7.GA]
          at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:72) [org-jboss-xnio-xnio-api-3.0.7.GA.jar:3.0.7.GA]
          at org.xnio.channels.TranslatingSuspendableChannel.handleReadable(TranslatingSuspendableChannel.java:189) [org-jboss-xnio-xnio-api-3.0.7.GA.jar:3.0.7.GA]
          at org.xnio.ssl.JsseConnectedSslStreamChannel.handleReadable(JsseConnectedSslStreamChannel.java:180) [org-jboss-xnio-xnio-api-3.0.7.GA.jar:3.0.7.GA]
          at org.xnio.channels.TranslatingSuspendableChannel$1.handleEvent(TranslatingSuspendableChannel.java:103) [org-jboss-xnio-xnio-api-3.0.7.GA.jar:3.0.7.GA]
          at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:72) [org-jboss-xnio-xnio-api-3.0.7.GA.jar:3.0.7.GA]
          at org.xnio.nio.NioHandle.run(NioHandle.java:90) [org-jboss-xnio-xnio-nio-3.0.7.GA.jar:3.0.7.GA]
          at org.xnio.nio.WorkerThread.run(WorkerThread.java:187) [org-jboss-xnio-xnio-nio-3.0.7.GA.jar:3.0.7.GA]
      

       

      I couldn't find any mention of changes in the 7.2 CLI API but nothing else changed so I'm wondering if I have to change the way I use the API.

       

      Thanks for your help.

       

      Fabian

        • 1. Re: Close handler throws exception when closing CLI connection on JBoss 7.2
          shinobies

          I had the same problem. Then I tried using the libraries maintained by Red Hat. The thing is, their jboss-as-cli doesn't have dependencies declared, so I had to add one by one in my pom.xml. Here is:

           

          <dependencies>
             <dependency>
                <groupId>org.jboss.as</groupId>
                <artifactId>jboss-as-cli</artifactId>
                <version>7.3.0.Final-redhat-14</version>
             </dependency>
             <dependency>
                <groupId>org.jboss.logging</groupId>
                <artifactId>jboss-logging</artifactId>
                <version>3.1.2.GA-redhat-1</version>
             </dependency>
             <dependency>
                <groupId>org.jboss</groupId>
                <artifactId>staxmapper</artifactId>
                <version>1.1.0.Final-redhat-2</version>
             </dependency>
             <dependency>
                <groupId>org.jboss.as</groupId>
                <artifactId>jboss-as-controller-client</artifactId>
                <version>7.3.0.Final-redhat-14</version>
             </dependency>
             <dependency>
                <groupId>org.jboss.as</groupId>
                <artifactId>jboss-as-protocol</artifactId>
                <version>7.3.0.Final-redhat-14</version>
             </dependency>
             <dependency>
                <groupId>org.jboss.threads</groupId>
                <artifactId>jboss-threads</artifactId>
                <version>2.1.1.Final-redhat-1</version>
             </dependency>
             <dependency>
                <groupId>org.jboss.remoting3</groupId>
                <artifactId>jboss-remoting</artifactId>
                <version>3.2.18.GA-redhat-1</version>
             </dependency>
             <dependency>
                <groupId>org.jboss.xnio</groupId>
                <artifactId>xnio-api</artifactId>
                <version>3.0.7.GA-redhat-1</version>
             </dependency>
             <dependency>
                <groupId>org.jboss.xnio</groupId>
                <artifactId>xnio-nio</artifactId>
                <version>3.0.7.GA-redhat-1</version>
             </dependency>
             <dependency>
                <groupId>org.jboss</groupId>
                <artifactId>jboss-dmr</artifactId>
                <version>1.2.0.Final-redhat-1</version>
             </dependency>
          </dependencies>
          
          
          

           

          Note: I only tested the connection and some simple stuff. Maybe there are more libraries to add if your case is complex.

           

          This answer comes really late, but I thought I'd leave it here for reference.

           

          [EDIT]

          URL for RedHat Maven Repository: https://maven.repository.redhat.com/techpreview/all

          • 2. Re: Close handler throws exception when closing CLI connection on JBoss 7.2
            baddeley84

            Thanks for posting this saved me a lot of digging around (3 years later)!

             

            To anyone else who needs it, there is a slightly simpler fix, just copy the module.xml for the jboss-as-cli-7.2.0.Final and create a new slot (7.3.0) and replace the jar with the redhat one, it should then just use the same dependencies as the main slot jar (which seems to work ok for me)