mmc18 mmc18 - 11 months ago 68
Java Question

Check if Glassfish DAS is running programmatically

How to check if Glassfish DAS is running programmatically even if it is deployed on local machine or remote machine?

Using Java6

Answer Source

I have found a way to check if DAS is up other than Linux script. With this way it does not matter if both my application and DAS are at same machine or each installed different machine.

public static boolean isUrlReachable(String host) {
  String URLName="http://"+host+":4848";
  boolean isUp = false;
  try {
     HttpURLConnection con = (HttpURLConnection) new URL(URLName).openConnection();
     isUp = (con.getResponseCode() == HttpURLConnection.HTTP_OK);
  catch (Exception e) {
     return isUp;

  return isUp;