4 Replies Latest reply on Jul 20, 2015 6:50 AM by sridharthiyagarajan

    How to shutdown Wildfly 8.2.0 AS programatically

    sridharthiyagarajan

      Hello,

       

      I am running the Wildfly AS 8.2.0 AS server in standalone (standalone-full-ha.xml) mode.

       

      I am using the below method to shutdown the wildfly AS 8.2.0 if any exception occurs during the application deployment.

       

      public static void stop() throws MalformedObjectNameException,

              InstanceNotFoundException, MBeanException, ReflectionException {

       

          MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();

          ObjectName objectName = new ObjectName("jboss.as:management-root=server");

          try {

              mBeanServer.invoke(objectName, "shutdown", new Object[] { false },

                      new String[] { boolean.class.getName() });

              _log.debug("In stop() of MBeanStopper - server stopped successfully");

          } catch (InstanceNotFoundException | ReflectionException

                  | MBeanException e) {

              _log.error("In stop() of MBeanStopper and the error msg is : " + e);

          }

      }

       

      Response is hanging after the calling invoke and the server is not shutting down. I am not getting any exception as well.

       

      Could anyone please help me to resolve the issue.