lundi 13 juillet 2015

How to shutdown Wildfly 8.2.0 AS programatically

I am running the Wildfly AS 8.2.0 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.

Aucun commentaire:

Enregistrer un commentaire