Author Archive

Client side Native Management API for monitoring JBossAS7.1.2

Hi,

JBossAS7 is one of the best application server which provides various options to control/manage/monitor the application resources using various options like jboss-cli.sh (CLI scripts) , jboss management console, JSON based monitoring & management using curl/wget, JBoss Native Management APIs …etc

Here in this article we will see how we can manage & monitor JBossAS 7.1.2 using JBoss Native Management APIs, this approach is best for the java developers, as in many production environments it is very convenient to manage the application respources based on java code. The developers wants to mmanage things using java style of programming, So for those develpers JBoss Native Management APIs is much convenient way of managing the JBoss.

More informations on this can be found in the following link: https://docs.jboss.org/author/display/AS7/The+native+management+API

The Source code for the following Demo is available in the github repository:
https://github.com/jaysensharma/MiddlewareMagicDemos/tree/master/NativeManagement_API_JBossAS712

Step1). First of all we will create a directory somewhere in our file system as “/home/jaysensharma/NativeManagement_API_JBossAS712″ and then we will create a directory with name “src” inside “/home/jaysensharma/NativeManagement_API_JBossAS712″:

Step2). Now we will use the “org.jboss.as.controller.client.ModelControllerClient” API to establish connection to the JBoss Server/Controller, So create a program as “NativeManagementClient.java” inside “/home/jaysensharma/NativeManagement_API_JBossAS712/src” as following:

import java.net.UnknownHostException;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.NameCallback;
import javax.security.auth.callback.PasswordCallback;
import javax.security.sasl.RealmCallback;
import javax.security.auth.callback.UnsupportedCallbackException;

import org.jboss.as.controller.client.ModelControllerClient;
import org.jboss.as.controller.client.ModelControllerClient.Factory;
import java.net.InetAddress;
import java.io.IOException;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.Property;

public class NativeManagementClient
{
    //static String host = "10.10.10.96"; // "localhost";
    static String host = "localhost";
    static int port = 9999;
    static String password = "admin";
    static String userid = "admin123";
    static String hostControllerName="master";
    static String serverName="JayServer";
    static boolean standaloneMode=true;     //  If you are running your Servers in Domain Mode then set this to false.
    static ModelControllerClient client = null;    

    public static void main (String[] args)
       {
           try {
                 createAndCheckClientConnection();
                 performOperations(client);
               }

           catch (java.io.IOException ex)
               {
                 System.out.println("\n\n Unable to Connect to the Host: "+host+" or Port:"+port+"\t\t" + ex.getMessage());
                 //ex.printStackTrace();
               }
           catch (Exception ex)
               {
                 System.out.println("\n\nSomeThing is Wrong: "+ex.getMessage());
                 //ex.printStackTrace();
               }

           try {
                 if (client != null ) client.close();
               }
           catch (Exception e)
               {
                 System.out.println ("Exception: " + e.getMessage());
                 e.printStackTrace();
               }
        }

    public static void createAndCheckClientConnection() throws IOException
     {
                 // NOTE: For hostname as "localhost" there is no need to pass the username & password  */
                 //client = ModelControllerClient.Factory.create(host, port, null); 

                 // If you are running this program remotely then you need to pass the credentials */
                 client = createClient (InetAddress.getByName(host), port, userid, password.toCharArray(), "ManagementRealm" );
                 System.out.println("Got the client: "+client);

                 // Checking whether Client is actually connected to Controller or not by executing dummy ModelNode? */
                 ModelNode op = new ModelNode();
                 op.get("operation").set("read-resource");
                 ModelNode returnVal=client.execute(op);
                 System.out.println("\n\nrelease-version: " + returnVal.get("result").get("release-version").asString());
                 System.out.println("release-codename: " + returnVal.get("result").get("release-codename").asString());
     }

   public static void performOperations(ModelControllerClient client)
      {
                  if(standaloneMode==true)
                     {
                        // FOR STANDALONE MODE use the "TestStandaloneModel" class as following:
                        TestStandaloneModel testStandaloneModel=new TestStandaloneModel();              

                        // Getting Web Subsystem runtime Details */
                        testStandaloneModel.getWebSubsystemRuntimeDetails(client);
                        // Testing Non XA DataSource ExampleDS */
                        testStandaloneModel.testNonXADataSource(client,"ExampleDS");
                        // Monitoring Application Statistics where application name is "Log4jDemo.war" */
                        testStandaloneModel.monitorApplicationStatistics(client,"Log4jDemo.war");
                     }
                  if(standaloneMode==false)
                    {
                        TestDomainModeModel testDomainModeModel= new TestDomainModeModel();
                        // Getting Web Subsystem runtime Details */
                        testDomainModeModel.getWebSubsystemRuntimeDetails(client,hostControllerName,serverName);
                        // Testing Non XA DataSource ExampleDS */
                        testDomainModeModel.testNonXADataSource(client,hostControllerName,serverName,"ExampleDS");
                        // Monitoring Application Statistics where application name is "Log4jDemo.war" */
                        testDomainModeModel.monitorApplicationStatistics(client,hostControllerName,serverName,"Log4jDemo.war");
                    }
      }

     static ModelControllerClient createClient (final InetAddress host, final int port, final String username, final char[] password, final String securityRealmName)
      {
         final CallbackHandler callbackHandler = new CallbackHandler() {
                 public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
                   {
                       for (Callback current : callbacks) {
                          if (current instanceof NameCallback) {
                             NameCallback ncb = (NameCallback) current;
                             System.out.println("\n\t\tncb.setName() = "+new String(password));
                             ncb.setName(new String(password));
                            } else if (current instanceof PasswordCallback) {
                             PasswordCallback pcb = (PasswordCallback) current;
                             System.out.println("\n\t\tpcb.setPassword() = "+username);
                             pcb.setPassword(username.toCharArray());
                            } else if (current instanceof RealmCallback) {
                             RealmCallback rcb = (RealmCallback) current;
                             System.out.println("\n\t\trcb.getDefaulttest() = "+rcb.getDefaultText());
                             rcb.setText(securityRealmName);
                            } else {
                             throw new UnsupportedCallbackException(current);
                        }
                    }
               }
             };
          return ModelControllerClient.Factory.create(host, port, callbackHandler);
       }
}

Step3). This step is for accessing JBoss informations in Standalone Mode, The most important part here we will write “TestStandaloneModel.java” program inside the “/home/jaysensharma/NativeManagement_API_JBossAS712/src” using the “org.jboss.dmr.ModelNode” and “ModelControllerClient” in order to access the “web” subsystem, deployment and “DataSource statistics” related informations as following:

import org.jboss.dmr.ModelNode;
import org.jboss.dmr.Property;
import org.jboss.as.controller.client.ModelControllerClient;

public class TestStandaloneModel
  {
   public void getWebSubsystemRuntimeDetails(ModelControllerClient client)
    {
       System.out.println("\n\n\n************************************************");
       System.out.println("Web Subsystem Runtime Details");
       System.out.println("************************************************");
       try{
             ModelNode op = new ModelNode();
             op.get("operation").set("read-resource");
             ModelNode address = op.get("address");
             address.add("subsystem", "web");
             address.add("connector", "http");
             op.get("recursive").set(true);
             op.get("include-runtime").set(true);
             op.get("operations").set(true);

             ModelNode returnVal = client.execute(op);
             String result=returnVal.get("result").toString();
             String path="/subsystem=web/connector=http";
             if(result.equals("undefined"))
                {
                   System.out.println("\n\tCheck ["+path+"] ** Server may not be Running");
                }
             else
                {
                   System.out.println(returnVal.get("result").toString());
                }
          }
        catch(Exception e)
          {
             e.printStackTrace();
             System.out.println("getWebSubsystemRuntimeDetails Failed: "+e);
          }
    }

   public void testNonXADataSource(ModelControllerClient client,String dataSourceName)
    {
       System.out.println("\n\n\n************************************************");
       System.out.println("DataSource \""+dataSourceName+"\" TestResults");
       System.out.println("************************************************");

       try{
             ModelNode op = new ModelNode();
             op.get("operation").set("test-connection-in-pool");
             ModelNode address = op.get("address");
             address.add("subsystem", "datasources");
             address.add("data-source", dataSourceName);
             op.get("operations").set(true);

             ModelNode returnVal = client.execute(op);
             String result=returnVal.get("result").toString();
             String path="/subsystem=datasources/data-source="+dataSourceName;
             if(result.equals("[true]"))
                {
                   System.out.println("\n\tNon XA DataSource \""+dataSourceName+"\" is RUNNING Successfully.");
                }
             else if(result.equals("[false]"))
                {
                   System.out.println("\n\tNon XA DataSource \""+dataSourceName+"\" is TEST FAILED Successfully. Check PATH exist or not? ["+path+"]");
                }
             else if(result.equals("undefined"))
                {
                   System.out.println("\n\tDataSource \""+dataSourceName+"\" might not be deployed, ["+path+"]  ** Server may not be Running"+"Please Check the DataSource \""+dataSourceName+"\" name, It may be INCORRECT. \n\tCheck PATH exist or not? ["+path+"]");
                }
          }
        catch(Exception e)
          {
             e.printStackTrace();
             System.out.println("testNonXADataSource Failed: "+e);
          }
    }

   public void monitorApplicationStatistics(ModelControllerClient client,String applicationName)
    {
       System.out.println("\n\n\n******************************************************");
       System.out.println("Application \""+applicationName+"\" RuntimeStatistics");
       System.out.println("******************************************************");
       try{
             ModelNode op = new ModelNode();
             op.get("operation").set("read-resource");
             ModelNode address = op.get("address");
             address.add("deployment", applicationName);
             op.get("recursive").set(true);
             op.get("include-runtime").set(true);
             op.get("include-defaults").set(true);
             op.get("operations").set(true);

             ModelNode returnVal = client.execute(op);
             String result=returnVal.get("result").toString();
             String path="/deployment="+applicationName;
             if(result.equals("undefined"))
                {
                   System.out.println("\n\tApplication \""+applicationName+ "\" might not have deployed. ** Server may not be Running. Check PATH exist or not? ["+path+"]");
                }
             else
                {
                   System.out.println("\n\tMonitoring \""+applicationName+ "\""+result);
                }
          }
        catch(Exception e)
          {
             e.printStackTrace();
             System.out.println("testNonXADataSource Failed: "+e);
          }
    }
  }

Step4). This step is for accessing JBoss informations of JBoss instances running in Domain Mode, The most important part here we will write “TestDomainModeModel.java” program inside the “/home/jaysensharma/NativeManagement_API_JBossAS712/src” using the “org.jboss.dmr.ModelNode” and “ModelControllerClient” in order to access the “web” subsystem, deployment and “DataSource statistics” related informations as following:

import org.jboss.dmr.ModelNode;
import org.jboss.dmr.Property;
import org.jboss.as.controller.client.ModelControllerClient;

public class TestDomainModeModel
  {
   public void getWebSubsystemRuntimeDetails(ModelControllerClient client,String hostControllerName,String serverName)
    {
       System.out.println("\n\n\n************************************************");
       System.out.println("Web Subsystem Runtime Details");
       System.out.println("************************************************");
       try{
             ModelNode op = new ModelNode();
             op.get("operation").set("read-resource");
             ModelNode address = op.get("address");
             address.add("host", hostControllerName);
             address.add("server", serverName);
             address.add("subsystem", "web");
             address.add("connector", "http");
             op.get("recursive").set(true);
             op.get("include-runtime").set(true);
             op.get("operations").set(true);

             ModelNode returnVal = client.execute(op);
             String result=returnVal.get("result").toString();
             String path="/host="+hostControllerName+"/server="+serverName+"/subsystem=web/connector=http";
             if(result.equals("undefined"))
                {
                   System.out.println("\n\tCheck ["+path+"] ** HostController HostController or Server may not be Running");
                }
             else
                {
                   System.out.println(returnVal.get("result").toString());
                }
          }
        catch(Exception e)
          {
             e.printStackTrace();
             System.out.println("getWebSubsystemRuntimeDetails Failed: "+e);
          }
    }

   public void testNonXADataSource(ModelControllerClient client,String hostControllerName,String serverName,String dataSourceName)
    {
       System.out.println("\n\n\n************************************************");
       System.out.println("DataSource \""+dataSourceName+"\" TestResults");
       System.out.println("************************************************");

       try{
             ModelNode op = new ModelNode();
             op.get("operation").set("test-connection-in-pool");
             ModelNode address = op.get("address");
             address.add("host", hostControllerName);
             address.add("server", serverName);
             address.add("subsystem", "datasources");
             address.add("data-source", dataSourceName);
             op.get("operations").set(true);

             ModelNode returnVal = client.execute(op);
             String result=returnVal.get("result").toString();
             String path="/host="+hostControllerName+"/server="+serverName+"/subsystem=datasources/data-source="+dataSourceName;
             if(result.equals("[true]"))
                {
                   System.out.println("\n\tNon XA DataSource \""+dataSourceName+"\" is RUNNING Successfully.");
                }
             else if(result.equals("[false]"))
                {
                   System.out.println("\n\tNon XA DataSource \""+dataSourceName+"\" is TEST FAILED Successfully. Check PATH exist or not? ["+path+"]");
                }
             else if(result.equals("undefined"))
                {
                   System.out.println("\n\tDataSource \""+dataSourceName+"\" might not be deployed on this ["+path+"]  ** HostController or Server may not be Running"+"Please Check the DataSource \""+dataSourceName+"\" name, It may be INCORRECT. \n\tCheck PATH exist or not? ["+path+"]");
                }
          }
        catch(Exception e)
          {
             e.printStackTrace();
             System.out.println("testNonXADataSource Failed: "+e);
          }
    }

   public void monitorApplicationStatistics(ModelControllerClient client,String hostControllerName,String serverName,String applicationName)
    {
       System.out.println("\n\n\n******************************************************");
       System.out.println("Application \""+applicationName+"\" RuntimeStatistics");
       System.out.println("******************************************************");
       try{
             ModelNode op = new ModelNode();
             op.get("operation").set("read-resource");
             ModelNode address = op.get("address");
             address.add("host", hostControllerName);
             address.add("server", serverName);
             address.add("deployment", applicationName);
             op.get("recursive").set(true);
             op.get("include-runtime").set(true);
             op.get("include-defaults").set(true);
             op.get("operations").set(true);

             ModelNode returnVal = client.execute(op);
             String result=returnVal.get("result").toString();
             String path="/host="+hostControllerName+"/server="+serverName+"/deployment="+applicationName;
             if(result.equals("undefined"))
                {
                   System.out.println("\n\tApplication \""+applicationName+ "\" might not have deployed on this host="+hostControllerName+"/server="+serverName+"  ** HostController or Server may not be Running. Check PATH exist or not? ["+path+"]");
                }
             else
                {
                   System.out.println("\n\tMonitoring \""+applicationName+ "\""+result);
                }
          }
        catch(Exception e)
          {
             e.printStackTrace();
             System.out.println("testNonXADataSource Failed: "+e);
          }
    }
  }

Step5). Now the most important part of building & running the Native Management API client which we created, so in order to achieve that we will create a simple ant build script, So Create a “build.xml” file inside the “/home/jaysensharma/NativeManagement_API_JBossAS712″ directory as following:

<project name="JBossAS712NativeManagementClient" default="all">
<property name="jboss.home" value="/home/jaysensharma/jboss-as-7.1.2.Final" />
<property name="jboss.module.dir" value="${jboss.home}/modules" />
<property name="basedir" value="." />
<property name="tmp.dir" value="tmp" />
<property name="src.dir" value="src" />
<property name="output.dir" value="build" />
<property name="client.jar.name" value="jbossModelAPIClient.jar" />

        <!-- Following 5 Jars are needed for Client. Client Needs the following Jar to be present in the CLASSPATH including -->
        <path id="jboss.client.classpath">
           <fileset dir="${jboss.module.dir}/org/jboss/as/controller-client/main">
               <include name="jboss-as-controller-client*.jar"/>
           </fileset>
           <fileset dir="${jboss.module.dir}/org/jboss/threads/main">
               <include name="jboss-threads*.jar"/>
           </fileset>
           <fileset dir="${jboss.module.dir}/org/jboss/as/protocol/main">
               <include name="jboss-as-protocol*.jar"/>
           </fileset>

           <fileset dir="${jboss.module.dir}/org/jboss/dmr/main">
               <include name="jboss-dmr*.jar"/>
           </fileset>
           <fileset dir="${jboss.home}/bin/client" >
               <include name="jboss-client.jar" />
           </fileset>
        </path>

        <target name="all" depends="run" />

        <target name="run">
           <delete dir="${tmp.dir}" />
           <mkdir dir="${tmp.dir}" />
           <delete dir="${output.dir}" />
           <mkdir dir="${output.dir}" />
           <javac srcdir="${src.dir}" destdir="${tmp.dir}"  includes="NativeManagementClient.java,TestStandaloneModel.java,TestDomainModeModel.java" classpathref="jboss.client.classpath"/>
           <jar jarfile="${output.dir}/${client.jar.name}" basedir="${tmp.dir}" compress="true" />
           <delete dir="${tmp.dir}"/>
           <java classname="NativeManagementClient" fork="true">
               <classpath>
                  <pathelement location="${output.dir}/${client.jar.name}"/>
                  <path refid="jboss.client.classpath"/>
               </classpath>
           </java>
        </target>        

</project>

NOTE: The only change in the above file you need to do is to change the “jboss.home” directory path in the second line of the above script to point to your own JBoss AS7 directory. It requires 5 Jars to be present in the Client’s classpath as mentioned in the above xml file.

Step-6). Now before running your ANT script to build and deploy the above webapplication you should have the ANT as well as JAVA set in the $PATH variable of the Shell / command prompt as following:

For Unix Based OS:
export PATH=/home/jaysensharma/jdk1.6.0_21/bin:/home/jaysensharma/org.apache.ant_1.6.5/bin:$PATH

For Windows Based OS:
set PATH=C:/jdk1.6.0_21/bin;C:/org.apache.ant_1.6.5/bin;%PATH%

Step-7). Now once the PATH is set In the command/Shell prompt you can move inside the directory “/home/jaysensharma/NativeManagement_API_JBossAS712″ and then run the ant to build and deploy the EJB based EAR applicationon your JBoss Standalone full profile, by running the command “ant deploy”

[jsenshar@localhost NativeManagement_API_JBossAS712]$ ant
Buildfile: build.xml

run:
    [mkdir] Created dir: /home/jaysensharma/NativeManagement_API_JBossAS712/tmp
   [delete] Deleting directory /home/jaysensharma/NativeManagement_API_JBossAS712/build
    [mkdir] Created dir: /home/jaysensharma/NativeManagement_API_JBossAS712/build
    [javac] Compiling 3 source files to /home/jaysensharma/NativeManagement_API_JBossAS712/tmp
      [jar] Building jar: /home/jaysensharma/NativeManagement_API_JBossAS712/build/jbossModelAPIClient.jar
   [delete] Deleting directory /home/jaysensharma/NativeManagement_API_JBossAS712/tmp
     [java] Got the client: org.jboss.as.controller.client.impl.RemotingModelControllerClient@7f971afc
     [java] Nov 27, 2012 12:06:02 AM org.xnio.Xnio <clinit>
     [java] INFO: XNIO Version 3.0.4.GA-redhat-1
     [java] Nov 27, 2012 12:06:02 AM org.xnio.nio.NioXnio <clinit>
     [java] INFO: XNIO NIO Implementation Version 3.0.4.GA-redhat-1
     [java] Nov 27, 2012 12:06:02 AM org.jboss.remoting3.EndpointImpl <clinit>
     [java] INFO: JBoss Remoting version 3.2.8.GA-redhat-1
     [java]
     [java]
     [java] release-version: 7.1.2.Final-redhat-1
     [java] release-codename: Steropes
     [java]
     [java]
     [java]
     [java] ************************************************
     [java] Web Subsystem Runtime Details
     [java] ************************************************
     [java] {
     [java]     "bytesReceived" => "0",
     [java]     "bytesSent" => "0",
     [java]     "enable-lookups" => false,
     [java]     "enabled" => true,
     [java]     "errorCount" => "0",
     [java]     "executor" => undefined,
     [java]     "max-connections" => undefined,
     [java]     "max-post-size" => 2097152,
     [java]     "max-save-post-size" => 4096,
     [java]     "maxTime" => "0",
     [java]     "name" => "http",
     [java]     "processingTime" => "0",
     [java]     "protocol" => "HTTP/1.1",
     [java]     "proxy-name" => undefined,
     [java]     "proxy-port" => undefined,
     [java]     "redirect-port" => 8433,
     [java]     "requestCount" => "0",
     [java]     "scheme" => "http",
     [java]     "secure" => false,
     [java]     "socket-binding" => "http",
     [java]     "ssl" => undefined,
     [java]     "virtual-server" => undefined
     [java] }
     [java]
     [java]
     [java]
     [java] ************************************************
     [java] DataSource "ExampleDS" TestResults
     [java] ************************************************
     [java]
     [java] 	Non XA DataSource "ExampleDS" is RUNNING Successfully.
     [java]
     [java]
     [java]
     [java] ******************************************************
     [java] Application "Log4jDemo.war" RuntimeStatistics
     [java] ******************************************************
     [java]
     [java] 	Monitoring "Log4jDemo.war"{
     [java]     "content" => [{
     [java]         "path" => "deployments/Log4jDemo.war",
     [java]         "relative-to" => "jboss.server.base.dir",
     [java]         "archive" => true
     [java]     }],
     [java]     "enabled" => true,
     [java]     "name" => "Log4jDemo.war",
     [java]     "persistent" => false,
     [java]     "runtime-name" => "Log4jDemo.war",
     [java]     "status" => "OK",
     [java]     "subdeployment" => undefined,
     [java]     "subsystem" => {"web" => {
     [java]         "active-sessions" => 0,
     [java]         "context-root" => "/Log4jDemo",
     [java]         "duplicated-session-ids" => 0,
     [java]         "expired-sessions" => 0,
     [java]         "max-active-sessions" => 0,
     [java]         "rejected-sessions" => 0,
     [java]         "session-avg-alive-time" => 0,
     [java]         "session-max-alive-time" => 0,
     [java]         "sessions-created" => 0,
     [java]         "virtual-host" => "default-host",
     [java]         "servlet" => {"servlets.TestServlet" => {
     [java]             "load-time" => 0L,
     [java]             "maxTime" => 9223372036854775807L,
     [java]             "min-time" => 0L,
     [java]             "processingTime" => 0L,
     [java]             "requestCount" => 0,
     [java]             "servlet-class" => "servlets.TestServlet",
     [java]             "servlet-name" => "servlets.TestServlet"
     [java]         }}
     [java]     }}
     [java] }

all:

BUILD SUCCESSFUL
Total time: 2 seconds

Step-8). If you are running your JBoss in Domain mode then you need to just edit the “NativeManagementClient.java” file, and just change the variable “standaloneMode” value to “false” as following:

static boolean standaloneMode=false;

.
.
Thanks
MiddlewareMagic Team :)


SAR dependency alternate approach using @Singleton in JBossAS7.1.2

Hi,

SAR files are called as Service Archives. The extension of SAR files are *.sar which contains a “META-INF/jboss-service.xml” file, this file describes the custom MBeans which has to be exposed at the time of deployment or JBoss Startup. JBoss’s service archive architecture is based on the JMX and the SAR files which are basically JBoss specific can be deployed in the jboss inorder to publish your MBean based services. At the time of JBoss startup these service archive deployer (SARDeployer) instantiates the JBoss service classes and exposes them as manageable beans through JMX.

In previous release of JBoss 5/6 the SAR provided mbeans dependency could be very easily defined using <depends> tag, as following:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE server>
<server>
    <mbean code="custom.mbean.MyServerMonitor" name="service.server.monitor:service=MyMonitor">
         <attribute name="Frequency">5000</attribute>
         <depends>jboss.jca:service=DataSourceBinding,name=MySqlDS</depends>
    </mbean>
</server>

@org.jboss.ejb3.annotation.Service and @org.jboss.ejb3.annotation.Management are no longer supported which could be used to define Services. However in JBossAS7 this approach of defining the dependency is not good and you may see following kind of exceptions at the time of server startup:

JBAS014775:    New missing/unsatisfied dependencies:
      service jboss.mbean.service."jboss.as:subsystem=datasources,data-source=MySqlDS".create (missing) dependents: [service jboss.mbean.service."service.server.monitor:service=MyMonitor".create]
      service jboss.mbean.service."jboss.as:subsystem=datasources,data-source=MySqlDS".start (missing) dependents: [service jboss.mbean.service."service.server.monitor:service=MyMonitor".start]

JBossAS7 is fully EE6 certified application server and it provides a much better approach to create a Service with the help of EJB3.1 specific “javax.ejb.Startup” and “javax.ejb.Singleton” annotations. This kind of service can be made dependent to other services like DataSource. In this example we will see What is the better approach to define a service (without using container specific SAR feature).

The Source code for this demo can be found in the following github link:
https://github.com/jaysensharma/MiddlewareMagicDemos/tree/master/SingletonServiceDemo

Creating DataSource in JBossAS7.1.2

As we are going make our Service dependent on a DataSource, sothat we can see how the dependency goes.

Configuration-1). So here first of all we will create a DataSource by running the following CLI script in batch mode. So create a file with name “createDataSource.cli” somewhere in your filesystem like “/home/jaysensharma/SingletonServiceDemo/createDataSource.cli” as following:

deploy  /home/jaysensharma/SingletonServiceDemo/mysql-connector-java-5.1.13-bin.jar

/subsystem=datasources/data-source="MySqlDS":add(jndi-name="java:jboss/datasources/MySqlDS",driver-name="mysql-connector-java-5.1.13-bin.jar",connection-url="jdbc:mysql://localhost:3306/testDB",user-name="root",password="redhat")

Configuration-2). Now start your “$JBOSS_HOME/bin/jboss-cli.sh” script in order to run the above deploy the mysql driver and create DataSource as following:

./jboss-cli.sh -c --controller=10.10.10.10:9999 --file=/home/jaysensharma/SingletonServiceDemo/createDataSource.cli

Configuration-3). As soon as you will run the cli script as mentioned above you will see that the following kind of datasource is created on your standalone*.xml.

                <datasource jndi-name="java:jboss/datasources/MySqlDS" pool-name="MySqlDS">
                    <connection-url>jdbc:mysql://localhost:3306/testDB</connection-url>
                    <driver>mysql-connector-java-5.1.13-bin.jar</driver>
                    <security>
                        <user-name>root</user-name>
                        <password>redhat</password>
                    </security>
                </datasource>

Creating @Singleton service dependent on the DataSource

Step1). First of all we will create a directory somewhere in our file system as “/home/jaysensharma/SingletonServiceDemo” and then we will create a directory with name “src” inside “/home/jaysensharma/SingletonServiceDemo”:

Step2). Now write a @Startup @Singleton EJB3.1 service using “SingletonServiceBean.java” inside “/home/jaysensharma/SingletonServiceDemo/src” as following:

package sar.dependency.alternative;
import javax.ejb.Startup;
import javax.ejb.Singleton;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

//commons logging
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

// DataSource related
import javax.sql.DataSource;
import java.sql.Connection;

// Resource Injection related
import javax.annotation.Resource;

@Startup
@Singleton  

public class SingletonServiceBean
 {
     private static Log logger = LogFactory.getLog(SingletonServiceBean.class);
     Connection con=null;

     public SingletonServiceBean()
            {
               logger.info("SingletonServiceBean constructor invoked.");
            }

     @Resource(name = "java:jboss/datasources/MySqlDS")
     DataSource ds;
     /* This @PostConstruct annotation is required to tell JBoss to invoke the "performOperations" immediately after the "SingletonServiceBean" creation. */
     @PostConstruct
     public void performOperations()
	    {
               logger.info("SingletonServiceBean performOperations() invoked.");
               try{
                     con=ds.getConnection();
                     logger.info("***** DataSource = "+ds+" . Connection con = "+con+" retrieved from the ConnectionPool.*****");
                  }
               catch(Exception e)
                 {
                     logger.error("Unable to get Connection From DataSource = "+ds+" ERROR: "+e.getMessage());
                     e.printStackTrace();
                 }
	    }

	@PreDestroy
	public void cleanUp() throws Exception {
	  logger.info("cleaning up connections.");
          if(con!=null)
            {
               try{
                     con.close();
                     logger.info("Connection con = "+con+" is successfully returned to the ConnectionPool.");
                  }
               catch(Exception e)
                 {
                     logger.error("Unable to Close Connection con = "+con+" ERROR: "+e.getMessage());
                     e.printStackTrace();
                 }
               finally{
                        try{   con.close(); }
                        catch(Exception ee) { ee.printStackTrace(); }
                      }
            }
	}
 }

Step3). Now the most important part of building / deploying the Singleton Service which we created, so in order to achieve that we will create a simple ant build script, So Create a “build.xml” file inside the “/home/jaysensharma/SingletonServiceDemo” directory as following:

<project name="SingletonStartupService" default="all">
<property name="jboss.home" value="/home/jaysensharma/jboss-as-7.1.2.Final" />
<property name="jboss.module.dir" value="${jboss.home}/modules" />
<property name="basedir" value="." />
<property name="tmp.dir" value="tmp" />
<property name="src.dir" value="src" />
<property name="output.dir" value="build" />
<property name="ear.name" value="TestSingletonService.ear" />
<property name="ejb.jar" value="singletonServiceEJB.jar" />

        <path id="jboss.classpath">
           <fileset dir="${jboss.module.dir}">
               <include name="**/*.jar"/>
           </fileset>
        </path>

        <target name="all" depends="deploy" />

        <target name="build_ear">
           <delete dir="${tmp.dir}" />
           <mkdir dir="${tmp.dir}" />
           <javac srcdir="${src.dir}" destdir="${tmp.dir}"  includes="*.java" classpathref="jboss.classpath"/>

           <jar jarfile="${tmp.dir}/${ejb.jar}" basedir="${tmp.dir}" compress="true" />

           <delete includeEmptyDirs="true">
              <fileset dir="${tmp.dir}/sar"/>
           </delete>
           <mkdir dir="${tmp.dir}/META-INF"/>
           <copy todir="${tmp.dir}/META-INF">
                <fileset dir="${src.dir}/">
                  <include name="application.xml"/>
                </fileset>
           </copy>
           <jar jarfile="${tmp.dir}/${ear.name}" basedir="${tmp.dir}" compress="true" />
           <delete includeEmptyDirs="true">
              <fileset dir="${tmp.dir}/META-INF"/>
           </delete>
           <delete file="${tmp.dir}/${ejb.jar}"/>

           <copy file="${tmp.dir}/${ear.name}" tofile="${output.dir}/${ear.name}"/>
           <delete dir="${tmp.dir}"/>
        </target>

        <target name="deploy" depends="build_ear">
            <echo message="*******************  Deploying the EAR file ${ear.name} *********************" />
            <echo message="********** ${output.dir}/${ear.name} to ${jboss.home}/standalone/deployments **********" />
            <copy todir="${jboss.home}/standalone/deployments/">
                <fileset dir="${output.dir}/">
                  <include name="${ear.name}"/>
                </fileset>
            </copy>
            <echo message="*******************  Deployed Successfully   *********************" />
        </target>

</project>

NOTE: The only change in the above file you need to do is to change the “jboss.home” directory path in the second line of the above script to point to your own JBoss AS7 directory.

Step-4). Now before running your ANT script to build and deploy the above webapplication you should have the ANT as well as JAVA set in the $PATH variable of the Shell / command prompt as following:

For Unix Based OS:
export PATH=/home/jaysensharma/jdk1.6.0_21/bin:/home/jaysensharma/org.apache.ant_1.6.5/bin:$PATH

For Windows Based OS:
set PATH=C:/jdk1.6.0_21/bin;C:/org.apache.ant_1.6.5/bin;%PATH%

Step-5). Now once the PATH is set In the command/Shell prompt you can move inside the directory “/home/jaysensharma/SingletonServiceDemo” and then run the ant to build and deploy the EJB based EAR applicationon your JBoss Standalone full profile, by running the command “ant deploy”

[jaysensharma@localhost SingletonServiceDemo]$ ant
Buildfile: build.xml

build_ear:
    [mkdir] Created dir: /home/jaysensharma/SingletonServiceDemo/tmp
    [javac] Compiling 1 source file to /home/jaysensharma/SingletonServiceDemo/tmp
      [jar] Building jar: /home/jaysensharma/SingletonServiceDemo/tmp/singletonServiceEJB.jar
    [mkdir] Created dir: /home/jaysensharma/SingletonServiceDemo/tmp/META-INF
      [jar] Building jar: /home/jaysensharma/SingletonServiceDemo/tmp/TestSingletonService.ear
   [delete] Deleting: /home/jaysensharma/SingletonServiceDemo/tmp/singletonServiceEJB.jar
     [copy] Copying 1 file to /home/jaysensharma/SingletonServiceDemo/build
   [delete] Deleting directory /home/jaysensharma/SingletonServiceDemo/tmp

deploy:
     [echo] *******************  Deploying the EAR file TestSingletonService.ear *********************
     [echo] ********** build/TestSingletonService.ear to /home/jaysensharma/jboss-as-7.1.2.Final/standalone/deployments **********
     [copy] Copying 1 file to /home/jaysensharma/jboss-as-7.1.2.Final/standalone/deployments
     [echo] *******************  Deployed Successfully   *********************

all:

BUILD SUCCESSFUL
Total time: 1 second

Step-6). As the application is deployed on your JBoss so now try restarting your JBoss and then see whether the Above service us successfully get the DataSource and JDBC Connection or not. If the Dependency is correctly working then after restarting your JBoss you will see the following kind of message on your JBoss console / logs.

22:41:51,569 INFO  [sar.dependency.alternative.SingletonServiceBean] (MSC service thread 1-1) ***** DataSource = org.jboss.jca.adapters.jdbc.WrapperDataSource@43877c42 . Connection con = org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6@5424bf0 retrieved from the ConnectionPool.*****

.
.
Thanks
MiddlewareMagic Team :)


Curl Based Management & Monitoring in JBossAS7 with HTTP-JSON APIs

Trust me None other Application Server provides this kind of amazing feature, except JBossAS7. JBoss AS7 is one of the bestest application available in the Middleware World, As it provides much more facilities to the Administrators in order to manage/configure and monitor various resources. As we are already familier with a utility called as “$JBOSS_HOME/bin/jboss-cli.sh” is one of the most powerful and easiest utility which can be used to manage and monitor JBossAS7.

In this demonstration we will see that JBoss AS7 provides another best feature, which allows us to easily access & monitor & management the JBoss AS7 using OS level utilities like “curl”. Yes, JBoss AS7 provides HTTP-JSON based APIs which can be used to achieve the same. So lets see some of it’s features…

So lets start JBossAS7 like following:

    ./standalone.sh -c standalone-full.xml

NOTE: In all the following operations we will assume that you have created a ManagementRealm User with username “admin” and password as “admin123″ (you can create any user name/password based on your requirement), Then change the username & password in the mentioned demo URLs like “http://admin:admin123@localhost:9990/management/”

NOTE: Curl is a free utility for non-interactive download of files from the Web.

So Open a Terminal (command prompt) and start testing the following Curl command on your JBossAS7

Checking Server State

curl --digest -L -D - http://admin:admin123@localhost:9990/management --header "Content-Type: application/json" -d '{"operation":"read-attribute","name":"server-state","json.pretty":1}'

HTTP/1.1 401 Unauthorized
Content-length: 0
Www-authenticate: Digest realm="ManagementRealm",nonce="07d65fc8e028df9ed577145c8e973c64"
Date: Sun, 23 Sep 2012 15:18:59 GMT

HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: application/json
Date: Sun, 23 Sep 2012 15:18:59 GMT

{
    "outcome" : "success",
    "result" : "running"
}

Editing “max-pool-size” attribute of ExampleDS DataSource

curl --digest -L -D - http://admin:admin123@localhost:9990/management/ -d '{"operation":"write-attribute","address":[{"subsystem":"datasources"},{"data-source":"ExampleDS"}],"name":"max-pool-size","value":10}' -HContent-Type:application/json

HTTP/1.1 401 Unauthorized
Content-length: 0
Www-authenticate: Digest realm="ManagementRealm",nonce="57d99ff484d2b950ecfde2bcd8c7b55c"
Date: Sun, 23 Sep 2012 15:27:32 GMT

HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: application/json
Date: Sun, 23 Sep 2012 15:27:32 GMT

Editing “min-pool-size” attribute of ExampleDS DataSource

curl --digest -L -D - http://admin:admin123@localhost:9990/management/ -d '{"operation":"write-attribute","address":[{"subsystem":"datasources"},{"data-source":"ExampleDS"}],"name":"min-pool-size","value":5}' -HContent-Type:application/json

HTTP/1.1 401 Unauthorized
Content-length: 0
Www-authenticate: Digest realm="ManagementRealm",nonce="662bd288e4949b0093b8d1c5db704a6a"
Date: Sun, 23 Sep 2012 15:33:37 GMT

HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: application/json
Date: Sun, 23 Sep 2012 15:33:37 GMT

Changing console-handler “CONSOLE” logging level to “WARN”


curl --digest -L -D - http://admin:admin123@localhost:9990/management/ -d '{"operation":"write-attribute","address":[{"subsystem":"logging"},{"console-handler":"CONSOLE"}],"name":"level","value":"WARN", "json.pretty":1}' -HContent-Type:application/json

HTTP/1.1 401 Unauthorized
Content-length: 0
Www-authenticate: Digest realm="ManagementRealm",nonce="8ad3a0fd0b5f393c8cf9ac757d8395d3"
Date: Sun, 23 Sep 2012 20:00:07 GMT

HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: application/json
Date: Sun, 23 Sep 2012 20:00:07 GMT

{"outcome" : "success"}

Testing ExampleDS datasource connections

curl --digest -L -D - http://admin:admin123@localhost:9990/management/ -d '{"operation":"test-connection-in-pool","address":[{"subsystem":"datasources"},{"data-source":"ExampleDS"}]}' -HContent-Type:application/json

HTTP/1.1 401 Unauthorized
Content-length: 0
Www-authenticate: Digest realm="ManagementRealm",nonce="2feecad0028c0122ed04c2bf344fdde3"
Date: Sun, 23 Sep 2012 16:47:29 GMT

HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: application/json
Date: Sun, 23 Sep 2012 16:47:30 GMT

{"outcome" : "success", "result" : [true]}

Getting JVM Memory & Runtime Details

curl --digest -D - http://admin:admin123@localhost:9990/management/ -d '{"operation":"read-resource", "include-runtime":"true", "address":[{"core-service":"platform-mbean"},{"type":"memory"}], "json.pretty":1}' -HContent-Type:application/json

HTTP/1.1 401 Unauthorized
Content-length: 0
Www-authenticate: Digest realm="ManagementRealm",nonce="86d37639bcc651b1cea47a91bef0be14"
Date: Sun, 23 Sep 2012 19:44:19 GMT

HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: application/json
Date: Sun, 23 Sep 2012 19:44:19 GMT

{
    "outcome" : "success",
    "result" : {
        "heap-memory-usage" : {
            "init" : 1366294528,
            "used" : 161655864,
            "committed" : 1324351488,
            "max" : 1324351488
        },
        "non-heap-memory-usage" : {
            "init" : 24313856,
            "used" : 61050320,
            "committed" : 61210624,
            "max" : 318767104
        },
        "object-name" : "java.lang:type=Memory",
        "object-pending-finalization-count" : 0,
        "verbose" : false
    }
}

Getting JBoss Runtime Details

curl --digest -D - http://admin:admin123@localhost:9990/management/ -d '{"operation":"read-resource", "include-rutime":"true", "address":[{"core-service":"platform-mbean"},{"type":"runtime"}], "json.pretty":1}' -HContent-Type:application/json

HTTP/1.1 401 Unauthorized
Content-length: 0
Www-authenticate: Digest realm="ManagementRealm",nonce="b2d05e49490da200cdd74bd7f848998e"
Date: Sun, 23 Sep 2012 19:45:22 GMT

HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: application/json
Date: Sun, 23 Sep 2012 19:45:22 GMT

{
    "outcome" : "success",
    "result" : {
        "name" : "24028@localhost.localdomain",
        "vm-name" : "Java HotSpot(TM) 64-Bit Server VM",
        "vm-vendor" : "Oracle Corporation",
        "vm-version" : "23.1-b03",
        "spec-name" : "Java Virtual Machine Specification",
        "spec-vendor" : "Oracle Corporation",
        "spec-version" : "1.7",
        "management-spec-version" : "1.2",
        "class-path" : "/home/userone/jboss-as-7.1.2/jboss-modules.jar",
        "library-path" : "/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib",
        "boot-class-path-supported" : true,
        "boot-class-path" : "/home/userone/jdk1.7.0_05/jre/lib/resources.jar:/home/userone/jdk1.7.0_05/jre/lib/rt.jar:/home/userone/jdk1.7.0_05/jre/lib/sunrsasign.jar:/home/userone/jdk1.7.0_05/jre/lib/jsse.jar:/home/userone/jdk1.7.0_05/jre/lib/jce.jar:/home/userone/jdk1.7.0_05/jre/lib/charsets.jar:/home/userone/jdk1.7.0_05/jre/lib/jfr.jar:/home/userone/jdk1.7.0_05/jre/classes",
        "input-arguments" : [
            "-D[Standalone]",
            "-XX:+UseCompressedOops",
            "-Xms1303m",
            "-Xmx1303m",
            "-XX:MaxPermSize=256m",
            "-Djava.net.preferIPv4Stack=true",
            "-Dorg.jboss.resolver.warning=true",
            "-Dsun.rmi.dgc.client.gcInterval=3600000",
            "-Dsun.rmi.dgc.server.gcInterval=3600000",
            "-Djboss.modules.system.pkgs=org.jboss.byteman",
            "-Djava.awt.headless=true",
            "-Djboss.server.default.config=standalone.xml",
            "-Dorg.jboss.boot.log.file=/home/userone/jboss-as-7.1.2/standalone/log/boot.log",
            "-Dlogging.configuration=file:/home/userone/jboss-as-7.1.2/standalone/configuration/logging.properties"
        ],
        "start-time" : 1348315286154,
        "system-properties" : {
            "[Standalone]" : "",
            "awt.toolkit" : "sun.awt.X11.XToolkit",
            "catalina.home" : "/home/userone/jboss-as-7.1.2/standalone/tmp",
            "ddddd" : "eeeee",
            "file.encoding" : "UTF-8",
            "file.encoding.pkg" : "sun.io",
            "file.separator" : "/",
            "java.awt.graphicsenv" : "sun.awt.X11GraphicsEnvironment",
            "java.awt.headless" : "true",
            "java.awt.printerjob" : "sun.print.PSPrinterJob",
            "java.class.path" : "/home/userone/jboss-as-7.1.2/jboss-modules.jar",
            "java.class.version" : "51.0",
            "java.endorsed.dirs" : "/home/userone/jdk1.7.0_05/jre/lib/endorsed",
            "java.ext.dirs" : "/home/userone/jdk1.7.0_05/jre/lib/ext:/usr/java/packages/lib/ext",
            "java.home" : "/home/userone/jdk1.7.0_05/jre",
            "java.io.tmpdir" : "/tmp",
            "java.library.path" : "/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib",
            "java.naming.factory.url.pkgs" : "org.jboss.as.naming.interfaces:org.jboss.ejb.client.naming",
            "java.net.preferIPv4Stack" : "true",
            "java.protocol.handler.pkgs" : "org.jboss.net.protocol|org.jboss.vfs.protocol",
            "java.runtime.name" : "Java(TM) SE Runtime Environment",
            "java.runtime.version" : "1.7.0_05-b05",
            "java.specification.name" : "Java Platform API Specification",
            "java.specification.vendor" : "Oracle Corporation",
            "java.specification.version" : "1.7",
            "java.util.logging.manager" : "org.jboss.logmanager.LogManager",
            "java.vendor" : "Oracle Corporation",
            "java.vendor.url" : "http://java.oracle.com/",
            "java.vendor.url.bug" : "http://bugreport.sun.com/bugreport/",
            "java.version" : "1.7.0_05",
            "java.vm.info" : "mixed mode",
            "java.vm.name" : "Java HotSpot(TM) 64-Bit Server VM",
            "java.vm.specification.name" : "Java Virtual Machine Specification",
            "java.vm.specification.vendor" : "Oracle Corporation",
            "java.vm.specification.version" : "1.7",
            "java.vm.vendor" : "Oracle Corporation",
            "java.vm.version" : "23.1-b03",
            "javax.management.builder.initial" : "org.jboss.as.jmx.PluggableMBeanServerBuilder",
            "javax.xml.datatype.DatatypeFactory" : "__redirected.__DatatypeFactory",
            "javax.xml.parsers.DocumentBuilderFactory" : "__redirected.__DocumentBuilderFactory",
            "javax.xml.parsers.SAXParserFactory" : "__redirected.__SAXParserFactory",
            "javax.xml.stream.XMLEventFactory" : "__redirected.__XMLEventFactory",
            "javax.xml.stream.XMLInputFactory" : "__redirected.__XMLInputFactory",
            "javax.xml.stream.XMLOutputFactory" : "__redirected.__XMLOutputFactory",
            "javax.xml.transform.TransformerFactory" : "__redirected.__TransformerFactory",
            "javax.xml.validation.SchemaFactory:http://www.w3.org/2001/XMLSchema" : "__redirected.__SchemaFactory",
            "javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom" : "__redirected.__XPathFactory",
            "jboss.home.dir" : "/home/userone/jboss-as-7.1.2",
            "jboss.host.name" : "localhost",
            "jboss.modules.dir" : "/home/userone/jboss-as-7.1.2/modules",
            "jboss.modules.system.pkgs" : "org.jboss.byteman",
            "jboss.node.name" : "localhost",
            "jboss.qualified.host.name" : "localhost.localdomain",
            "jboss.server.base.dir" : "/home/userone/jboss-as-7.1.2/standalone",
            "jboss.server.config.dir" : "/home/userone/jboss-as-7.1.2/standalone/configuration",
            "jboss.server.data.dir" : "/home/userone/jboss-as-7.1.2/standalone/data",
            "jboss.server.default.config" : "standalone.xml",
            "jboss.server.deploy.dir" : "/home/userone/jboss-as-7.1.2/standalone/data/content",
            "jboss.server.log.dir" : "/home/userone/jboss-as-7.1.2/standalone/log",
            "jboss.server.name" : "localhost",
            "jboss.server.temp.dir" : "/home/userone/jboss-as-7.1.2/standalone/tmp",
            "line.separator" : "\n",
            "logging.configuration" : "file:/home/userone/jboss-as-7.1.2/standalone/configuration/logging.properties",
            "module.path" : "/home/userone/jboss-as-7.1.2/modules",
            "org.apache.coyote.http11.Http11Protocol.COMPRESSION" : "on",
            "org.apache.coyote.http11.Http11Protocol.COMPRESSION_MIME_TYPES" : "text/javascript,text/css,text/html",
            "org.apache.coyote.http11.Http11Protocol.COMPRESSION_MIN_SIZE" : "5",
            "org.jboss.as.logging.per-deployment" : "false",
            "org.jboss.boot.log.file" : "/home/userone/jboss-as-7.1.2/standalone/log/boot.log",
            "org.jboss.com.sun.CORBA.ORBUseDynamicStub" : "true",
            "org.jboss.resolver.warning" : "true",
            "org.jboss.security.context.ThreadLocal" : "true",
            "org.omg.CORBA.ORBClass" : "org.jacorb.orb.ORB",
            "org.omg.CORBA.ORBSingletonClass" : "org.jacorb.orb.ORBSingleton",
            "org.osgi.vendor.framework" : "org.jboss.osgi.framework",
            "org.xml.sax.driver" : "__redirected.__XMLReaderFactory",
            "os.arch" : "amd64",
            "os.name" : "Linux",
            "os.version" : "3.4.9-2.fc16.x86_64",
            "path.separator" : ":",
            "sun.arch.data.model" : "64",
            "sun.boot.class.path" : "/home/userone/jdk1.7.0_05/jre/lib/resources.jar:/home/userone/jdk1.7.0_05/jre/lib/rt.jar:/home/userone/jdk1.7.0_05/jre/lib/sunrsasign.jar:/home/userone/jdk1.7.0_05/jre/lib/jsse.jar:/home/userone/jdk1.7.0_05/jre/lib/jce.jar:/home/userone/jdk1.7.0_05/jre/lib/charsets.jar:/home/userone/jdk1.7.0_05/jre/lib/jfr.jar:/home/userone/jdk1.7.0_05/jre/classes",
            "sun.boot.library.path" : "/home/userone/jdk1.7.0_05/jre/lib/amd64",
            "sun.cpu.endian" : "little",
            "sun.cpu.isalist" : "",
            "sun.desktop" : "gnome",
            "sun.io.unicode.encoding" : "UnicodeLittle",
            "sun.java.command" : "/home/userone/jboss-as-7.1.2/jboss-modules.jar -mp /home/userone/jboss-as-7.1.2/modules -jaxpmodule javax.xml.jaxp-provider org.jboss.as.standalone -Djboss.home.dir=/home/userone/jboss-as-7.1.2 -Djboss.server.base.dir=/home/userone/jboss-as-7.1.2/standalone -c standalone-full.xml -Dorg.jboss.as.logging.per-deployment=false",
            "sun.java.launcher" : "SUN_STANDARD",
            "sun.jnu.encoding" : "UTF-8",
            "sun.management.compiler" : "HotSpot 64-Bit Tiered Compilers",
            "sun.os.patch.level" : "unknown",
            "sun.rmi.dgc.client.gcInterval" : "3600000",
            "sun.rmi.dgc.server.gcInterval" : "3600000",
            "user.country" : "US",
            "user.dir" : "/home/userone/jboss-as-7.1.2/bin",
            "user.home" : "/home/jsenshar",
            "user.language" : "en",
            "user.name" : "jsenshar",
            "user.timezone" : "Asia/Calcutta"
        },
        "uptime" : 114236761,
        "object-name" : "java.lang:type=Runtime"
    }
}

Getting Server Environment Details

curl --digest -D - http://admin:admin123@localhost:9990/management/ -d '{"operation":"read-resource", "include-runtime":"true", "address":[{"core-service":"server-environment"}], "json.pretty":1}' -HContent-Type:application/json

HTTP/1.1 401 Unauthorized
Content-length: 0
Www-authenticate: Digest realm="ManagementRealm",nonce="39385b83b7b9b2abbd722a3bdb4d7173"
Date: Sun, 23 Sep 2012 19:47:56 GMT

HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: application/json
Date: Sun, 23 Sep 2012 19:47:56 GMT

{
    "outcome" : "success",
    "result" : {
        "base-dir" : "/home/userone/jboss-as-7.1.2/standalone",
        "config-dir" : "/home/userone/jboss-as-7.1.2/standalone/configuration",
        "config-file" : "/home/userone/jboss-as-7.1.2/standalone/configuration/standalone-full.xml",
        "content-dir" : "/home/userone/jboss-as-7.1.2/standalone/data/content",
        "data-dir" : "/home/userone/jboss-as-7.1.2/standalone/data",
        "deploy-dir" : "/home/userone/jboss-as-7.1.2/standalone/data/content",
        "ext-dirs" : [
            "/home/userone/jdk1.7.0_05/jre/lib/ext",
            "/usr/java/packages/lib/ext"
        ],
        "home-dir" : "/home/userone/jboss-as-7.1.2",
        "host-name" : "localhost",
        "initial-running-mode" : "NORMAL",
        "launch-type" : "STANDALONE",
        "log-dir" : "/home/userone/jboss-as-7.1.2/standalone/log",
        "modules-dir" : "/home/userone/jboss-as-7.1.2/modules",
        "node-name" : "localhost",
        "qualified-host-name" : "localhost.localdomain",
        "server-name" : "localhost",
        "temp-dir" : "/home/userone/jboss-as-7.1.2/standalone/tmp"
    }
}

Getting Runtime Statistics of Http Connector of web subsystem

curl --digest -D - http://admin:admin123@localhost:9990/management/ -d '{"operation":"read-resource", "include-runtime":"true", "address":[{"subsystem":"web"},{"connector":"http"}], "json.pretty":1}' -HContent-Type:application/json

HTTP/1.1 401 Unauthorized
Content-length: 0
Www-authenticate: Digest realm="ManagementRealm",nonce="37b5ee0cb0dde6f3963e7660a4439862"
Date: Sun, 23 Sep 2012 19:51:16 GMT

HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: application/json
Date: Sun, 23 Sep 2012 19:51:16 GMT

{
    "outcome" : "success",
    "result" : {
        "bytesReceived" : "0",
        "bytesSent" : "0",
        "enable-lookups" : false,
        "enabled" : true,
        "errorCount" : "0",
        "executor" : null,
        "max-connections" : 20,
        "max-post-size" : 2097152,
        "max-save-post-size" : 4096,
        "maxTime" : "0",
        "name" : "http",
        "processingTime" : "0",
        "protocol" : "HTTP/1.1",
        "proxy-name" : null,
        "proxy-port" : null,
        "redirect-port" : 8433,
        "requestCount" : "0",
        "scheme" : "http",
        "secure" : false,
        "socket-binding" : "http",
        "ssl" : null,
        "virtual-server" : null
    }
}

Shutting down JBoss Standalone Server

curl --digest -D - http://admin:admin123@localhost:9990/management/ -d '{"operation":"shutdown" , "json.pretty":1}' -HContent-Type:application/json

HTTP/1.1 401 Unauthorized
Content-length: 0
Www-authenticate: Digest realm="ManagementRealm",nonce="dd74ab565fbf5345ebb015cbd337ffea"
Date: Sun, 23 Sep 2012 20:08:02 GMT

HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: application/json
Date: Sun, 23 Sep 2012 20:08:02 GMT

{"outcome" : "success"}

Getting Application “TestLogging.ear” Details

curl --digest -D - http://admin:admin123@localhost:9990/management --header "Content-Type: application/json" -d '{"operation":"read-resource", "address":["deployment","TestLogging.ear"], "json.pretty":1}' 

HTTP/1.1 401 Unauthorized
Content-length: 0
Www-authenticate: Digest realm="ManagementRealm",nonce="486aa728c5bd526ab1bf1b96941252e2"
Date: Sat, 22 Sep 2012 11:07:38 GMT

HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: application/json
Date: Sat, 22 Sep 2012 11:07:38 GMT

{
    "outcome" : "success",
    "result" : {
        "content" : [{
            "path" : "deployments/TestLogging.ear",
            "relative-to" : "jboss.server.base.dir",
            "archive" : false
        }],
        "enabled" : true,
        "name" : "TestLogging.ear",
        "persistent" : false,
        "runtime-name" : "TestLogging.ear",
        "subsystem" : null,
        "subdeployment" : {
            "Log4jDemoOne.war" : null,
            "Log4jDemoTwo.war" : null
        }
    }
}

Getting Runtime Statistics of “Test_EAR.ear” application (session/request monitoring)

curl --digest -D - http://admin:admin123@localhost:9990/management --header "Content-Type: application/json" -d '{"operation":"read-resource","recursive":"true", "include-runtime":"true", "address":["deployment","Test_EAR.ear"], "json.pretty":1}'

HTTP/1.1 401 Unauthorized
Content-length: 0
Www-authenticate: Digest realm="ManagementRealm",nonce="80f9f113cda3ea0430c0a1474ac9b736"
Date: Sun, 23 Sep 2012 20:20:29 GMT

HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: application/json
Date: Sun, 23 Sep 2012 20:20:29 GMT

{
    "outcome" : "success",
    "result" : {
        "content" : [{"hash" : {
            "BYTES_VALUE" : "mSLytFVBop/W+VqanbNUztt7DRY="
        }}],
        "enabled" : true,
        "name" : "Test_EAR.ear",
        "persistent" : true,
        "runtime-name" : "test_trn.ear",
        "status" : "no metrics available",
        "subsystem" : null,
        "subdeployment" : {"Test_WAR.war" : {"subsystem" : {"web" : {
            "active-sessions" : 1,
            "context-root" : "/Test_WAR",
            "duplicated-session-ids" : 0,
            "expired-sessions" : 0,
            "max-active-sessions" : 1,
            "rejected-sessions" : 0,
            "servlet" : null,
            "session-avg-alive-time" : 0,
            "session-max-alive-time" : 0,
            "sessions-created" : 1,
            "virtual-host" : "default-host"
        }}}}
    }
}

Getting JNDI view details (list Jndi) / (jndi-view)

curl --digest -D - http://admin:admin123@localhost:9990/management --header "Content-Type: application/json" -d '{"operation":"jndi-view", "address":["subsystem","naming"], "json.pretty":1}'

HTTP/1.1 401 Unauthorized
Content-length: 0
Www-authenticate: Digest realm="ManagementRealm",nonce="e92a46c2e34810ed0084542cc59ca38f"
Date: Sat, 22 Sep 2012 11:13:29 GMT

HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: application/json
Date: Sat, 22 Sep 2012 11:13:29 GMT

{
    "outcome" : "success",
    "result" : {
        "java: contexts" : {
            "java:" : {
                "ConnectionFactory" : {
                    "class-name" : "org.hornetq.jms.client.HornetQJMSConnectionFactory",
                    "value" : "HornetQConnectionFactory [serverLocator=ServerLocatorImpl [initialConnectors=[org-hornetq-core-remoting-impl-invm-InVMConnectorFactory?server-id=0], discoveryGroupConfiguration=null], clientID=null, dupsOKBatchSize=1048576, transactionBatchSize=1048576, readOnly=false]"
                },
                "JmsXA" : {
                    "class-name" : "org.hornetq.ra.HornetQRAConnectionFactoryImpl",
                    "value" : "org.hornetq.ra.HornetQRAConnectionFactoryImpl@59ffb3fa"
                },
                "TransactionManager" : {
                    "class-name" : "com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate",
                    "value" : "com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate@13190ef8"
                },
                "ejb" : {
                    "class-name" : "javax.naming.Context",
                    "children" : {"mgmt" : {
                        "class-name" : "javax.naming.Context",
                        "children" : null
                    }}
                },
                "jboss" : {
                    "class-name" : "javax.naming.Context",
                    "value" : "org.jboss.as.naming.WritableServiceBasedNamingStore@6ab0fa3b"
                }
            },
            "java:jboss" : {
                "ORB" : {
                    "class-name" : "org.jacorb.orb.ORB",
                    "value" : "org.jacorb.orb.ORB@274fb2cf"
                },
                "TransactionManager" : {
                    "class-name" : "com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate",
                    "value" : "com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate@13190ef8"
                },
                "TransactionSynchronizationRegistry" : {
                    "class-name" : "com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple",
                    "value" : "com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple@61644832"
                },
                "UserTransaction" : {
                    "class-name" : "org.jboss.tm.usertx.client.ServerVMClientUserTransaction",
                    "value" : "org.jboss.tm.usertx.client.ServerVMClientUserTransaction@5e6d855c"
                },
                "corbanaming" : {
                    "class-name" : "org.omg.CosNaming._NamingContextExtStub",
                    "value" : "IOR:000000000000002B49444C3A6F6D672E6F72672F436F734E616D696E672F4E616D696E67436F6E746578744578743A312E3000000000000100000000000000B0000102000000000A3132372E302E302E31000DC8000000114A426F73732F4E616D696E672F726F6F74000000000000040000000000000008000000004A4143000000000100000020000000000501000100000001000100010001010900000002050100010001010000000014000000080000001A00000DC90000002100000030000000000000000100000000000000220000000000000000000000000000000000000000000000000000000000000000"
                },
                "irpoa" : {
                    "class-name" : "org.jacorb.poa.POA",
                    "value" : "org.jacorb.poa.POA@7ebffc91"
                },
                "jaas" : {
                    "class-name" : "$Proxy13",
                    "children" : {
                        "jboss-ejb-policy" : {
                            "class-name" : "org.jboss.as.security.plugins.SecurityDomainContext",
                            "value" : "org.jboss.security.authentication.JBossCachedAuthenticationManager@7c1e7bee"
                        },
                        "other" : {
                            "class-name" : "org.jboss.as.security.plugins.SecurityDomainContext",
                            "value" : "org.jboss.security.authentication.JBossCachedAuthenticationManager@355a85eb"
                        },
                        "jboss-web-policy" : {
                            "class-name" : "org.jboss.as.security.plugins.SecurityDomainContext",
                            "value" : "org.jboss.security.authentication.JBossCachedAuthenticationManager@4a0e22aa"
                        }
                    }
                },
                "poa" : {
                    "class-name" : "org.jacorb.poa.POA",
                    "value" : "org.jacorb.poa.POA@6605ece1"
                },
                "mail" : {
                    "class-name" : "javax.naming.Context",
                    "children" : {"Default" : {
                        "class-name" : "javax.mail.Session",
                        "value" : "javax.mail.Session@3e475bbb"
                    }}
                },
                "datasources" : {
                    "class-name" : "javax.naming.Context",
                    "children" : {"ExampleDS" : {
                        "class-name" : "org.jboss.jca.adapters.jdbc.WrapperDataSource",
                        "value" : "org.jboss.jca.adapters.jdbc.WrapperDataSource@9b534aa"
                    }}
                },
                "exported" : {
                    "class-name" : "javax.naming.Context",
                    "value" : "org.jboss.as.naming.WritableServiceBasedNamingStore@579489e0"
                }
            },
            "java:global" : null
        },
        "applications" : {"TestLogging.ear" : {
            "java:app" : {
                "AppName" : {
                    "class-name" : "java.lang.String",
                    "value" : "TestLogging"
                },
                "env" : {
                    "class-name" : "org.jboss.as.naming.NamingContext",
                    "children" : null
                }
            },
            "modules" : null
        }}
    }
}

Dumping JBoss Services which are active

curl --digest -D - http://admin:admin123@localhost:9990/management --header "Content-Type: application/json" -d '{"operation":"dump-services", "address":["core-service","service-container"], "json.pretty":1}'

.
.
Thanks :)
MiddlewareMagic Team


Managing JBossAS7 with HTTP-JSON APIs using wget

Hi,

JBoss AS7 is one of the bestest application available in the Middleware World, As it provides much more facilities to the Administrators in order to manage/configure and monitor various resources. As we are already familier with a utility called as “$JBOSS_HOME/bin/jboss-cli.sh” is one of the most powerful and easiest utility which can be used to manage and monitor JBossAS7.

In this demonstration we will see that JBoss AS7 provides another best feature, which allows us to easily access & monitor the JBoss AS7 using OS level utilities like “curl” or “wget”. Yes, JBoss AS7 provides HTTP-JSON based APIs which can be used to achieve the same. So lets see some of it’s features…

So lets start JBossAS7 like following:

    ./standalone.sh -c standalone-full.xml

NOTE: In all the following operations we will assume that you have created a ManagementRealm User with username “admin” and password as “admin123″ (you can create any user name/password based on your requirement), Then change the username & password in the mentioned demo URLs like “http://admin:admin123@localhost:9990/management/

NOTE: Wget is a free utility for non-interactive download of files from the Web. It supports HTTP, HTTPS, and FTP protocols, as well as retrieval through HTTP proxies.
Wget can follow links in HTML pages and create local versions of remote web sites, fully recreating the directory structure of the original site. This is sometimes referred to as “recursive downloading.” While doing that, Wget respects the Robot Exclusion Standard (/robots.txt). Wget can be instructed to convert the links in downloaded HTML files to the local files for offline viewing.
More informations about “wget” utility can be found in the following link: http://en.wikipedia.org/wiki/Wget

Http Connector’s Runtime statistics

wget -O out.txt "http://admin:admin123@localhost:9990/management/subsystem/web/connector/http?operation=resource&include-runtime=true&recursive&json.pretty"

{
    "bytesReceived" : "0",
    "bytesSent" : "0",
    "enable-lookups" : false,
    "enabled" : true,
    "errorCount" : "0",
    "executor" : null,
    "max-connections" : 20,
    "max-post-size" : 2097152,
    "max-save-post-size" : 4096,
    "maxTime" : "124",
    "name" : "http",
    "processingTime" : "255",
    "protocol" : "HTTP/1.1",
    "proxy-name" : null,
    "proxy-port" : null,
    "redirect-port" : 8433,
    "requestCount" : "21",
    "scheme" : "http",
    "secure" : false,
    "socket-binding" : "http",
    "ssl" : null,
    "virtual-server" : null
}

Accessing the “jsp-configuration” of JBoss Web Container

wget -O out.txt "http://admin:admin123@localhost:9990/management/subsystem/web/configuration/jsp-configuration?operation=resource&recursive&json.pretty"

{
    "check-interval" : 0,
    "development" : false,
    "disabled" : false,
    "display-source-fragment" : true,
    "dump-smap" : false,
    "error-on-use-bean-invalid-class-attribute" : false,
    "generate-strings-as-char-arrays" : false,
    "java-encoding" : "UTF8",
    "keep-generated" : true,
    "mapped-file" : true,
    "modification-test-interval" : 4,
    "recompile-on-fail" : false,
    "scratch-dir" : null,
    "smap" : true,
    "source-vm" : "1.5",
    "tag-pooling" : true,
    "target-vm" : "1.5",
    "trim-spaces" : false,
    "x-powered-by" : true
}

Accessing Deployment Details

wget -O out.txt "http://admin:admin123@localhost:9990/management/deployment/TestLogging.ear/subdeployment/Log4jDemoOne.war?operation=resource&include-runtime&recursive&json.pretty"

Suppose you have deployed an EAP application with name “TestLogging.ear” which contains a sunmodule with name “Log4jDemoOne.war” then you can get it’s runtime information using the above command, the outputwill be something like following:


{"subsystem" : {"web" : {
    "active-sessions" : 0,
    "context-root" : "/Log4jDemoOne",
    "duplicated-session-ids" : 0,
    "expired-sessions" : 2,
    "max-active-sessions" : 2,
    "rejected-sessions" : 0,
    "servlet" : null,
    "session-avg-alive-time" : 1851,
    "session-max-alive-time" : 1852,
    "sessions-created" : 2,
    "virtual-host" : "default-host"
}}}

In order to get the EAR depployment details you can use the following command:

wget -O out.txt "http://admin:admin123@localhost:9990/management/deployment/TestLogging.ear?operation=resource&recursive&json.pretty"

{
    "content" : [{
        "path" : "deployments/TestLogging.ear",
        "relative-to" : "jboss.server.base.dir",
        "archive" : false
    }],
    "enabled" : true,
    "name" : "TestLogging.ear",
    "persistent" : false,
    "runtime-name" : "TestLogging.ear",
    "subsystem" : null,
    "subdeployment" : {
        "Log4jDemoOne.war" : {"subsystem" : {"web" : {
            "context-root" : "/Log4jDemoOne",
            "servlet" : null,
            "virtual-host" : "default-host"
        }}},
        "Log4jDemoTwo.war" : {"subsystem" : {"web" : {
            "context-root" : "/Log4jDemoTwo",
            "servlet" : null,
            "virtual-host" : "default-host"
        }}}
    }
}

Getting Management Interface Details

wget -O out.txt "http://admin:admin123@localhost:9990/management/interface/public?operation=resource&recursive&json.pretty"

{
    "any" : null,
    "any-address" : null,
    "any-ipv4-address" : null,
    "any-ipv6-address" : null,
    "inet-address" : {
        "EXPRESSION_VALUE" : "${jboss.bind.address:127.0.0.1}"
    },
    "link-local-address" : null,
    "loopback" : null,
    "loopback-address" : null,
    "multicast" : null,
    "name" : "public",
    "nic" : null,
    "nic-match" : null,
    "not" : null,
    "point-to-point" : null,
    "public-address" : null,
    "site-local-address" : null,
    "subnet-match" : null,
    "up" : null,
    "virtual" : null
}

DataSource Configuration & Runtime Details

wget -O out.txt "http://admin:admin123@localhost:9990/management/subsystem/datasources/data-source/ExampleDS/statistics/pool?read-resource&include-runtime=true&recursive&json.pretty"

{
    "ActiveCount" : "0",
    "AvailableCount" : "20",
    "AverageBlockingTime" : "0",
    "AverageCreationTime" : "0",
    "CreatedCount" : "0",
    "DestroyedCount" : "0",
    "MaxCreationTime" : "0",
    "MaxUsedCount" : "0",
    "MaxWaitTime" : "0",
    "TimedOut" : "0",
    "TotalBlockingTime" : "0",
    "TotalCreationTime" : "0"
}

Geting Jdbc Statictics:

wget -O out.txt "http://admin:admin123@localhost:9990/management/subsystem/datasources/data-source/ExampleDS/statistics/jdbc?read-resource&include-runtime=true&recursive&json.pretty"

{
    "PreparedStatementCacheAccessCount" : "0",
    "PreparedStatementCacheAddCount" : "0",
    "PreparedStatementCacheCurrentSize" : "0",
    "PreparedStatementCacheDeleteCount" : "0",
    "PreparedStatementCacheHitCount" : "0",
    "PreparedStatementCacheMissCount" : "0"
}

Getting all the informations related to DataSource at once:


wget -O out.txt "http://admin:admin123@localhost:9990/management/subsystem/datasources/data-source/ExampleDS/statistics?read-resource&include-runtime=true&recursive&json.pretty"

{
    "allocation-retry" : null,
    "allocation-retry-wait-millis" : null,
    "allow-multiple-users" : null,
    "background-validation" : null,
    "background-validation-millis" : null,
    "blocking-timeout-wait-millis" : null,
    "check-valid-connection-sql" : null,
    "connection-properties" : null,
    "connection-url" : "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1",
    "datasource-class" : null,
    "driver-class" : null,
    "driver-name" : "h2",
    "enabled" : true,
    "exception-sorter-class-name" : null,
    "exception-sorter-properties" : null,
    "flush-strategy" : null,
    "idle-timeout-minutes" : null,
    "jndi-name" : "java:jboss/datasources/ExampleDS",
    "jta" : true,
    "max-pool-size" : null,
    "min-pool-size" : null,
    "new-connection-sql" : null,
    "password" : "sa",
    "pool-prefill" : null,
    "pool-use-strict-min" : null,
    "prepared-statements-cache-size" : null,
    "query-timeout" : null,
    "reauth-plugin-class-name" : null,
    "reauth-plugin-properties" : null,
    "security-domain" : null,
    "set-tx-query-timeout" : false,
    "share-prepared-statements" : false,
    "spy" : false,
    "stale-connection-checker-class-name" : null,
    "stale-connection-checker-properties" : null,
    "track-statements" : "NOWARN",
    "transaction-isolation" : null,
    "url-delimiter" : null,
    "url-selector-strategy-class-name" : null,
    "use-ccm" : true,
    "use-fast-fail" : false,
    "use-java-context" : true,
    "use-try-lock" : null,
    "user-name" : "sa",
    "valid-connection-checker-class-name" : null,
    "valid-connection-checker-properties" : null,
    "validate-on-match" : false,
    "statistics" : {
        "jdbc" : {
            "PreparedStatementCacheAccessCount" : "0",
            "PreparedStatementCacheAddCount" : "0",
            "PreparedStatementCacheCurrentSize" : "0",
            "PreparedStatementCacheDeleteCount" : "0",
            "PreparedStatementCacheHitCount" : "0",
            "PreparedStatementCacheMissCount" : "0"
        },
        "pool" : {
            "ActiveCount" : "0",
            "AvailableCount" : "20",
            "AverageBlockingTime" : "0",
            "AverageCreationTime" : "0",
            "CreatedCount" : "0",
            "DestroyedCount" : "0",
            "MaxCreationTime" : "0",
            "MaxUsedCount" : "0",
            "MaxWaitTime" : "0",
            "TimedOut" : "0",
            "TotalBlockingTime" : "0",
            "TotalCreationTime" : "0"
        }
    }
}

Getting the <connection-url> attribute details of DataSource:

wget -O out.txt "http://admin:admin123@localhost:9990/management/subsystem/datasources/data-source/ExampleDS?operation=attribute&name=connection-url"

"jdbc:h2:mem:test;DB_CLOSE_DELAY=-1"

Getting “set-tx-query-timeout” attribute information of DataSource

wget -O out.txt "http://admin:admin123@localhost:9990/management/subsystem/datasources/data-source/ExampleDS?operation=attribute&name=set-tx-query-timeout"

false

Getting DataSource’s Comlete Configuration related information

wget -O out.txt "http://admin:admin123@localhost:9990/management/subsystem/datasources/data-source/ExampleDS?operation=resource&recursive&json.pretty"

{
    "allocation-retry" : null,
    "allocation-retry-wait-millis" : null,
    "allow-multiple-users" : null,
    "background-validation" : null,
    "background-validation-millis" : null,
    "blocking-timeout-wait-millis" : null,
    "check-valid-connection-sql" : null,
    "connection-properties" : null,
    "connection-url" : "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1",
    "datasource-class" : null,
    "driver-class" : null,
    "driver-name" : "h2",
    "enabled" : true,
    "exception-sorter-class-name" : null,
    "exception-sorter-properties" : null,
    "flush-strategy" : null,
    "idle-timeout-minutes" : null,
    "jndi-name" : "java:jboss/datasources/ExampleDS",
    "jta" : true,
    "max-pool-size" : null,
    "min-pool-size" : null,
    "new-connection-sql" : null,
    "password" : "sa",
    "pool-prefill" : null,
    "pool-use-strict-min" : null,
    "prepared-statements-cache-size" : null,
    "query-timeout" : null,
    "reauth-plugin-class-name" : null,
    "reauth-plugin-properties" : null,
    "security-domain" : null,
    "set-tx-query-timeout" : false,
    "share-prepared-statements" : false,
    "spy" : false,
    "stale-connection-checker-class-name" : null,
    "stale-connection-checker-properties" : null,
    "track-statements" : "NOWARN",
    "transaction-isolation" : null,
    "url-delimiter" : null,
    "url-selector-strategy-class-name" : null,
    "use-ccm" : true,
    "use-fast-fail" : false,
    "use-java-context" : true,
    "use-try-lock" : null,
    "user-name" : "sa",
    "valid-connection-checker-class-name" : null,
    "valid-connection-checker-properties" : null,
    "validate-on-match" : false,
    "statistics" : {
        "jdbc" : null,
        "pool" : null
    }
}

Getting Memory & Thread & Runtime Details with server properties

 wget -O out.txt "http://admin:admin123@localhost:9990/management/core-service/platform-mbean?operation=resource&type=runtime&recursive&json.pretty"

{"type" : {
    "garbage-collector" : {"name" : {
        "PS_Scavenge" : {},
        "PS_MarkSweep" : {}
    }},
    "runtime" : {
        "name" : "24028@localhost.localdomain",
        "vm-name" : "Java HotSpot(TM) 64-Bit Server VM",
        "vm-vendor" : "Oracle Corporation",
        "vm-version" : "23.1-b03",
        "spec-name" : "Java Virtual Machine Specification",
        "spec-vendor" : "Oracle Corporation",
        "spec-version" : "1.7",
        "management-spec-version" : "1.2",
        "class-path" : "/home/userone/jboss-as-7.1.2/jboss-modules.jar",
        "library-path" : "/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib",
        "boot-class-path-supported" : true,
        "boot-class-path" : "/home/userone/jdk1.7.0_05/jre/lib/resources.jar:/home/userone/jdk1.7.0_05/jre/lib/rt.jar:/home/userone/jdk1.7.0_05/jre/lib/sunrsasign.jar:/home/userone/jdk1.7.0_05/jre/lib/jsse.jar:/home/userone/jdk1.7.0_05/jre/lib/jce.jar:/home/userone/jdk1.7.0_05/jre/lib/charsets.jar:/home/userone/jdk1.7.0_05/jre/lib/jfr.jar:/home/userone/jdk1.7.0_05/jre/classes",
        "input-arguments" : [
            "-D[Standalone]",
            "-XX:+UseCompressedOops",
            "-Xms1303m",
            "-Xmx1303m",
            "-XX:MaxPermSize=256m",
            "-Djava.net.preferIPv4Stack=true",
            "-Dorg.jboss.resolver.warning=true",
            "-Dsun.rmi.dgc.client.gcInterval=3600000",
            "-Dsun.rmi.dgc.server.gcInterval=3600000",
            "-Djboss.modules.system.pkgs=org.jboss.byteman",
            "-Djava.awt.headless=true",
            "-Djboss.server.default.config=standalone.xml",
            "-Dorg.jboss.boot.log.file=/home/userone/jboss-as-7.1.2/standalone/log/boot.log",
            "-Dlogging.configuration=file:/home/userone/jboss-as-7.1.2/standalone/configuration/logging.properties"
        ],
        "start-time" : 1348315286154,
        "system-properties" : {
            "[Standalone]" : "",
            "awt.toolkit" : "sun.awt.X11.XToolkit",
            "catalina.home" : "/home/userone/jboss-as-7.1.2/standalone/tmp",
            "file.encoding" : "UTF-8",
            "file.encoding.pkg" : "sun.io",
            "file.separator" : "/",
            "java.awt.graphicsenv" : "sun.awt.X11GraphicsEnvironment",
            "java.awt.headless" : "true",
            "java.awt.printerjob" : "sun.print.PSPrinterJob",
            "java.class.path" : "/home/userone/jboss-as-7.1.2/jboss-modules.jar",
            "java.class.version" : "51.0",
            "java.endorsed.dirs" : "/home/userone/jdk1.7.0_05/jre/lib/endorsed",
            "java.ext.dirs" : "/home/userone/jdk1.7.0_05/jre/lib/ext:/usr/java/packages/lib/ext",
            "java.home" : "/home/userone/jdk1.7.0_05/jre",
            "java.io.tmpdir" : "/tmp",
            "java.library.path" : "/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib",
            "java.naming.factory.url.pkgs" : "org.jboss.as.naming.interfaces:org.jboss.ejb.client.naming",
            "java.net.preferIPv4Stack" : "true",
            "java.protocol.handler.pkgs" : "org.jboss.net.protocol|org.jboss.vfs.protocol",
            "java.runtime.name" : "Java(TM) SE Runtime Environment",
            "java.runtime.version" : "1.7.0_05-b05",
            "java.specification.name" : "Java Platform API Specification",
            "java.specification.vendor" : "Oracle Corporation",
            "java.specification.version" : "1.7",
            "java.util.logging.manager" : "org.jboss.logmanager.LogManager",
            "java.vendor" : "Oracle Corporation",
            "java.vendor.url" : "http://java.oracle.com/",
            "java.vendor.url.bug" : "http://bugreport.sun.com/bugreport/",
            "java.version" : "1.7.0_05",
            "java.vm.info" : "mixed mode",
            "java.vm.name" : "Java HotSpot(TM) 64-Bit Server VM",
            "java.vm.specification.name" : "Java Virtual Machine Specification",
            "java.vm.specification.vendor" : "Oracle Corporation",
            "java.vm.specification.version" : "1.7",
            "java.vm.vendor" : "Oracle Corporation",
            "java.vm.version" : "23.1-b03",
            "javax.management.builder.initial" : "org.jboss.as.jmx.PluggableMBeanServerBuilder",
            "javax.xml.datatype.DatatypeFactory" : "__redirected.__DatatypeFactory",
            "javax.xml.parsers.DocumentBuilderFactory" : "__redirected.__DocumentBuilderFactory",
            "javax.xml.parsers.SAXParserFactory" : "__redirected.__SAXParserFactory",
            "javax.xml.stream.XMLEventFactory" : "__redirected.__XMLEventFactory",
            "javax.xml.stream.XMLInputFactory" : "__redirected.__XMLInputFactory",
            "javax.xml.stream.XMLOutputFactory" : "__redirected.__XMLOutputFactory",
            "javax.xml.transform.TransformerFactory" : "__redirected.__TransformerFactory",
            "javax.xml.validation.SchemaFactory:http://www.w3.org/2001/XMLSchema" : "__redirected.__SchemaFactory",
            "javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom" : "__redirected.__XPathFactory",
            "jboss.home.dir" : "/home/userone/jboss-as-7.1.2",
            "jboss.host.name" : "localhost",
            "jboss.modules.dir" : "/home/userone/jboss-as-7.1.2/modules",
            "jboss.modules.system.pkgs" : "org.jboss.byteman",
            "jboss.node.name" : "localhost",
            "jboss.qualified.host.name" : "localhost.localdomain",
            "jboss.server.base.dir" : "/home/userone/jboss-as-7.1.2/standalone",
            "jboss.server.config.dir" : "/home/userone/jboss-as-7.1.2/standalone/configuration",
            "jboss.server.data.dir" : "/home/userone/jboss-as-7.1.2/standalone/data",
            "jboss.server.default.config" : "standalone.xml",
            "jboss.server.deploy.dir" : "/home/userone/jboss-as-7.1.2/standalone/data/content",
            "jboss.server.log.dir" : "/home/userone/jboss-as-7.1.2/standalone/log",
            "jboss.server.name" : "localhost",
            "jboss.server.temp.dir" : "/home/userone/jboss-as-7.1.2/standalone/tmp",
            "line.separator" : "\n",
            "logging.configuration" : "file:/home/userone/jboss-as-7.1.2/standalone/configuration/logging.properties",
            "module.path" : "/home/userone/jboss-as-7.1.2/modules",
            "org.apache.coyote.http11.Http11Protocol.COMPRESSION" : "on",
            "org.apache.coyote.http11.Http11Protocol.COMPRESSION_MIME_TYPES" : "text/javascript,text/css,text/html",
            "org.apache.coyote.http11.Http11Protocol.COMPRESSION_MIN_SIZE" : "5",
            "org.jboss.as.logging.per-deployment" : "false",
            "org.jboss.boot.log.file" : "/home/userone/jboss-as-7.1.2/standalone/log/boot.log",
            "org.jboss.com.sun.CORBA.ORBUseDynamicStub" : "true",
            "org.jboss.resolver.warning" : "true",
            "org.jboss.security.context.ThreadLocal" : "true",
            "org.omg.CORBA.ORBClass" : "org.jacorb.orb.ORB",
            "org.omg.CORBA.ORBSingletonClass" : "org.jacorb.orb.ORBSingleton",
            "org.osgi.vendor.framework" : "org.jboss.osgi.framework",
            "org.xml.sax.driver" : "__redirected.__XMLReaderFactory",
            "os.arch" : "amd64",
            "os.name" : "Linux",
            "os.version" : "3.4.9-2.fc16.x86_64",
            "path.separator" : ":",
            "sun.arch.data.model" : "64",
            "sun.boot.class.path" : "/home/userone/jdk1.7.0_05/jre/lib/resources.jar:/home/userone/jdk1.7.0_05/jre/lib/rt.jar:/home/userone/jdk1.7.0_05/jre/lib/sunrsasign.jar:/home/userone/jdk1.7.0_05/jre/lib/jsse.jar:/home/userone/jdk1.7.0_05/jre/lib/jce.jar:/home/userone/jdk1.7.0_05/jre/lib/charsets.jar:/home/userone/jdk1.7.0_05/jre/lib/jfr.jar:/home/userone/jdk1.7.0_05/jre/classes",
            "sun.boot.library.path" : "/home/userone/jdk1.7.0_05/jre/lib/amd64",
            "sun.cpu.endian" : "little",
            "sun.cpu.isalist" : "",
            "sun.desktop" : "gnome",
            "sun.io.unicode.encoding" : "UnicodeLittle",
            "sun.java.command" : "/home/userone/jboss-as-7.1.2/jboss-modules.jar -mp /home/userone/jboss-as-7.1.2/modules -jaxpmodule javax.xml.jaxp-provider org.jboss.as.standalone -Djboss.home.dir=/home/userone/jboss-as-7.1.2 -Djboss.server.base.dir=/home/userone/jboss-as-7.1.2/standalone -c standalone-full.xml -Dorg.jboss.as.logging.per-deployment=false",
            "sun.java.launcher" : "SUN_STANDARD",
            "sun.jnu.encoding" : "UTF-8",
            "sun.management.compiler" : "HotSpot 64-Bit Tiered Compilers",
            "sun.os.patch.level" : "unknown",
            "sun.rmi.dgc.client.gcInterval" : "3600000",
            "sun.rmi.dgc.server.gcInterval" : "3600000",
            "user.country" : "US",
            "user.dir" : "/home/userone/jboss-as-7.1.2/bin",
            "user.home" : "/home/jsenshar",
            "user.language" : "en",
            "user.name" : "jsenshar",
            "user.timezone" : "Asia/Calcutta"
        },
        "uptime" : 14530013,
        "object-name" : "java.lang:type=Runtime"
    },
    "memory-manager" : {"name" : {
        "PS_Scavenge" : {},
        "CodeCacheManager" : {},
        "PS_MarkSweep" : {}
    }},
    "threading" : {
        "all-thread-ids" : [
            150,
            142,
            140,
            139,
            138,
            137,
            136,
            135,
            134,
            132,
            131,
            130,
            129,
            127,
            126,
            125,
            124,
            123,
            122,
            121,
            120,
            117,
            116,
            115,
            114,
            113,
            112,
            111,
            110,
            109,
            108,
            106,
            105,
            103,
            102,
            101,
            100,
            98,
            97,
            96,
            93,
            95,
            94,
            92,
            91,
            90,
            88,
            87,
            86,
            85,
            80,
            79,
            53,
            52,
            51,
            20,
            18,
            17,
            16,
            15,
            14,
            13,
            12,
            11,
            8,
            4,
            3,
            2
        ],
        "thread-contention-monitoring-supported" : true,
        "thread-cpu-time-supported" : true,
        "current-thread-cpu-time-supported" : true,
        "object-monitor-usage-supported" : true,
        "synchronizer-usage-supported" : true,
        "thread-contention-monitoring-enabled" : false,
        "thread-cpu-time-enabled" : true,
        "thread-count" : 68,
        "peak-thread-count" : 118,
        "total-started-thread-count" : 144,
        "daemon-thread-count" : 31,
        "current-thread-cpu-time" : 528324157,
        "current-thread-user-time" : 170000000,
        "object-name" : "java.lang:type=Threading"
    },
    "buffer-pool" : {"name" : {
        "mapped" : {},
        "direct" : {}
    }},
    "memory-pool" : {"name" : {
        "PS_Eden_Space" : {
            "name" : "PS_Eden_Space",
            "type" : "HEAP",
            "valid" : true,
            "memory-manager-names" : [
                "PS_MarkSweep",
                "PS_Scavenge"
            ],
            "usage-threshold-supported" : false,
            "collection-usage-threshold-supported" : true,
            "usage-threshold" : null,
            "collection-usage-threshold" : 0,
            "usage" : {
                "init" : 341639168,
                "used" : 154096440,
                "committed" : 341966848,
                "max" : 341966848
            },
            "peak-usage" : {
                "init" : 341639168,
                "used" : 341639168,
                "committed" : 341966848,
                "max" : 341966848
            },
            "usage-threshold-exceeded" : null,
            "usage-threshold-count" : null,
            "collection-usage-threshold-exceeded" : false,
            "collection-usage-threshold-count" : 0,
            "collection-usage" : {
                "init" : 341639168,
                "used" : 0,
                "committed" : 341966848,
                "max" : 341966848
            },
            "object-name" : "java.lang:type=MemoryPool,name=\"PS Eden Space\""
        },
        "PS_Old_Gen" : {
            "name" : "PS_Old_Gen",
            "type" : "HEAP",
            "valid" : true,
            "memory-manager-names" : ["PS_MarkSweep"],
            "usage-threshold-supported" : true,
            "collection-usage-threshold-supported" : true,
            "usage-threshold" : 0,
            "collection-usage-threshold" : 0,
            "usage" : {
                "init" : 910884864,
                "used" : 81936,
                "committed" : 910884864,
                "max" : 911605760
            },
            "peak-usage" : {
                "init" : 910884864,
                "used" : 81936,
                "committed" : 910884864,
                "max" : 911605760
            },
            "usage-threshold-exceeded" : false,
            "usage-threshold-count" : 0,
            "collection-usage-threshold-exceeded" : false,
            "collection-usage-threshold-count" : 0,
            "collection-usage" : {
                "init" : 910884864,
                "used" : 0,
                "committed" : 0,
                "max" : 911605760
            },
            "object-name" : "java.lang:type=MemoryPool,name=\"PS Old Gen\""
        },
        "PS_Survivor_Space" : {
            "name" : "PS_Survivor_Space",
            "type" : "HEAP",
            "valid" : true,
            "memory-manager-names" : [
                "PS_MarkSweep",
                "PS_Scavenge"
            ],
            "usage-threshold-supported" : false,
            "collection-usage-threshold-supported" : true,
            "usage-threshold" : null,
            "collection-usage-threshold" : 0,
            "usage" : {
                "init" : 56885248,
                "used" : 44903304,
                "committed" : 56885248,
                "max" : 56885248
            },
            "peak-usage" : {
                "init" : 56885248,
                "used" : 44903304,
                "committed" : 56885248,
                "max" : 56885248
            },
            "usage-threshold-exceeded" : null,
            "usage-threshold-count" : null,
            "collection-usage-threshold-exceeded" : false,
            "collection-usage-threshold-count" : 0,
            "collection-usage" : {
                "init" : 56885248,
                "used" : 44903304,
                "committed" : 56885248,
                "max" : 56885248
            },
            "object-name" : "java.lang:type=MemoryPool,name=\"PS Survivor Space\""
        },
        "PS_Perm_Gen" : {
            "name" : "PS_Perm_Gen",
            "type" : "NON_HEAP",
            "valid" : true,
            "memory-manager-names" : ["PS_MarkSweep"],
            "usage-threshold-supported" : true,
            "collection-usage-threshold-supported" : true,
            "usage-threshold" : 0,
            "collection-usage-threshold" : 0,
            "usage" : {
                "init" : 21757952,
                "used" : 53906776,
                "committed" : 54001664,
                "max" : 268435456
            },
            "peak-usage" : {
                "init" : 21757952,
                "used" : 53906776,
                "committed" : 54001664,
                "max" : 268435456
            },
            "usage-threshold-exceeded" : false,
            "usage-threshold-count" : 0,
            "collection-usage-threshold-exceeded" : false,
            "collection-usage-threshold-count" : 0,
            "collection-usage" : {
                "init" : 21757952,
                "used" : 0,
                "committed" : 0,
                "max" : 268435456
            },
            "object-name" : "java.lang:type=MemoryPool,name=\"PS Perm Gen\""
        },
        "Code_Cache" : {
            "name" : "Code_Cache",
            "type" : "NON_HEAP",
            "valid" : true,
            "memory-manager-names" : ["CodeCacheManager"],
            "usage-threshold-supported" : true,
            "collection-usage-threshold-supported" : false,
            "usage-threshold" : 0,
            "collection-usage-threshold" : null,
            "usage" : {
                "init" : 2555904,
                "used" : 1969024,
                "committed" : 2555904,
                "max" : 50331648
            },
            "peak-usage" : {
                "init" : 2555904,
                "used" : 1979776,
                "committed" : 2555904,
                "max" : 50331648
            },
            "usage-threshold-exceeded" : false,
            "usage-threshold-count" : 0,
            "collection-usage-threshold-exceeded" : null,
            "collection-usage-threshold-count" : null,
            "collection-usage" : null,
            "object-name" : "java.lang:type=MemoryPool,name=\"Code Cache\""
        }
    }},
    "compilation" : {
        "name" : "HotSpot 64-Bit Tiered Compilers",
        "compilation-time-monitoring-supported" : true,
        "total-compilation-time" : 7407,
        "object-name" : "java.lang:type=Compilation"
    },
    "memory" : {},
    "class-loading" : {},
    "operating-system" : {
        "name" : "Linux",
        "arch" : "amd64",
        "version" : "3.4.9-2.fc16.x86_64",
        "available-processors" : 4,
        "system-load-average" : 0.13,
        "object-name" : "java.lang:type=OperatingSystem"
    }
}}

Messaging & HornetQ subsystem related Details

wget -O out.txt "http://admin:admin123@localhost:9990/management/subsystem/messaging/hornetq-server/default?operation=resource&recursive&json.pretty"

{
    "acceptor" : null,
    "allow-failback" : true,
    "async-connection-execution-enabled" : true,
    "backup" : false,
    "bridge" : null,
    "broadcast-group" : null,
    "cluster-connection" : null,
    "cluster-password" : "CHANGE ME!!",
    "cluster-user" : "HORNETQ.CLUSTER.ADMIN.USER",
    "clustered" : false,
    "connection-ttl-override" : -1,
    "connector" : null,
    "connector-service" : null,
    "core-address" : null,
    "create-bindings-dir" : true,
    "create-journal-dir" : true,
    "discovery-group" : null,
    "divert" : null,
    "failback-delay" : 5000,
    "failover-on-shutdown" : false,
    "grouping-handler" : null,
    "id-cache-size" : 2000,
    "jms-queue" : null,
    "jms-topic" : null,
    "jmx-domain" : "org.hornetq",
    "jmx-management-enabled" : false,
    "journal-buffer-size" : null,
    "journal-buffer-timeout" : null,
    "journal-compact-min-files" : 10,
    "journal-compact-percentage" : 30,
    "journal-file-size" : 102400,
    "journal-max-io" : null,
    "journal-min-files" : 2,
    "journal-sync-non-transactional" : true,
    "journal-sync-transactional" : true,
    "journal-type" : "ASYNCIO",
    "live-connector-ref" : null,
    "log-journal-write-rate" : false,
    "management-address" : "jms.queue.hornetq.management",
    "management-notification-address" : "hornetq.notifications",
    "memory-measure-interval" : -1,
    "memory-warning-threshold" : 25,
    "message-counter-enabled" : false,
    "message-counter-max-day-history" : 10,
    "message-counter-sample-period" : 10000,
    "message-expiry-scan-period" : 30000,
    "message-expiry-thread-priority" : 3,
    "page-max-concurrent-io" : 5,
    "path" : null,
    "perf-blast-pages" : -1,
    "persist-delivery-count-before-delivery" : false,
    "persist-id-cache" : true,
    "persistence-enabled" : true,
    "queue" : null,
    "remoting-interceptors" : null,
    "run-sync-speed-test" : false,
    "scheduled-thread-pool-max-size" : 5,
    "security-domain" : "other",
    "security-enabled" : true,
    "security-invalidation-interval" : 10000,
    "server-dump-interval" : -1,
    "shared-store" : true,
    "thread-pool-max-size" : 30,
    "transaction-timeout" : 300000,
    "transaction-timeout-scan-period" : 1000,
    "wild-card-routing-enabled" : true,
    "address-setting" : {"#" : {
        "address-full-policy" : "BLOCK",
        "dead-letter-address" : "jms.queue.DLQ",
        "expiry-address" : "jms.queue.ExpiryQueue",
        "last-value-queue" : false,
        "max-delivery-attempts" : 10,
        "max-size-bytes" : 10485760,
        "message-counter-history-day-limit" : 10,
        "page-max-cache-size" : 5,
        "page-size-bytes" : 10485760,
        "redelivery-delay" : 0,
        "redistribution-delay" : -1,
        "send-to-dla-on-no-route" : false
    }},
    "connection-factory" : {
        "InVmConnectionFactory" : {
            "auto-group" : false,
            "block-on-acknowledge" : false,
            "block-on-durable-send" : true,
            "block-on-non-durable-send" : false,
            "cache-large-message-client" : false,
            "call-timeout" : 30000,
            "client-failure-check-period" : 30000,
            "client-id" : null,
            "compress-large-messages" : false,
            "confirmation-window-size" : -1,
            "connection-load-balancing-policy-class-name" : "org.hornetq.api.core.client.loadbalance.RoundRobinConnectionLoadBalancingPolicy",
            "connection-ttl" : 60000,
            "connector" : {"in-vm" : null},
            "consumer-max-rate" : -1,
            "consumer-window-size" : 1048576,
            "discovery-group-name" : null,
            "discovery-initial-wait-timeout" : null,
            "dups-ok-batch-size" : 1048576,
            "entries" : ["java:/ConnectionFactory"],
            "factory-type" : null,
            "failover-on-initial-connection" : false,
            "failover-on-server-shutdown" : null,
            "group-id" : null,
            "ha" : false,
            "max-retry-interval" : 2000,
            "min-large-message-size" : 102400,
            "pre-acknowledge" : false,
            "producer-max-rate" : -1,
            "producer-window-size" : 65536,
            "reconnect-attempts" : 0,
            "retry-interval" : 2000,
            "retry-interval-multiplier" : 1.0,
            "scheduled-thread-pool-max-size" : 5,
            "thread-pool-max-size" : 30,
            "transaction-batch-size" : 1048576,
            "use-global-pools" : true
        },
        "RemoteConnectionFactory" : {
            "auto-group" : false,
            "block-on-acknowledge" : false,
            "block-on-durable-send" : true,
            "block-on-non-durable-send" : false,
            "cache-large-message-client" : false,
            "call-timeout" : 30000,
            "client-failure-check-period" : 30000,
            "client-id" : null,
            "compress-large-messages" : false,
            "confirmation-window-size" : -1,
            "connection-load-balancing-policy-class-name" : "org.hornetq.api.core.client.loadbalance.RoundRobinConnectionLoadBalancingPolicy",
            "connection-ttl" : 60000,
            "connector" : {"netty" : null},
            "consumer-max-rate" : -1,
            "consumer-window-size" : 1048576,
            "discovery-group-name" : null,
            "discovery-initial-wait-timeout" : null,
            "dups-ok-batch-size" : 1048576,
            "entries" : ["java:jboss/exported/jms/RemoteConnectionFactory"],
            "factory-type" : null,
            "failover-on-initial-connection" : false,
            "failover-on-server-shutdown" : null,
            "group-id" : null,
            "ha" : false,
            "max-retry-interval" : 2000,
            "min-large-message-size" : 102400,
            "pre-acknowledge" : false,
            "producer-max-rate" : -1,
            "producer-window-size" : 65536,
            "reconnect-attempts" : 0,
            "retry-interval" : 2000,
            "retry-interval-multiplier" : 1.0,
            "scheduled-thread-pool-max-size" : 5,
            "thread-pool-max-size" : 30,
            "transaction-batch-size" : 1048576,
            "use-global-pools" : true
        }
    },
    "in-vm-acceptor" : {"in-vm" : {
        "param" : null,
        "server-id" : 0
    }},
    "in-vm-connector" : {"in-vm" : {
        "param" : null,
        "server-id" : 0
    }},
    "pooled-connection-factory" : {"hornetq-ra" : {
        "auto-group" : false,
        "block-on-acknowledge" : false,
        "block-on-durable-send" : true,
        "block-on-non-durable-send" : false,
        "cache-large-message-client" : false,
        "call-timeout" : 30000,
        "client-failure-check-period" : 30000,
        "client-id" : null,
        "confirmation-window-size" : -1,
        "connection-load-balancing-policy-class-name" : "org.hornetq.api.core.client.loadbalance.RoundRobinConnectionLoadBalancingPolicy",
        "connection-ttl" : 60000,
        "connector" : {"in-vm" : null},
        "consumer-max-rate" : -1,
        "consumer-window-size" : 1048576,
        "discovery-group-name" : null,
        "discovery-initial-wait-timeout" : null,
        "dups-ok-batch-size" : 1048576,
        "entries" : ["java:/JmsXA"],
        "failover-on-initial-connection" : false,
        "failover-on-server-shutdown" : null,
        "group-id" : null,
        "ha" : false,
        "jndi-params" : null,
        "max-pool-size" : -1,
        "max-retry-interval" : 2000,
        "min-large-message-size" : 102400,
        "min-pool-size" : -1,
        "password" : null,
        "pre-acknowledge" : false,
        "producer-max-rate" : -1,
        "producer-window-size" : 65536,
        "reconnect-attempts" : 0,
        "retry-interval" : 2000,
        "retry-interval-multiplier" : 1.0,
        "scheduled-thread-pool-max-size" : 5,
        "setup-attempts" : null,
        "setup-interval" : null,
        "thread-pool-max-size" : 30,
        "transaction" : "xa",
        "transaction-batch-size" : 1048576,
        "use-global-pools" : true,
        "use-jndi" : null,
        "use-local-tx" : null,
        "user" : null
    }},
    "remote-acceptor" : {
        "netty" : {
            "param" : null,
            "socket-binding" : "messaging"
        },
        "netty-throughput" : {
            "socket-binding" : "messaging-throughput",
            "param" : {
                "batch-delay" : {"value" : "50"},
                "direct-deliver" : {"value" : "false"}
            }
        }
    },
    "remote-connector" : {
        "netty" : {
            "param" : null,
            "socket-binding" : "messaging"
        },
        "netty-throughput" : {
            "socket-binding" : "messaging-throughput",
            "param" : {"batch-delay" : {"value" : "50"}}
        }
    },
    "security-setting" : {"#" : {"role" : {"guest" : {
        "consume" : true,
        "create-durable-queue" : false,
        "create-non-durable-queue" : true,
        "delete-durable-queue" : false,
        "delete-non-durable-queue" : true,
        "manage" : false,
        "send" : true
    }}}}
}

Getting “cluster-user” attribute details of HornetQ server:

wget -O out.txt "http://admin:admin123@localhost:9990/management/subsystem/messaging/hornetq-server/default?operation=attribute&name=cluster-user"

"HORNETQ.CLUSTER.ADMIN.USER"

Loggign Subsystem Related Informations

Getting “console-handler” CONSOLE logger level information

wget -O out.txt "http://admin:admin123@localhost:9990/management/subsystem/logging/console-handler/CONSOLE?operation=attribute&name=level"

"INFO"

Getting “console-handler” CONSOLE logger “autoflush” information

wget -O out.txt "http://admin:admin123@localhost:9990/management/subsystem/logging/console-handler/CONSOLE?operation=attribute&name=autoflush"

true

Getting console-handler’s complete config informations

wget -O out.txt "http://admin:admin123@localhost:9990/management/subsystem/logging/console-handler/CONSOLE?operation=resource&recursive&json.pretty"

{
    "autoflush" : true,
    "encoding" : null,
    "filter" : null,
    "formatter" : "%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n",
    "level" : "INFO",
    "target" : "System.out"
}

Getting articular logger’s like”org.apache.tomcat.util.modeler” information:

wget -O out.txt "http://admin:admin123@localhost:9990/management/subsystem/logging/logger/org.apache.tomcat.util.modeler?operation=resource&recursive&json.pretty"

{
    "filter" : null,
    "handlers" : null,
    "level" : "WARN",
    "use-parent-handlers" : true
}

Getting “periodic-rotating-file-handler” formatter information:

wget -O out.txt "http://admin:admin123@localhost:9990/management/subsystem/logging/periodic-rotating-file-handler/FILE?operation=attribute&name=formatter"

"%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"

Getting “” suffix information:

wget -O out.txt "http://admin:admin123@localhost:9990/management/subsystem/logging/periodic-rotating-file-handler/FILE?operation=attribute&name=suffix"

".yyyy-MM-dd"

Getting “” complete config infromations

wget -O out.txt "http://admin:admin123@localhost:9990/management/subsystem/logging/periodic-rotating-file-handler/FILE?operation=resource&recursive&json.pretty"

{
    "append" : true,
    "autoflush" : true,
    "encoding" : null,
    "file" : {
        "relative-to" : "jboss.server.log.dir",
        "path" : "server.log"
    },
    "filter" : null,
    "formatter" : "%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n",
    "level" : null,
    "suffix" : ".yyyy-MM-dd"
}

Getting “root-logger” logging level information:

wget -O out.txt "http://admin:admin123@localhost:9990/management/subsystem/logging/root-logger/ROOT?operation=attribute&name=level"

"INFO"

.
.
Thanks :)
MiddlewareMagic Team


Accessing JBoss Management Console over Https in JBossAS7.1.2

Hi,

In this demonstration we will see how to access the JBoss Management Console over HTTPS in a secured manner, As it is desired in many production/secure environment to access the JBoss Management Console over https sothat the communication will be in SSL encrypted format. So in this example we will see how to configure the JBoss AS7.1.2 sothat we can connect to JBoss Management Console via SSL port 9991 (management-console-https socket binding).

Step1). First if all we will create Security certificates with the help of JDK provided utility “keytool”, So make sure that the JDK’s bin directory is added in your shell/command prompts PATH variable like following (We are creating the “chap8.keystore” inside “$JBOSS_HOME/standalone/configuration” directory):

.
[userone@localhost ~]$ cd /home/userone/jboss-as-7.1.2.Final/standalone/configuration/

[userone@localhost configuration]$ export PATH=/home/userone/MyJdks/jdk1.6.0_21/bin:$PATH

[userone@localhost configuration] keytool -genkey -keystore chap8.keystore -storepass rmi+ssl -keypass rmi+ssl -keyalg RSA -alias chapter8 -validity 3650 -dname "cn=chapter8 example,ou=admin book,dc=jboss,dc=org"
.

Step2). Make sure that the JBoss AS7.1.2 is running, In our case we started JBossAS7.1.2 “standalone-full.xml” profile.

.
[userone@localhost bin]$ ./standalone.sh -c standalone-full.xml
.

Step3). Now We will configure the <server-identities> for ManagementRealm By specifying the SSL informations. We will use the following CLI Commands in order to achieve the goal

[userone@localhost bin]$ cd /home/userone/jboss-as-7.1.2.Final/bin

[userone@localhost bin]$ ./jboss-cli.sh -c --controller=localhost:9999
.
[standalone@localhost:9999 /] /core-service=management/security-realm=ManagementRealm/server-identity=ssl:add(keystore-password="rmi+ssl", keystore-path="chap8.keystore", keystore-relative-to="jboss.server.config.dir", alias="chapter8",protocol="TLSv1")
{
    "outcome" => "success",
    "response-headers" => {
        "operation-requires-reload" => true,
        "process-state" => "reload-required"
    }
}

[standalone@localhost:9999 /] /socket-binding-group=standard-sockets/socket-binding=management-console-https/:add(port=9991,interface=management,fixed-port=false)
{
    "outcome" => "success",
    "response-headers" => {"process-state" => "reload-required"}
}

[standalone@localhost:9999 /] /core-service=management/management-interface=http-interface/:write-attribute(name=secure-socket-binding,value=management-console-https)
{
    "outcome" => "success",
    "response-headers" => {"process-state" => "reload-required"}
}

[standalone@localhost:9999 /] /core-service=management/management-interface=http-interface/:undefine-attribute(name=socket-binding)
{
    "outcome" => "success",
    "response-headers" => {"process-state" => "reload-required"}
}
.

Once your above CLI command is executed successfully you will notice the following in your JBossAS 7.1.2 configuration file “standalone-full.xml”:


    <management>
        <security-realms>
            <security-realm name="ManagementRealm">
                <server-identities>
                    <ssl protocol="TLSv1">
                        <keystore path="chap8.keystore" relative-to="jboss.server.config.dir" keystore-password="rmi+ssl" alias="chapter8"/>
                    </ssl>
                </server-identities>
                <authentication>
                    <local default-user="$local"/>
                    <properties path="mgmt-users.properties" relative-to="jboss.server.config.dir"/>
                </authentication>
            </security-realm>
            <security-realm name="ApplicationRealm">
                <authentication>
                    <local default-user="$local" allowed-users="*"/>
                    <properties path="application-users.properties" relative-to="jboss.server.config.dir"/>
                </authentication>
                <authorization>
                    <properties path="application-roles.properties" relative-to="jboss.server.config.dir"/>
                </authorization>
            </security-realm>
        </security-realms>
        <management-interfaces>
            <native-interface security-realm="ManagementRealm">
                <socket-binding native="management-native"/>
            </native-interface>
            <http-interface security-realm="ManagementRealm">
                <socket-binding https="management-console-https"/>
            </http-interface>
        </management-interfaces>
    </management>
    .
    .
    .
    .
    <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
        <socket-binding name="management-native" interface="management" port="${jboss.management.native.port:9999}"/>
        <socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
        <socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9443}"/>
         .
         .
        <socket-binding name="management-console-https" interface="management" port="9991" fixed-port="false"/>
         .
         .
        <outbound-socket-binding name="mail-smtp">
            <remote-destination host="localhost" port="25"/>
        </outbound-socket-binding>
    </socket-binding-group>

Step4). Now restart your JBoss AS 7.1.2 again as following:

.
[userone@localhost bin]$ ./standalone.sh -c standalone-full.xml
.

Step5). Now Try to access the JBoss Management Console with the following URL:

https://localhost:9991/console

Achieving same in Domain Mode

In your “master” Host “$JBOSS_HOME/domain/configuration/host.xml” you will need to define the tag as following:

            <security-realm name="ManagementRealm">
                <server-identities>
                    <ssl protocol="TLSv1">
                        <keystore path="chap8.keystore" relative-to="jboss.domain.config.dir" keystore-password="rmi+ssl" alias="chapter8"/>
                    </ssl>
                </server-identities>
                <authentication>
                    <local default-user="$local"/>
                    <properties path="mgmt-users.properties" relative-to="jboss.domain.config.dir"/>
                </authentication>
            </security-realm>

Alter the “http-interface” as following in the same “master” host.xml file.

        <management-interfaces>
            <native-interface security-realm="ManagementRealm">
                <socket interface="management" port="${jboss.management.native.port:9999}"/>
            </native-interface>
            <http-interface security-realm="ManagementRealm">
                <socket interface="management" secure-port="9991"/>
            </http-interface>
        </management-interfaces>

Or you can use the following command to achieve the same:

/host=master/core-service=management/management-interface=http-interface/:write-attribute(name=secure-port,value=9991)
/host=master/core-service=management/management-interface=http-interface/:undefine-attribute(name=port)

Restart JBoss EAP6 and then check the CONSOLE output to see if you find the following:

[Host Controller] 10:00:04,445 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015952: Admin console listening on https://127.0.0.1:9991

.
.
Thanks :)
MiddlewareMagic Team


Enabling SSL Communication for the Native Management Interface using CLI

Hi,

In this demonstration we will see how to configure Native Management Interface to use the SSL, As it is desired in many production/secure environment to access the JBoss via CLI utility over SSL sothat the communication will be in SSL encrypted format. So in this example we will see how to configure the JBoss AS7.1.2 sothat we can connect to it via SSL port 9443 (management-https socket binding).

Step1). First if all we will create Security certificates with the help of JDK provided utility “keytool”, So make sure that the JDK’s bin directory is added in your shell/command prompts PATH variable like following (We are creating the “chap8.keystore” inside “$JBOSS_HOME/standalone/configuration” directory):

.
[userone@localhost ~]$ cd /home/userone/jboss-as-7.1.2.Final/standalone/configuration/

[userone@localhost configuration]$ export PATH=/home/userone/MyJdks/jdk1.6.0_21/bin:$PATH

[userone@localhost configuration] keytool -genkey -keystore chap8.keystore -storepass rmi+ssl -keypass rmi+ssl -keyalg RSA -alias chapter8 -validity 3650 -dname "cn=chapter8 example,ou=admin book,dc=jboss,dc=org"
.

Step2). Make sure that the JBoss AS7.1.2 is running, In our case we started JBossAS7.1.2 “standalone-full.xml” profile.

.
[userone@localhost bin]$ ./standalone.sh -c standalone-full.xml
.

Step3). Now We will configure the <server-identities> for ManagementRealm By specifying the SSL informations. We will use the following CLI Commands in order to achieve the goal

[userone@localhost bin]$ cd /home/userone/jboss-as-7.1.2.Final/bin

[userone@localhost bin]$ ./jboss-cli.sh -c --controller=localhost:9999

[standalone@localhost:9999 /] /core-service=management/security-realm=ManagementRealm/server-identity=ssl:add(keystore-password="rmi+ssl", keystore-path="chap8.keystore", keystore-relative-to="jboss.server.config.dir", alias="chapter8",protocol="TLSv1")

{
    "outcome" => "success",
    "response-headers" => {
        "operation-requires-reload" => true,
        "process-state" => "reload-required"
    }
}

[standalone@localhost:9999 /] /core-service=management/management-interface=native-interface/:write-attribute(name=socket-binding,value=management-https)

{
    "outcome" => "success",
    "response-headers" => {
        "operation-requires-reload" => true,
        "process-state" => "reload-required"
    }
}

Once your above CLI command is executed successfully you will notice the following in your JBossAS 7.1.2 configuration file “standalone-full.xml”:


    <management>
        <security-realms>
            <security-realm name="ManagementRealm">
                <server-identities>
                    <ssl protocol="TLSv1">
                        <keystore path="chap8.keystore" relative-to="jboss.server.config.dir" keystore-password="rmi+ssl" alias="chapter8"/>
                    </ssl>
                </server-identities>
                <authentication>
                    <local default-user="$local"/>
                    <properties path="mgmt-users.properties" relative-to="jboss.server.config.dir"/>
                </authentication>
            </security-realm>
            <security-realm name="ApplicationRealm">
                <authentication>
                    <local default-user="$local" allowed-users="*"/>
                    <properties path="application-users.properties" relative-to="jboss.server.config.dir"/>
                </authentication>
                <authorization>
                    <properties path="application-roles.properties" relative-to="jboss.server.config.dir"/>
                </authorization>
            </security-realm>
        </security-realms>
        <management-interfaces>
            <native-interface security-realm="ManagementRealm">
                <socket-binding native="management-https"/>
            </native-interface>
            <http-interface security-realm="ManagementRealm">
                <socket-binding http="management-http"/>
            </http-interface>
        </management-interfaces>
    </management>

Step4). Now restart your JBoss AS 7.1.2 again as following:
-Djavax.net.debug=all This System property will give us more details about the SSL Communication so we enabled it just to varify if the SSL configuration is working properly or not.

.
[userone@localhost bin]$ ./standalone.sh -c standalone-full.xml  -Djavax.net.debug=all
.

Step5). Now there will be a slignt change in the way we used to connect to the JBoss Via CLI command, It will be happening via “management-https” (9443) now as following:

.
[userone@localhost bin]$ ./jboss-cli.sh -c --controller=localhost:9443
Unable to connect due to unrecognised server certificate
Subject    - CN=chapter8 example,OU=admin book,DC=jboss,DC=org
Issuer     - CN=chapter8 example, OU=admin book, DC=jboss, DC=org
Valid From - Sat Sep 15 20:13:01 IST 2012
Valid To   - Tue Sep 13 20:13:01 IST 2022
MD5 : 20:c7:41:56:34:c2:15:49:e3:95:84:ab:19:fc:1f:ca
SHA1 : c9:c0:b4:8b:82:18:6b:3d:35:c3:1e:26:7f:52:e5:8c:ab:93:35:78

Accept certificate? [N]o, [T]emporarily, [P]ermenantly : T
[standalone@localhost:9443 /] 

.

.
.
Thanks :)
MiddlewareMagic Team


Invoking EJBs from One JBossAS7 to another JBossAS7

Hi,

In our previous examples we have seen how to invoke an EJB which is deployed on JBoss AS7 server from a standalone java client (http://middlewaremagic.com/jboss/?p=1466). However in this example we will see how to invoke an EJB from another EJB when both the EJBs are deployed on different JBoss instances. This is different from invoking the EJBs from a remote standalone client.

In order to achieve this we will need to create an "remote-outbound-connection" on the "ClientServer" (A Server which has the CallerEJB). The "remote-outbound-connection" which will use the newly created "outbound-socket-binding" (pointing to the EJB remoting connector of the "Destination Server")

Reference Document:
https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+server+instance

Points we will discuss here:

Point-1) . In JBossAS7 how to create/delete Server-Groups, JBoss Servers, Outbound-Connections and Security realm using Batch Mode of CLI.

Point-2) . We will see how to configure a Server-Identity for the JBoss to JBoss EJB communication purpose.

Point-3) . We will see how to invoke an EJB from a standalone java client.

Point-4) . We will see how One EJB deployed on the Client Server (JBossServerOne) can invoke an EJB which is deployed on the destination server (JBossServerTwo)

Point-5) . The source code of this demo along with the “domain.xml” & “host.xml” including the Example source is present in the github repository.
https://github.com/jaysensharma/MiddlewareMagicDemos/tree/master/EJB_Server_to_Server

Point-6) . We will see how to make use of “$EAR/META-INF/jboss-ejb-client.xml” file. Like following:

<jboss-ejb-client xmlns="urn:jboss:ejb-client:1.0">
    <client-context>
        <ejb-receivers>
            <remoting-ejb-receiver outbound-connection-ref="OutboundEJB_ConnectionOne"/>
        </ejb-receivers>
    </client-context>
</jboss-ejb-client>
EJB_to_EJB_Call_Between_JBossAS7_Servers

EJB_to_EJB_Call_Between_JBossAS7_Servers

Creating a User which will be available in Destination Server.

Step-1) Create a User with username “ejbUserOne” and password as “ejbPasswordOne” in the client Server.

[userone@localhost bin]$ ./add-user.sh 

What type of user do you wish to add?
 a) Management User (mgmt-users.properties)
 b) Application User (application-users.properties)
(a): b

Enter the details of the new user to add.
Realm (ApplicationRealm) : ApplicationRealm
Username : ejbUserOne
Password : ejbPasswordOne
Re-enter Password : ejbPasswordOne
What roles do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[  ]: ejbRole
About to add user 'ejbUserOne' for realm 'ApplicationRealm'
Is this correct yes/no? yes
Added user 'ejbUserOne' to file '/home/userone/jboss-as-7.1.2.Final/standalone/configuration/application-users.properties'
Added user 'ejbUserOne' to file '/home/userone/jboss-as-7.1.2.Final/domain/configuration/application-users.properties'
Added user 'ejbUserOne' with roles ejbRole to file '/home/userone/jboss-as-7.1.2.Final/standalone/configuration/application-roles.properties'
Added user 'ejbUserOne' with roles ejbRole to file '/home/userone/jboss-as-7.1.2.Final/domain/configuration/application-roles.properties'
Is this new user going to be used for one AS process to connect to another AS process e.g. slave domain controller?
yes/no? yes

To represent the user add the following to the server-identities definition <secret value="ZWpiUGFzc3dvcmRPbmU=" />

NOTE: The “ejbUserOne” which we created in destination Server “JBossServerTwo” has generated a secret value “ZWpiUGFzc3dvcmRPbmU=” which we need to add in the “host.xml” of the Client JBoss where we will deploy the CallerBean.

In our case for our simplicity we will create the same user “ejbUserOne” in the clientServer “JBossServerOne” as well sothat the Standalone client also can use the same username & password in order to invoke the CallerBean deployed on Client Server “JBossServerOne”

Step-2) Create a directory somewhere in your file system like “/home/userone/jboss-as-7.1.2.Final/domain/EJB_Server_to_Server/Server_To_Server_EJB3_Remote_Lookup/” and place the CLI Batch file “ConfigureResources.cli” inside the above directory which we will use oin order to configure various resources on the JBoss quickly.

NOTE: In the following script you will need to replace the value secret key value (line-43) “ZWpiUGFzc3dvcmRPbmU=” which is generated in Step-1 (if you want to create a different username)

#################################################################
# Removing all Unnecessary & Default Configurations from Server
#################################################################
batch
# Stopping all the default servers, and removing default groups & servers
/host=master/server-config=server-one:stop(blocking=true)
/host=master/server-config=server-two:stop(blocking=true)

/host=master/server-config=server-one:remove
/host=master/server-config=server-two:remove
/host=master/server-config=server-three:remove
/server-group=main-server-group:remove
/server-group=other-server-group:remove

#################################################################
# Disabling the "$local" authentication from the Configuration
#################################################################
/host=master/core-service=management/security-realm=ApplicationRealm/authentication=local:remove

#################################################################
# EJB server to server call related configuration
#################################################################
/socket-binding-group=full-sockets/remote-destination-outbound-socket-binding=OutboundEJBOne:add(host=localhost, port=4647)

# adding the outbound connections to the remoting subsystem of the full-profile
/profile=full/subsystem=remoting/remote-outbound-connection=OutboundEJB_ConnectionOne:add(outbound-socket-binding-ref=remote-ejb, security-realm=ejbRealmOne, username=ejbUserOne)
/profile=full/subsystem=remoting/remote-outbound-connection=OutboundEJB_ConnectionOne/property=SASL_POLICY_NOANONYMOUS:add(value=false)
/profile=full/subsystem=remoting/remote-outbound-connection=OutboundEJB_ConnectionOne/property=SSL_ENABLED:add(value=false)

/socket-binding-group=full-sockets/remote-destination-outbound-socket-binding=remote-ejb:add(host=localhost, port=4647)

#################################################################
# Security-Realm configuration
#################################################################
#### using    add-user.sh   create a user with name "ejbUserOne"  and password  as "ejbPasswordOne" on the Client Server
#### Press "yes" When the user creation script asks:
#### Is this new user going to be used for one AS process to connect to another AS process e.g. slave domain controller?
####  it will generate an encrypted password., Use it in the below section.

/host=master/core-service=management/security-realm=ejbRealmOne:add()
/host=master/core-service=management/security-realm=ejbRealmOne/server-identity=secret:add(value=ZWpiUGFzc3dvcmRPbmU=)

#################################################################
# Configuring New Servers & Server Groups
#################################################################
/server-group=GroupOne:add(profile=full,socket-binding-group=full-sockets)
/server-group=GroupOne/jvm=default:add(permgen-size=64m, max-permgen-size=128m)
/host=master/server-config=JBossServerOne:add(auto-start=true, group=GroupOne, socket-binding-port-offset=100)

/server-group=GroupTwo:add(profile=full,socket-binding-group=full-sockets)
/server-group=GroupTwo/jvm=default:add(permgen-size=64m, max-permgen-size=128m)
/host=master/server-config=JBossServerTwo:add(auto-start=true, group=GroupTwo, socket-binding-port-offset=200)
run-batch

Step-3) Now start your JBoss Domain controller using the “domain.sh” script.

Step-4) Open a terminal and the move inside the “$JBOSS_HOME/bin” directory from where we will execute the above CLI Batch file in order to configure various resources on our JBoss.

[userone@localhost bin]$ ./jboss-cli.sh -c --controller=localhost:9999 --file=/home/userone/jboss-as-7.1.2.Final/domain/EJB_Server_to_Server/ConfigureResources.cli

Output will be something like following:

#1 /host=master/server-config=server-one:stop(blocking=true)
#2 /host=master/server-config=server-two:stop(blocking=true)

#3 /host=master/server-config=server-one:remove
#4 /host=master/server-config=server-two:remove
#5 /host=master/server-config=server-three:remove

#6 /server-group=main-server-group:remove
#7 /server-group=other-server-group:remove

#8 /host=master/core-service=management/security-realm=ApplicationRealm/authentication=local:remove

#9 /socket-binding-group=full-sockets/remote-destination-outbound-socket-binding=OutboundEJBOne:add(host=localhost, port=4647)

#10 /profile=full/subsystem=remoting/remote-outbound-connection=OutboundEJB_ConnectionOne:add(outbound-socket-binding-ref=remote-ejb, security-realm=ejbRealmOne, username=ejbUserOne)
#11 /profile=full/subsystem=remoting/remote-outbound-connection=OutboundEJB_ConnectionOne/property=SASL_POLICY_NOANONYMOUS:add(value=false)
#12 /profile=full/subsystem=remoting/remote-outbound-connection=OutboundEJB_ConnectionOne/property=SSL_ENABLED:add(value=false)

#13 /socket-binding-group=full-sockets/remote-destination-outbound-socket-binding=remote-ejb:add(host=localhost, port=4647)

#14 /host=master/core-service=management/security-realm=ejbRealmOne:add()
#15 /host=master/core-service=management/security-realm=ejbRealmOne/server-identity=secret:add(value=ZWpiUGFzc3dvcmRPbmU=)

#16 /server-group=GroupOne:add(profile=full,socket-binding-group=full-sockets)
#17 /server-group=GroupOne/jvm=default:add(permgen-size=64m, max-permgen-size=128m)

#18 /host=master/server-config=JBossServerOne:add(auto-start=true, group=GroupOne, socket-binding-port-offset=100)
#19 /server-group=GroupTwo:add(profile=full,socket-binding-group=full-sockets)
#20 /server-group=GroupTwo/jvm=default:add(permgen-size=64m, max-permgen-size=128m)
#21 /host=master/server-config=JBossServerTwo:add(auto-start=true, group=GroupTwo, socket-binding-port-offset=200)

The batch executed successfully.

Deploying and running the code:

You can download the TestCase from the following github repository. https://github.com/jaysensharma/MiddlewareMagicDemos/tree/master/EJB_Server_to_Server

Place the “EJB_Server_to_Server” directory somewhere in your file system thich contains the following:

├── domain_Configurations
│   ├── application-roles.properties
│   ├── application-users.properties
│   ├── domain.xml
│   ├── host.xml
│   └── mgmt-users.properties

├── EJB_2_EJB_Call_Between_Servers.JPG

└── Server_To_Server_EJB3_Remote_Lookup
    ├── build
    │   ├── ejbOneEAR.ear
    │   ├── ejbTwoEAR.ear
    │   └── remoteEJBClient.jar
    ├── build.xml
    ├── ConfigureResources.cli
    └── src
        ├── client
        │   ├── CallerRemote.java
        │   ├── Client.java
        │   └── jboss-ejb-client.properties
        ├── ejbOneEAR
        │   ├── application.xml
        │   ├── CallerBean.java
        │   ├── CallerRemote.java
        │   ├── jboss-ejb-client.xml
        │   └── TestRemote.java
        └── ejbTwoEAR
            ├── application.xml
            ├── TestBean.java
            └── TestRemote.java

Code snippet of “CallerBean.java”

package ejb.one;
import javax.ejb.*;
import javax.naming.*;
import java.util.*;
import ejb.two.TestRemote;
@Stateless
@Remote(CallerRemote.class)
public class CallerBean implements CallerRemote
 {
     public String testMethod(String name)
	    {
                   String result="";
		   System.out.println("\n\n\t[CallerBean] Bean's testMethod(String name) called....");
                   System.out.println("\n\n\t[CallerBean] Is Now calling the TestBean deployed on another JBoss Instance.");
                   try {
                         Hashtable<String,String> props = new Hashtable<String,String>();
                         props.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

                         /******* FOLLOWING  CODE IS NOT NEEDED  ********/
                         //props.put(Context.PROVIDER_URL, "remote://localhost:4647");
                         //props.put(Context.SECURITY_PRINCIPAL, "ejbUserOne");
                         //props.put(Context.SECURITY_CREDENTIALS, "ejbPasswordOne");

                         Context context = new javax.naming.InitialContext(props);
                         String jndiName="ejb:" + "ejbTwoEAR/remoteEjbTwo/TestBean!ejb.two.TestRemote";
                         TestRemote remote = (TestRemote) context.lookup(jndiName);

                         result = remote.helloWorld("TestMessage For TestBean: MiddlewareMagic");
                         System.out.println("[CallerBean] Received result from TestBean: " + result);
                        }
                    catch (Exception e)
                        {
                         throw new RuntimeException(e);
                        }
		   return "[CallerBean] returned Hello "+name+"\tTestBean: " + result;
	    }
 }

Now open a Terminal where we need to set the PATH like following sothat ANT is available in the path and then compile and run the program:

For Unix Based OS:
export PATH=/home/userone/jdk1.6.0_21/bin:/home/userone/org.apache.ant_1.8.0/bin:$PATH

For Windows Based OS:
set PATH=C:/jdk1.6.0_21/bin;C:/org.apache.ant_1.8.0/bin;%PATH%

Compile the program as following:


[userone@localhost Server_To_Server_EJB3_Remote_Lookup]$ cd /home/userone/jboss-as-7.1.2.Final/domain/EJB_Server_to_Server/Server_To_Server_EJB3_Remote_Lookup
[userone@localhost Server_To_Server_EJB3_Remote_Lookup]$ ant
Buildfile: build.xml

build_ear_one:
    [mkdir] Created dir: /home/userone/jboss-as-7.1.2.Final/domain/EJB_Server_to_Server/Server_To_Server_EJB3_Remote_Lookup/tmp
    [javac] Compiling 3 source files to /home/userone/jboss-as-7.1.2.Final/domain/EJB_Server_to_Server/Server_To_Server_EJB3_Remote_Lookup/tmp
      [jar] Building jar: /home/userone/jboss-as-7.1.2.Final/domain/EJB_Server_to_Server/Server_To_Server_EJB3_Remote_Lookup/tmp/remoteEjbOne.jar
    [mkdir] Created dir: /home/userone/jboss-as-7.1.2.Final/domain/EJB_Server_to_Server/Server_To_Server_EJB3_Remote_Lookup/tmp/META-INF
     [copy] Copying 2 files to /home/userone/jboss-as-7.1.2.Final/domain/EJB_Server_to_Server/Server_To_Server_EJB3_Remote_Lookup/tmp/META-INF
      [jar] Building jar: /home/userone/jboss-as-7.1.2.Final/domain/EJB_Server_to_Server/Server_To_Server_EJB3_Remote_Lookup/tmp/ejbOneEAR.ear
   [delete] Deleting: /home/userone/jboss-as-7.1.2.Final/domain/EJB_Server_to_Server/Server_To_Server_EJB3_Remote_Lookup/tmp/remoteEjbOne.jar
     [copy] Copying 1 file to /home/userone/jboss-as-7.1.2.Final/domain/EJB_Server_to_Server/Server_To_Server_EJB3_Remote_Lookup/build
   [delete] Deleting: /home/userone/jboss-as-7.1.2.Final/domain/EJB_Server_to_Server/Server_To_Server_EJB3_Remote_Lookup/tmp/ejbOneEAR.ear

build_ear_two:
   [delete] Deleting directory /home/userone/jboss-as-7.1.2.Final/domain/EJB_Server_to_Server/Server_To_Server_EJB3_Remote_Lookup/tmp
    [mkdir] Created dir: /home/userone/jboss-as-7.1.2.Final/domain/EJB_Server_to_Server/Server_To_Server_EJB3_Remote_Lookup/tmp
    [javac] Compiling 2 source files to /home/userone/jboss-as-7.1.2.Final/domain/EJB_Server_to_Server/Server_To_Server_EJB3_Remote_Lookup/tmp
      [jar] Building jar: /home/userone/jboss-as-7.1.2.Final/domain/EJB_Server_to_Server/Server_To_Server_EJB3_Remote_Lookup/tmp/remoteEjbTwo.jar
    [mkdir] Created dir: /home/userone/jboss-as-7.1.2.Final/domain/EJB_Server_to_Server/Server_To_Server_EJB3_Remote_Lookup/tmp/META-INF
     [copy] Copying 1 file to /home/userone/jboss-as-7.1.2.Final/domain/EJB_Server_to_Server/Server_To_Server_EJB3_Remote_Lookup/tmp/META-INF
      [jar] Building jar: /home/userone/jboss-as-7.1.2.Final/domain/EJB_Server_to_Server/Server_To_Server_EJB3_Remote_Lookup/tmp/ejbTwoEAR.ear
   [delete] Deleting: /home/userone/jboss-as-7.1.2.Final/domain/EJB_Server_to_Server/Server_To_Server_EJB3_Remote_Lookup/tmp/remoteEjbTwo.jar
     [copy] Copying 1 file to /home/userone/jboss-as-7.1.2.Final/domain/EJB_Server_to_Server/Server_To_Server_EJB3_Remote_Lookup/build
   [delete] Deleting: /home/userone/jboss-as-7.1.2.Final/domain/EJB_Server_to_Server/Server_To_Server_EJB3_Remote_Lookup/tmp/ejbTwoEAR.ear

message:
     [echo] *******************  ******************* *********************
     [echo] ********** build/ejbOneEAR.ear Build Successfully **********
     [echo] ********** build/ejbTwoEAR.ear Build Successfully **********
     [echo] Deploy the above EARs on your desired servers using CLI script or using Manaagement Console
     [echo] *******************  ******************* *********************

all:

BUILD SUCCESSFUL
Total time: 2 seconds

Deploy & Run
Now deploy the “ejbOneEAR.ear” on “JBossServerOne”
And
deploy the “ejbTwoEAR.ear” on “JBossServerTwo”
And
Then Run the program as following:

[jsenshar@localhost Server_To_Server_EJB3_Remote_Lookup]$ ant run
Buildfile: build.xml

run:
   [delete] Deleting directory /home/userone/jboss-as-7.1.2.Final/domain/EJB_Server_to_Server/Server_To_Server_EJB3_Remote_Lookup/tmp
    [mkdir] Created dir: /home/userone/jboss-as-7.1.2.Final/domain/EJB_Server_to_Server/Server_To_Server_EJB3_Remote_Lookup/tmp
     [copy] Copying 1 file to /home/userone/jboss-as-7.1.2.Final/domain/EJB_Server_to_Server/Server_To_Server_EJB3_Remote_Lookup/tmp
    [javac] Compiling 2 source files to /home/userone/jboss-as-7.1.2.Final/domain/EJB_Server_to_Server/Server_To_Server_EJB3_Remote_Lookup/tmp
      [jar] Building jar: /home/userone/jboss-as-7.1.2.Final/domain/EJB_Server_to_Server/Server_To_Server_EJB3_Remote_Lookup/build/remoteEJBClient.jar
   [delete] Deleting directory /home/userone/jboss-as-7.1.2.Final/domain/EJB_Server_to_Server/Server_To_Server_EJB3_Remote_Lookup/tmp
     [java] Sep 10, 2012 2:20:25 AM org.xnio.Xnio <clinit>
     [java] INFO: XNIO Version 3.0.3.GA
     [java] Sep 10, 2012 2:20:25 AM org.xnio.nio.NioXnio <clinit>
     [java] INFO: XNIO NIO Implementation Version 3.0.3.GA
     [java] Sep 10, 2012 2:20:25 AM org.jboss.remoting3.EndpointImpl <clinit>
     [java] INFO: JBoss Remoting version 3.2.7.GA
     [java]
     [java] 	Got initial Context: javax.naming.InitialContext@671ff436
     [java] Sep 10, 2012 2:20:26 AM org.jboss.ejb.client.remoting.VersionReceiver handleMessage
     [java] INFO: EJBCLIENT000017: Received server version 1 and marshalling strategies [river]
     [java] Sep 10, 2012 2:20:26 AM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate
     [java] INFO: EJBCLIENT000013: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@62ebcdbb, receiver=Remoting connection EJB receiver [connection=Remoting connection <65efb4be>,channel=jboss.ejb,nodename=master:JBossServerOne]} on channel Channel ID 9a4598f0 (outbound) of Remoting connection 5d2aea3e to localhost/127.0.0.1:4547
     [java] Sep 10, 2012 2:20:26 AM org.jboss.ejb.client.remoting.ChannelAssociation$ResponseReceiver handleMessage
     [java] WARN: Unsupported message received with header 0xffffffff
     [java]
     [java] 	 remote.testMethod("MiddlewareMagic") = [CallerBean] returned Hello MiddlewareMagic	TestBean: [TestBean] returned Hello TestMessage For TestBean: MiddlewareMagic

BUILD SUCCESSFUL
Total time: 3 seconds

.
.
Thanks :)
MiddlewareMagic Team


How to get All Cluster Node Details using JMX in JBossAS7.1.2

Hi,

In JBoss EAP5 or AS6 or previous releases there was a concept of Partition Name which could be used to get the list of active cluster members, However in JBoss AS7 there is no concept of PartitionName rather in UDP mode the lustering happens based on the multicast asddress (Clustering can be achieved using TCP mode of communication as well). However many developers want to list the number of active members running as part of a JBoss As7 cluster programatically.

So in this example we will see how to write a simple JMX Code in order to access the cluster node details.

NOTE:

Point-1) . In JBoss AS7 until you deploy an application which requires clustering the JBoss will now start the clustering services. So in case of web Applications you should deploy at least one application on your Cluster members which has <distributable/> tag specified in it’s “WEB-INF/web.xml” file.

Point-2) . If you are using EJBs (and not web application to deploy on your cluster) make sure that the EJBs are clustered in order to start Cluster services. EJBs can be annotated using the following annotation in order to be clustered. @org.jboss.ejb3.annotation.Clustered

Point-3) . In Case of WebBased cluster the ObjectName of the Clustered instance will be “jgroups:type=channel,cluster=web” by default which can be used in the JMX Code in order to look query the MBean.

Point-3) . In Case of EJBBased cluster the ObjectName of the Clustered instance will be “jgroups:type=channel,cluster=ejb” by default which can be used in the JMX Code in order to look query the MBean.

Point-5) . If you are running your Server in Domain Mode then you should not use the Native Management Port 9999 in order to query the MBeans rather you should use the individual server’s Remoting Port 4447 in your JMX Code. by adding the following configuration on your JBoss Profile inside domain.xml you can allow accessing the MBeans via Remoting port 4447 rather than (native management port 9999)

<subsystem xmlns="urn:jboss:domain:jmx:1.1">
    <show-model value="true"/>
     <remoting-connector  use-management-endpoint="false" />
</subsystem>

Point-6) . If you are using Native Management Interface port 9999 in order to query your Cluster MBean (in standalone mode) then you should use the Credentials (username/password) for a user belonging to ManagementRealm, But in Domain mode as we need to connect to server using Remoting Port (4447) so you should create a ApplicationRealm user. in all the cluster Hosts.

Writing the JMX codce to query Cluster MBean

import java.util.Hashtable;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;

public class AS7ClusterView {
	public static void main(String[] args) throws Exception {

		String host = "10.10.10.10"; // Your JBoss Native Interface Bin Address default is localhost
		int port = 9999;             // management port     // In Domain Mode you should use  4447 port of individual server
		String urlString = "service:jmx:remoting-jmx://" + host + ":" + port;
		System.out.println(" \n\n\t**** urlString: " + urlString);
                String webClusterObjectName="jgroups:type=channel,cluster=\"web\"";
                //String ejbClusterObjectName="jgroups:type=channel,cluster=\"ejb\"";

		JMXServiceURL serviceURL = new JMXServiceURL(urlString);

		Hashtable h = new Hashtable();
		String[] credentials = new String[] { "admin", "admin123" };
		h.put("jmx.remote.credentials", credentials);

		JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceURL,null);
		MBeanServerConnection connection = jmxConnector.getMBeanServerConnection();
		ObjectName objectName = new ObjectName(webClusterObjectName);
		String clusterView = (String) connection.getAttribute(objectName,"View");
		Long receivedMessages = (Long) connection.getAttribute(objectName,"ReceivedMessages");
		String name = (String) connection.getAttribute(objectName, "Name");
		String clusterName = (String) connection.getAttribute(objectName,"ClusterName");

		System.out.println(" clusterView = " + clusterView);
		System.out.println(" receivedMessages = " + receivedMessages);
		System.out.println(" name = " + name);
		System.out.println(" clusterName = " + clusterName);
		jmxConnector.close();
	}

}

Now open a Terminal where we need to set the PATh and CLASSPATH like following and then compile and run the program:

For UNIX Based Operating System:

export PATH=/home/userone/jdk1.6.0_21/bin:$PATH
export CLASSPATH=/home/userone/jboss-as-7.1.2.Final/bin/client/jboss-client.jar:$CLASSPATH:.:

++++++++++++++++++++++++++++++++
For Windows Based Operating System

set PATH=C:\jdk1.6.0_21\bin;%PATH%
set CLASSPATH=c:\jboss-as-7.1.2.Final\bin\client\jboss-client.jar;%CLASSPATH%;.;

.
.
Thanks :)
MiddlewareMagic Team


How to use log filters in JBoss AS 7.1.2 in order to avoid some WARN & INFO Messages

Hi,

In this demonstration we will see how to configure use the log filtering feature of JBoss AS7.1.2 in order to prevent some of the log messages (containing a specific words) to not to appear in the logs. Many times it is desired to avoid displaying some WARN Messages or some INFO messages which appears in log but we dont want to see them in the logs.

For example when we start a normal JBoss AS7.1.2 standalone-full.xml profile then as soon as the server boots up we can see the following kind of entries in our "server.log":

02:22:28,652 INFO  [org.jboss.as.configadmin] (ServerService Thread Pool -- 32) JBAS016200: Activating ConfigAdmin Subsystem
02:22:28,660 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 37) JBAS010280: Activating Infinispan subsystem.
02:22:28,669 INFO  [org.jboss.as.jacorb] (ServerService Thread Pool -- 38) JBAS016300: Activating JacORB Subsystem
02:22:28,733 INFO  [org.jboss.as.osgi] (ServerService Thread Pool -- 49) JBAS011906: Activating OSGi Subsystem
02:22:28,736 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 54) JBAS013101: Activating Security Subsystem
02:22:28,761 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 58) JBAS015537: Activating WebServices Extension
02:22:28,765 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 48) JBAS011800: Activating Naming Subsystem
02:22:28,773 INFO  [org.jboss.as.security] (MSC service thread 1-7) JBAS013100: Current PicketBox version=4.0.9.Final
02:22:28,782 INFO  [org.jboss.as.connector.logging] (MSC service thread 1-2) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.11.Final)
02:22:28,844 INFO  [org.jboss.as.naming] (MSC service thread 1-8) JBAS011802: Starting Naming Service

Now suppose if we want to filterout all the messages in the log which has following JBoss message codes like “JBAS016200″, “JBAS010280″, “JBAS016300″, “JBAS011906″, “JBAS013101″, “JBAS015537″ then we can achieve it by simply adding a “not” filter inside our JBoss configuration file like “standalone-full.xml” inside the logging subsystem as following:

            <periodic-rotating-file-handler name="FILE">

                <filter>
                    <not>
                        <match pattern="JBAS016200|JBAS010280|JBAS016300|JBAS011906|JBAS013101|JBAS015537"/>
                    </not>
                </filter>

                <formatter>
                    <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
                </formatter>
                <file relative-to="jboss.server.log.dir" path="server.log"/>
                <suffix value=".yyyy-MM-dd"/>
                <append value="true"/>
            </periodic-rotating-file-handler>

Now after restarting the JBossAS 7.1.1 or AS 7.1.2 try to search any of the mentioned keywrd in the logs “JBAS016200″, “JBAS010280″, “JBAS016300″, “JBAS011906″, “JBAS013101″, “JBAS015537″ , If you wont find it there it means your log filter is working fine. for example now the first few lines of your server.log may be as following without any of the above messages:

02:33:40,438 INFO  [org.jboss.as.connector.logging] (MSC service thread 1-8) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.11.Final)
02:33:40,448 INFO  [org.jboss.as.security] (MSC service thread 1-2) JBAS013100: Current PicketBox version=4.0.9.Final
02:33:40,452 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 48) JBAS011800: Activating Naming Subsystem
02:33:40,500 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 33) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
02:33:40,527 INFO  [org.jboss.as.naming] (MSC service thread 1-1) JBAS011802: Starting Naming Service
02:33:40,540 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-5) JBAS015400: Bound mail session [java:jboss/mail/Default]
02:33:40,572 INFO  [org.jboss.jaxr] (MSC service thread 1-8) JBAS014000: Started JAXR subsystem, binding JAXR connection factory into JNDI as: java:jboss/jaxr/ConnectionFactory

.
.
Thanks :)
MiddlewareMagic Team


Configuring Https Connector using CLI on JBossAS 7.1.2 & Testing with Java TestClient

Hi,

In this demonstration we will see how to configure Https connector using CLI commands on JBossAS 7.1.2 sothat we can access server deployed resources over SSL on secure port 8443. We will also see how to access the resources over HTTPS through a simple standalone java based client program.

NOTE: This demo can be downloaded from Github:
https://github.com/jaysensharma/MiddlewareMagicDemos/tree/master/SSL_With_CLI_&_JavaBased_TestClient

Step1). First if all we will create Security certificates with the help of JDK provided utility “keytool”, So make sure that the JDK’s bin directory is added in your shell/command prompts PATH variable like following (We are creating the “chap8.keystore” inside “$JBOSS_HOME/standalone/configuration” directory):

.
[userone@localhost ~]$ cd /home/userone/jboss-as-7.1.2.Final/standalone/configuration/

[userone@localhost configuration]$ export PATH=/home/userone/MyJdks/jdk1.6.0_21/bin:$PATH

[userone@localhost configuration] keytool -genkey -keystore chap8.keystore -storepass rmi+ssl -keypass rmi+ssl -keyalg RSA -alias chapter8 -validity 3650 -dname "cn=chapter8 example,ou=admin book,dc=jboss,dc=org"
.

Step2). Make sure that the JBoss AS7.1.2 is running, In our case we started JBossAS7.1.2 “standalone-full.xml” profile.

.
[userone@localhost bin]$ ./standalone.sh -c standalone-full.xml
.

Step3). Now We will configure the Https connector to listen on Secured port “8443″ on our JBoss, we will take help of the CLI utility in order to configure the same:

[userone@localhost bin]$ cd /home/userone/jboss-as-7.1.2.Final/bin

[userone@localhost bin]$ ./jboss-cli.sh -c --controller=localhost:9999

[standalone@localhost:9999 /] /subsystem=web/connector=https/:add(socket-binding=https,scheme=https,protocol=HTTP/1.1,secure=true,enabled=true,enable-lookups=false)
{"outcome" => "success"}

[standalone@localhost:9999 /] /subsystem=web/connector=https/ssl=configuration:add(name="ssl",key-alias="chapter8",password="rmi+ssl",certificate-key-file="${jboss.server.config.dir}/chap8.keystore",protocol="TLSv1",verify-client="false",certificate-file="${jboss.server.config.dir}/chap8.keystore")
{"outcome" => "success"}

Once your above CLI command is executed successfully you will notice the following in your JBossAS 7.1.2 configuration file “standalone-full.xml”:

        <subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false">
            <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
            <connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https" secure="true">
                <ssl name="ssl"
                     key-alias="chapter8"
                     password="rmi+ssl"
                     certificate-key-file="${jboss.server.config.dir}/chap8.keystore"
                     protocol="TLSv1"
                     verify-client="false"
                     certificate-file="${jboss.server.config.dir}/chap8.keystore"/>
            </connector>
            <virtual-server name="default-host" enable-welcome-root="true">
                <alias name="localhost"/>
                <alias name="example.com"/>
            </virtual-server>
        </subsystem>

You will notice the following kind of message in your JBossAS7.1.2 console which says that HTTPS connector is started and listening on 8443 port.

.
20:37:05,691 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-7) Starting Coyote HTTP/1.1 on http-localhost/127.0.0.1:8443
.

Step4). Still it is better to restart your JBoss Server and then deploy any Test Web Application on it which we will try to access over SSL through a simple JAVA based standalone client.

Testing with a Https Based Standalone Java Client

Step5). Now write a simple Java program “TestHttpsClient.java” as following:

import java.io.*;
import java.net.*;
import java.security.cert.X509Certificate;
import javax.net.ssl.*;

public class TestHttpsClient implements javax.net.ssl.X509TrustManager {

	public static void main(String[] args) throws Exception {
		TestHttpsClient test=new TestHttpsClient();
		String resourceURL="https://localhost:8443/test/index.jsp";
		String UserName = "test";  // this is just dummy credentials we dont need it until WebApplication asks for Basic Auth Credentials
		String Password = "test";
		InputStream InputStream=test.doHttpsUrlConnectionAction(resourceURL, UserName, Password);
	}

	public InputStream doHttpsUrlConnectionAction(String resourceURL,String UserName,String Password) throws Exception {
		URL url;
		int responseCode = 0;
		// ###########
		SSLContext sc = SSLContext.getInstance("SSLv3");
		TrustManager[] tma = { new TestHttpsClient() };
		sc.init(null, tma, null);
		SSLSocketFactory ssf = sc.getSocketFactory();
		HttpsURLConnection.setDefaultSSLSocketFactory(ssf);
		// ###########
		HttpsURLConnection connection = null;

		String nurl = resourceURL;
		System.out.println("\n\t resourceURL = " + resourceURL);
		HostnameVerifier hv = new HostnameVerifier() {
			                  public boolean verify(String urlHostName, SSLSession session) {
				                                System.out.println("Warning: URL Host: " + urlHostName+ " vs. " + session.getPeerHost());
				                                return true;
			                                        }
		                                             };

		HttpsURLConnection.setDefaultHostnameVerifier(hv);
		try {
			url = new URL(nurl);
			connection = (HttpsURLConnection) url.openConnection();

                        //  Following two lines can be uncommented if you want your client to pass Basic Authentication Credentials as well
                        //
			//  String encoding = encodeUsernamePasswordBase64(UserName,Password);
			//  connection.setRequestProperty("Authorization", "Basic " + encoding);
                        //

			System.out.println("Conn established " + connection);
			connection.setDoInput(true);
			connection.setDoOutput(true);
			connection.setRequestMethod("GET");
			responseCode = connection.getResponseCode();
			System.out.println("response code : " + responseCode);
			connection.connect();
		} catch (Exception e) {
			System.err.println(e);
		}

		InputStream inputStream = null;
		try {
			inputStream = connection.getInputStream();
			System.out.println("Received Data: as Following:\n\n");
                        StringBuilder sb=new StringBuilder();
                        BufferedInputStream bis = new BufferedInputStream(inputStream);
                        while (bis.available() > 0)
                          {
                             System.out.print((char)bis.read());
                          }
                        bis.close();
                        inputStream.close();

		} catch (Exception e) {
			System.err.println(e);
		}
		return inputStream;
	}

	public void checkClientTrusted(X509Certificate[] chain, String authType) {
	}

	public void checkServerTrusted(X509Certificate[] chain, String authType) {
	}

	public X509Certificate[] getAcceptedIssuers() {
		return null;
	}

        //      Following method can be uncommented if you want to sent the Basic authentication credential as well 

	//public String encodeUsernamePasswordBase64(String UserName,String Password) {
	//	String userPassword = UserName + ":" + Password;
	//	byte[] encodedByte = org.apache.commons.codec.binary.Base64.encodeBase64(userPassword.getBytes());
	//	String encodedBase64String = new String(encodedByte);
	//	return encodedBase64String;
	//}
 }

Step6). Now we will compile and test the above program as following:

[userone@localhost standalone]$ javac -d . TestHttpsClient.java
[userone@localhost standalone]$ java TestHttpsClient 

	 resourceURL = https://localhost:8443/test/index.jsp
Conn established sun.net.www.protocol.https.DelegateHttpsURLConnection:https://localhost:8443/test/index.jsp
javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
[userone@localhost standalone]$

We can see that the program is throwing SSL Error and the Handshake is failing. So we need to know how to debug it and what kind of trouble shooting steps are needed.

Troubleshooting “Received fatal alert: handshake_failure”

Step7). As we do not know what is failing and how to troubleshoot this issue so lets add the following JAVA_OPTS on both client and server side. Edit the “$JBOSS_HOME/bin/standalone.conf” file and then add the following java option somewhere at the end of the file then restart your JBossAS 7.1.2:

JAVA_OPTS="$JAVA_OPTS  -Djavax.net.debug=all"

Step8). Now add the same JAVA_OPTION on the client side as well to see what we get:


[userone@localhost standalone]$ java -Djavax.net.debug=all TestHttpsClient
.
.
trigger seeding of SecureRandom
done seeding SecureRandom

	 resourceURL = https://localhost:8443/test/index.jsp
Conn established sun.net.www.protocol.https.DelegateHttpsURLConnection:https://localhost:8443/test/index.jsp
%% No cached client session
*** ClientHello, TLSv1
RandomCookie:  GMT: 1345238221 bytes = { 105, 167, 167, 204, 97, 58, 22, 192, 82, 217, 200, 202, 181, 7, 25, 79, 228, 159, 44, 247, 106, 185, 240, 130, 26, 152, 20, 178 }
Session ID:  {}
Cipher Suites: [SSL_RSA_WITH_RC4_128_MD5, SSL_RSA_WITH_RC4_128_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_DES_CBC_SHA, SSL_DHE_RSA_WITH_DES_CBC_SHA, SSL_DHE_DSS_WITH_DES_CBC_SHA, SSL_RSA_EXPORT_WITH_RC4_40_MD5, SSL_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA]
Compression Methods:  { 0 }
***
[write] MD5 and SHA1 hashes:  len = 73
0000: 01 00 00 45 03 01 50 2F   B5 CD 69 A7 A7 CC 61 3A  ...E..P/..i...a:
0010: 16 C0 52 D9 C8 CA B5 07   19 4F E4 9F 2C F7 6A B9  ..R......O..,.j.
0020: F0 82 1A 98 14 B2 00 00   1E 00 04 00 05 00 2F 00  ............../.
0030: 33 00 32 00 0A 00 16 00   13 00 09 00 15 00 12 00  3.2.............
0040: 03 00 08 00 14 00 11 01   00                       .........
main, WRITE: TLSv1 Handshake, length = 73
[write] MD5 and SHA1 hashes:  len = 98
0000: 01 03 01 00 39 00 00 00   20 00 00 04 01 00 80 00  ....9... .......
0010: 00 05 00 00 2F 00 00 33   00 00 32 00 00 0A 07 00  ..../..3..2.....
0020: C0 00 00 16 00 00 13 00   00 09 06 00 40 00 00 15  ............@...
0030: 00 00 12 00 00 03 02 00   80 00 00 08 00 00 14 00  ................
0040: 00 11 50 2F B5 CD 69 A7   A7 CC 61 3A 16 C0 52 D9  ..P/..i...a:..R.
0050: C8 CA B5 07 19 4F E4 9F   2C F7 6A B9 F0 82 1A 98  .....O..,.j.....
0060: 14 B2                                              ..
main, WRITE: SSLv2 client hello message, length = 98
[Raw write]: length = 100
0000: 80 62 01 03 01 00 39 00   00 00 20 00 00 04 01 00  .b....9... .....
0010: 80 00 00 05 00 00 2F 00   00 33 00 00 32 00 00 0A  ....../..3..2...
0020: 07 00 C0 00 00 16 00 00   13 00 00 09 06 00 40 00  ..............@.
0030: 00 15 00 00 12 00 00 03   02 00 80 00 00 08 00 00  ................
0040: 14 00 00 11 50 2F B5 CD   69 A7 A7 CC 61 3A 16 C0  ....P/..i...a:..
0050: 52 D9 C8 CA B5 07 19 4F   E4 9F 2C F7 6A B9 F0 82  R......O..,.j...
0060: 1A 98 14 B2                                        ....
[Raw read]: length = 5
0000: 15 03 01 00 02                                     .....
[Raw read]: length = 2
0000: 02 28                                              .(
main, READ: TLSv1 Alert, length = 2
main, RECV TLSv1 ALERT:  fatal, handshake_failure
main, called closeSocket()
main, handling exception: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure

Step9). On the JBossAS7.1.2 console i was able to see the following kind of reason for the SSL Handshake after enabling the debug:

21:03:33,010 INFO  [stdout] (http-localhost/127.0.0.1:8443-Acceptor-0) Allow unsafe renegotiation: false
21:03:33,010 INFO  [stdout] (http-localhost/127.0.0.1:8443-Acceptor-0) Allow legacy hello messages: true
21:03:33,010 INFO  [stdout] (http-localhost/127.0.0.1:8443-Acceptor-0) Is initial handshake: true
21:03:33,010 INFO  [stdout] (http-localhost/127.0.0.1:8443-Acceptor-0) Is secure renegotiation: false
21:03:33,012 INFO  [stdout] (http-localhost/127.0.0.1:8443-1) http-localhost/127.0.0.1:8443-1, setSoTimeout(60000) called
21:03:33,069 INFO  [stdout] (http-localhost/127.0.0.1:8443-1) [Raw read]: length = 5
21:03:33,070 INFO  [stdout] (http-localhost/127.0.0.1:8443-1) 0000: 80 62 01 03 01                                     .b...
21:03:33,070 INFO  [stdout] (http-localhost/127.0.0.1:8443-1) http-localhost/127.0.0.1:8443-1, handling exception: javax.net.ssl.SSLHandshakeException: SSLv2Hello is disabled
21:03:33,071 INFO  [stdout] (http-localhost/127.0.0.1:8443-1) http-localhost/127.0.0.1:8443-1, SEND TLSv1 ALERT:  fatal, description = handshake_failure
21:03:33,071 INFO  [stdout] (http-localhost/127.0.0.1:8443-1) http-localhost/127.0.0.1:8443-1, WRITE: TLSv1 Alert, length = 2
21:03:33,072 INFO  [stdout] (http-localhost/127.0.0.1:8443-1) [Raw write]: length = 7
21:03:33,072 INFO  [stdout] (http-localhost/127.0.0.1:8443-1) 0000: 15 03 01 00 02 02 28                               ......(
21:03:33,072 INFO  [stdout] (http-localhost/127.0.0.1:8443-1) http-localhost/127.0.0.1:8443-1, called closeSocket()
21:03:33,073 INFO  [stdout] (http-localhost/127.0.0.1:8443-1) http-localhost/127.0.0.1:8443-1, IOException in getSession():  javax.net.ssl.SSLHandshakeException: SSLv2Hello is disabled
21:03:33,073 INFO  [stdout] (http-localhost/127.0.0.1:8443-1) http-localhost/127.0.0.1:8443-1, called close()
21:03:33,073 INFO  [stdout] (http-localhost/127.0.0.1:8443-1) http-localhost/127.0.0.1:8443-1, called closeInternal(true)
.

What was the Cause of handshake failure ?

Notice JBossAS 7.1.2 is cmplaining that “SSLv2Hello” is disabled which means the client is not sending a proper SSL Protocol.

http-localhost/127.0.0.1:8443-1, handling exception: javax.net.ssl.SSLHandshakeException: SSLv2Hello is disabled

Step10). So now as we know that the client is not using a proper protocol to send the request so we will try adding the following JAVA_OPTS [ -Dhttps.protocols=TLSv1 ] on the client side in order to use the TLSv1 protocol for communication:

[userone@localhost standalone]$ java -Djavax.net.debug=all  -Dhttps.protocols=TLSv1 TestHttpsClient
.
.
trigger seeding of SecureRandom
done seeding SecureRandom

	 resourceURL = https://localhost:8443/test/index.jsp
Conn established sun.net.www.protocol.https.DelegateHttpsURLConnection:https://localhost:8443/test/index.jsp
%% No cached client session
*** ClientHello, TLSv1
RandomCookie:  GMT: 1345238823 bytes = { 59, 48, 212, 175, 197, 249, 200, 221, 96, 72, 203, 206, 27, 95, 71, 211, 123, 182, 131, 91, 91, 236, 19, 6, 159, 175, 93, 210 }
Session ID:  {}
Cipher Suites: [SSL_RSA_WITH_RC4_128_MD5, SSL_RSA_WITH_RC4_128_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_DES_CBC_SHA, SSL_DHE_RSA_WITH_DES_CBC_SHA, SSL_DHE_DSS_WITH_DES_CBC_SHA, SSL_RSA_EXPORT_WITH_RC4_40_MD5, SSL_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA]
Compression Methods:  { 0 }
***
[write] MD5 and SHA1 hashes:  len = 73
0000: 01 00 00 45 03 01 50 2F   B7 27 3B 30 D4 AF C5 F9  ...E..P/.';0....
0010: C8 DD 60 48 CB CE 1B 5F   47 D3 7B B6 83 5B 5B EC  ..`H..._G....[[.
0020: 13 06 9F AF 5D D2 00 00   1E 00 04 00 05 00 2F 00  ....]........./.
0030: 33 00 32 00 0A 00 16 00   13 00 09 00 15 00 12 00  3.2.............
0040: 03 00 08 00 14 00 11 01   00                       .........
main, WRITE: TLSv1 Handshake, length = 73
[Raw write]: length = 78
0000: 16 03 01 00 49 01 00 00   45 03 01 50 2F B7 27 3B  ....I...E..P/.';
0010: 30 D4 AF C5 F9 C8 DD 60   48 CB CE 1B 5F 47 D3 7B  0......`H..._G..
0020: B6 83 5B 5B EC 13 06 9F   AF 5D D2 00 00 1E 00 04  ..[[.....]......
0030: 00 05 00 2F 00 33 00 32   00 0A 00 16 00 13 00 09  .../.3.2........
0040: 00 15 00 12 00 03 00 08   00 14 00 11 01 00        ..............
[Raw read]: length = 5
0000: 16 03 01 02 8B                                     .....
[Raw read]: length = 651
0000: 02 00 00 46 03 01 50 2F   B7 27 A2 82 8C F5 F3 F7  ...F..P/.'......
0010: 5F EE 55 CA 25 5E 83 5A   1D C8 39 2E 07 8C FE E0  _.U.%^.Z..9.....
0020: 67 8C 41 0C F4 01 20 50   2F B7 27 01 EA 77 CD 5D  g.A... P/.'..w.]
0030: 66 82 11 AC 11 96 9B 6E   8B AD 8D 8E 59 81 C9 D4  f......n....Y...
0040: 62 A0 CD 96 1F 96 0F 00   04 00 0B 00 02 39 00 02  b............9..
0050: 36 00 02 33 30 82 02 2F   30 82 01 98 A0 03 02 01  6..30../0.......
0060: 02 02 04 50 2F AE 0A 30   0D 06 09 2A 86 48 86 F7  ...P/..0...*.H..
0070: 0D 01 01 05 05 00 30 5C   31 13 30 11 06 0A 09 92  ......0\1.0.....
0080: 26 89 93 F2 2C 64 01 19   16 03 6F 72 67 31 15 30  &...,d....org1.0
0090: 13 06 0A 09 92 26 89 93   F2 2C 64 01 19 16 05 6A  .....&...,d....j
00A0: 62 6F 73 73 31 13 30 11   06 03 55 04 0B 13 0A 61  boss1.0...U....a
00B0: 64 6D 69 6E 20 62 6F 6F   6B 31 19 30 17 06 03 55  dmin book1.0...U
00C0: 04 03 13 10 63 68 61 70   74 65 72 38 20 65 78 61  ....chapter8 exa
00D0: 6D 70 6C 65 30 1E 17 0D   31 32 30 38 31 38 31 35  mple0...12081815
00E0: 30 30 32 36 5A 17 0D 32   32 30 38 31 36 31 35 30  0026Z..220816150
00F0: 30 32 36 5A 30 5C 31 13   30 11 06 0A 09 92 26 89  026Z0\1.0.....&.
0100: 93 F2 2C 64 01 19 16 03   6F 72 67 31 15 30 13 06  ..,d....org1.0..
0110: 0A 09 92 26 89 93 F2 2C   64 01 19 16 05 6A 62 6F  ...&...,d....jbo
0120: 73 73 31 13 30 11 06 03   55 04 0B 13 0A 61 64 6D  ss1.0...U....adm
0130: 69 6E 20 62 6F 6F 6B 31   19 30 17 06 03 55 04 03  in book1.0...U..
0140: 13 10 63 68 61 70 74 65   72 38 20 65 78 61 6D 70  ..chapter8 examp
0150: 6C 65 30 81 9F 30 0D 06   09 2A 86 48 86 F7 0D 01  le0..0...*.H....
0160: 01 01 05 00 03 81 8D 00   30 81 89 02 81 81 00 9F  ........0.......
0170: F5 D8 05 FD 40 7F E8 BB   92 10 39 EB 19 C9 E5 58  ....@.....9....X
0180: 4E 11 18 32 75 8A 49 53   4A 18 BF 3E C1 09 5C F1  N..2u.ISJ..>..\.
0190: 1D C2 96 8C 86 29 A2 1D   8F 51 2E B8 15 7F 6E C0  .....)...Q....n.
01A0: 20 8A 50 47 C8 A1 4A C7   77 CD CC EB 9C 11 24 E2   .PG..J.w.....$.
01B0: EE E6 98 9A 38 C9 9E FF   AF AC E7 8C D4 29 17 4E  ....8........).N
01C0: 8A 7E 89 C8 52 27 A0 D1   9F DF 7D D0 D9 7B EB 22  ....R'........."
01D0: 9E 80 6F 11 DD 5B 60 9C   74 DB A5 77 F4 B6 F2 46  ..o..[`.t..w...F
01E0: DC D1 18 A4 E9 16 73 43   F6 ED 11 5B 1C 25 5B 02  ......sC...[.%[.
01F0: 03 01 00 01 30 0D 06 09   2A 86 48 86 F7 0D 01 01  ....0...*.H.....
0200: 05 05 00 03 81 81 00 09   0F C7 47 4C 20 61 FF 59  ..........GL a.Y
0210: 2F 8C 3E 46 B1 32 CE 09   36 F3 25 AF 2C 37 D5 DA  /.>F.2..6.%.,7..
0220: 54 78 D3 4B EA 78 78 F4   B4 C1 DC BF 4E 11 CE 03  Tx.K.xx.....N...
0230: 6D 57 F5 07 2F CA 02 B6   23 B3 40 26 F4 3C 9E 09  mW../...#.@&.<..
0240: 75 16 F9 94 AF B4 EF C4   C1 0E A7 F9 5F 2F 70 18  u..........._/p.
0250: C0 B5 09 16 E2 A6 BC 86   EF 7F A4 E1 F5 C2 35 C6  ..............5.
0260: F4 09 BB 93 A8 23 91 E4   F1 42 59 53 89 47 F1 04  .....#...BYS.G..
0270: B5 CE 30 C0 BE 7A 9E D0   D2 57 B5 61 B0 F1 1A D2  ..0..z...W.a....
0280: C6 C5 4E 10 4C FC 6F 0E   00 00 00                 ..N.L.o....
main, READ: TLSv1 Handshake, length = 651
*** ServerHello, TLSv1
RandomCookie:  GMT: 1345238823 bytes = { 162, 130, 140, 245, 243, 247, 95, 238, 85, 202, 37, 94, 131, 90, 29, 200, 57, 46, 7, 140, 254, 224, 103, 140, 65, 12, 244, 1 }
Session ID:  {80, 47, 183, 39, 1, 234, 119, 205, 93, 102, 130, 17, 172, 17, 150, 155, 110, 139, 173, 141, 142, 89, 129, 201, 212, 98, 160, 205, 150, 31, 150, 15}
Cipher Suite: SSL_RSA_WITH_RC4_128_MD5
Compression Method: 0
***
%% Created:  [Session-1, SSL_RSA_WITH_RC4_128_MD5]
** SSL_RSA_WITH_RC4_128_MD5
[read] MD5 and SHA1 hashes:  len = 74
0000: 02 00 00 46 03 01 50 2F   B7 27 A2 82 8C F5 F3 F7  ...F..P/.'......
0010: 5F EE 55 CA 25 5E 83 5A   1D C8 39 2E 07 8C FE E0  _.U.%^.Z..9.....
0020: 67 8C 41 0C F4 01 20 50   2F B7 27 01 EA 77 CD 5D  g.A... P/.'..w.]
0030: 66 82 11 AC 11 96 9B 6E   8B AD 8D 8E 59 81 C9 D4  f......n....Y...
0040: 62 A0 CD 96 1F 96 0F 00   04 00                    b.........
*** Certificate chain
chain [0] = [
[
  Version: V3
  Subject: CN=chapter8 example, OU=admin book, DC=jboss, DC=org
  Signature Algorithm: SHA1withRSA, OID = 1.2.840.113549.1.1.5

  Key:  Sun RSA public key, 1024 bits
  modulus: 112327961955793427294788693539127054708342991554979642795375341813812315606410953443425170876453687812657572324528850546265317609032949186934642585274247999052696216659140187935451881753515565277516661450297298499364056248126550289023310877209666305304254207350144517608476196856386756508895595865011272820059
  public exponent: 65537
  Validity: [From: Sat Aug 18 20:30:26 IST 2012,
               To: Tue Aug 16 20:30:26 IST 2022]
  Issuer: CN=chapter8 example, OU=admin book, DC=jboss, DC=org
  SerialNumber: [    502fae0a]

]
  Algorithm: [SHA1withRSA]
  Signature:
0000: 09 0F C7 47 4C 20 61 FF   59 2F 8C 3E 46 B1 32 CE  ...GL a.Y/.>F.2.
0010: 09 36 F3 25 AF 2C 37 D5   DA 54 78 D3 4B EA 78 78  .6.%.,7..Tx.K.xx
0020: F4 B4 C1 DC BF 4E 11 CE   03 6D 57 F5 07 2F CA 02  .....N...mW../..
0030: B6 23 B3 40 26 F4 3C 9E   09 75 16 F9 94 AF B4 EF  .#.@&.<..u......
0040: C4 C1 0E A7 F9 5F 2F 70   18 C0 B5 09 16 E2 A6 BC  ....._/p........
0050: 86 EF 7F A4 E1 F5 C2 35   C6 F4 09 BB 93 A8 23 91  .......5......#.
0060: E4 F1 42 59 53 89 47 F1   04 B5 CE 30 C0 BE 7A 9E  ..BYS.G....0..z.
0070: D0 D2 57 B5 61 B0 F1 1A   D2 C6 C5 4E 10 4C FC 6F  ..W.a......N.L.o

]
***
[read] MD5 and SHA1 hashes:  len = 573
0000: 0B 00 02 39 00 02 36 00   02 33 30 82 02 2F 30 82  ...9..6..30../0.
0010: 01 98 A0 03 02 01 02 02   04 50 2F AE 0A 30 0D 06  .........P/..0..
0020: 09 2A 86 48 86 F7 0D 01   01 05 05 00 30 5C 31 13  .*.H........0\1.
0030: 30 11 06 0A 09 92 26 89   93 F2 2C 64 01 19 16 03  0.....&...,d....
0040: 6F 72 67 31 15 30 13 06   0A 09 92 26 89 93 F2 2C  org1.0.....&...,
0050: 64 01 19 16 05 6A 62 6F   73 73 31 13 30 11 06 03  d....jboss1.0...
0060: 55 04 0B 13 0A 61 64 6D   69 6E 20 62 6F 6F 6B 31  U....admin book1
0070: 19 30 17 06 03 55 04 03   13 10 63 68 61 70 74 65  .0...U....chapte
0080: 72 38 20 65 78 61 6D 70   6C 65 30 1E 17 0D 31 32  r8 example0...12
0090: 30 38 31 38 31 35 30 30   32 36 5A 17 0D 32 32 30  0818150026Z..220
00A0: 38 31 36 31 35 30 30 32   36 5A 30 5C 31 13 30 11  816150026Z0\1.0.
00B0: 06 0A 09 92 26 89 93 F2   2C 64 01 19 16 03 6F 72  ....&...,d....or
00C0: 67 31 15 30 13 06 0A 09   92 26 89 93 F2 2C 64 01  g1.0.....&...,d.
00D0: 19 16 05 6A 62 6F 73 73   31 13 30 11 06 03 55 04  ...jboss1.0...U.
00E0: 0B 13 0A 61 64 6D 69 6E   20 62 6F 6F 6B 31 19 30  ...admin book1.0
00F0: 17 06 03 55 04 03 13 10   63 68 61 70 74 65 72 38  ...U....chapter8
0100: 20 65 78 61 6D 70 6C 65   30 81 9F 30 0D 06 09 2A   example0..0...*
0110: 86 48 86 F7 0D 01 01 01   05 00 03 81 8D 00 30 81  .H............0.
0120: 89 02 81 81 00 9F F5 D8   05 FD 40 7F E8 BB 92 10  ..........@.....
0130: 39 EB 19 C9 E5 58 4E 11   18 32 75 8A 49 53 4A 18  9....XN..2u.ISJ.
0140: BF 3E C1 09 5C F1 1D C2   96 8C 86 29 A2 1D 8F 51  .>..\......)...Q
0150: 2E B8 15 7F 6E C0 20 8A   50 47 C8 A1 4A C7 77 CD  ....n. .PG..J.w.
0160: CC EB 9C 11 24 E2 EE E6   98 9A 38 C9 9E FF AF AC  ....$.....8.....
0170: E7 8C D4 29 17 4E 8A 7E   89 C8 52 27 A0 D1 9F DF  ...).N....R'....
0180: 7D D0 D9 7B EB 22 9E 80   6F 11 DD 5B 60 9C 74 DB  ....."..o..[`.t.
0190: A5 77 F4 B6 F2 46 DC D1   18 A4 E9 16 73 43 F6 ED  .w...F......sC..
01A0: 11 5B 1C 25 5B 02 03 01   00 01 30 0D 06 09 2A 86  .[.%[.....0...*.
01B0: 48 86 F7 0D 01 01 05 05   00 03 81 81 00 09 0F C7  H...............
01C0: 47 4C 20 61 FF 59 2F 8C   3E 46 B1 32 CE 09 36 F3  GL a.Y/.>F.2..6.
01D0: 25 AF 2C 37 D5 DA 54 78   D3 4B EA 78 78 F4 B4 C1  %.,7..Tx.K.xx...
01E0: DC BF 4E 11 CE 03 6D 57   F5 07 2F CA 02 B6 23 B3  ..N...mW../...#.
01F0: 40 26 F4 3C 9E 09 75 16   F9 94 AF B4 EF C4 C1 0E  @&.<..u.........
0200: A7 F9 5F 2F 70 18 C0 B5   09 16 E2 A6 BC 86 EF 7F  .._/p...........
0210: A4 E1 F5 C2 35 C6 F4 09   BB 93 A8 23 91 E4 F1 42  ....5......#...B
0220: 59 53 89 47 F1 04 B5 CE   30 C0 BE 7A 9E D0 D2 57  YS.G....0..z...W
0230: B5 61 B0 F1 1A D2 C6 C5   4E 10 4C FC 6F           .a......N.L.o
*** ServerHelloDone
[read] MD5 and SHA1 hashes:  len = 4
0000: 0E 00 00 00                                        ....
*** ClientKeyExchange, RSA PreMasterSecret, TLSv1
[write] MD5 and SHA1 hashes:  len = 134
0000: 10 00 00 82 00 80 32 75   DE 6E 2E 5A F9 1C 5E AF  ......2u.n.Z..^.
0010: F9 58 7C 27 5D 83 3A 08   4C 09 1E 31 9C E9 DF F3  .X.'].:.L..1....
0020: E9 C9 7F 78 04 73 FA 43   F1 8F 2C 9F D0 F8 E1 4D  ...x.s.C..,....M
0030: 5E C8 A4 17 EB C9 68 B5   67 DE CD 34 3E 4B 55 E5  ^.....h.g..4>KU.
0040: 38 F3 AD 5A 23 D1 5D 11   89 B5 3C F5 F7 B3 A8 A9  8..Z#.]...<.....
0050: EE 79 BD B5 5D 96 F1 B1   48 4F BF E8 16 81 A1 EB  .y..]...HO......
0060: 65 77 ED 21 9C 29 4A 80   12 86 1D 82 9D A8 1E 63  ew.!.)J........c
0070: 7F 2A AA 40 06 97 70 4D   BF D7 C0 D2 27 87 F0 11  .*.@..pM....'...
0080: 3A C2 99 ED 87 1C                                  :.....
main, WRITE: TLSv1 Handshake, length = 134
[Raw write]: length = 139
0000: 16 03 01 00 86 10 00 00   82 00 80 32 75 DE 6E 2E  ...........2u.n.
0010: 5A F9 1C 5E AF F9 58 7C   27 5D 83 3A 08 4C 09 1E  Z..^..X.'].:.L..
0020: 31 9C E9 DF F3 E9 C9 7F   78 04 73 FA 43 F1 8F 2C  1.......x.s.C..,
0030: 9F D0 F8 E1 4D 5E C8 A4   17 EB C9 68 B5 67 DE CD  ....M^.....h.g..
0040: 34 3E 4B 55 E5 38 F3 AD   5A 23 D1 5D 11 89 B5 3C  4>KU.8..Z#.]...<
0050: F5 F7 B3 A8 A9 EE 79 BD   B5 5D 96 F1 B1 48 4F BF  ......y..]...HO.
0060: E8 16 81 A1 EB 65 77 ED   21 9C 29 4A 80 12 86 1D  .....ew.!.)J....
0070: 82 9D A8 1E 63 7F 2A AA   40 06 97 70 4D BF D7 C0  ....c.*.@..pM...
0080: D2 27 87 F0 11 3A C2 99   ED 87 1C                 .'...:.....
SESSION KEYGEN:
PreMaster Secret:
0000: 03 01 7E AA A8 36 E5 83   D8 6B 8E 5D 58 FD 7F CD  .....6...k.]X...
0010: D0 3F 2E 13 22 AA F0 4B   DB FB 69 DF 49 D6 41 94  .?.."..K..i.I.A.
0020: 25 69 46 F4 41 4E 35 26   5F 24 83 31 A3 81 4B 8D  %iF.AN5&_$.1..K.
CONNECTION KEYGEN:
Client Nonce:
0000: 50 2F B7 27 3B 30 D4 AF   C5 F9 C8 DD 60 48 CB CE  P/.';0......`H..
0010: 1B 5F 47 D3 7B B6 83 5B   5B EC 13 06 9F AF 5D D2  ._G....[[.....].
Server Nonce:
0000: 50 2F B7 27 A2 82 8C F5   F3 F7 5F EE 55 CA 25 5E  P/.'......_.U.%^
0010: 83 5A 1D C8 39 2E 07 8C   FE E0 67 8C 41 0C F4 01  .Z..9.....g.A...
Master Secret:
0000: 53 99 13 E9 DE C8 EB 85   D8 4F E4 52 D9 9E 91 DE  S........O.R....
0010: FD FE F0 2E B5 E2 65 F6   96 A4 48 C1 E0 4D 74 EB  ......e...H..Mt.
0020: 3E AC 50 84 3A C0 5C 08   ED 7F BC 39 DF E5 FA 02  >.P.:.\....9....
Client MAC write Secret:
0000: 93 58 54 31 D6 18 0A FE   BC FF 40 86 66 1C 95 A5  .XT1......@.f...
Server MAC write Secret:
0000: F5 F9 2E 64 12 A2 F3 6B   6B 69 C2 AA 36 14 AA 2C  ...d...kki..6..,
Client write key:
0000: 0F AF E3 10 1C 9B 24 A4   C8 0C 01 E1 FC 64 4F 55  ......$......dOU
Server write key:
0000: 72 04 94 3B 1E 2C DA 21   35 D7 ED CA A7 B7 3C 02  r..;.,.!5.....<.
... no IV used for this cipher
main, WRITE: TLSv1 Change Cipher Spec, length = 1
[Raw write]: length = 6
0000: 14 03 01 00 01 01                                  ......
*** Finished
verify_data:  { 199, 153, 29, 209, 100, 86, 200, 134, 249, 145, 192, 14 }
***
[write] MD5 and SHA1 hashes:  len = 16
0000: 14 00 00 0C C7 99 1D D1   64 56 C8 86 F9 91 C0 0E  ........dV......
Padded plaintext before ENCRYPTION:  len = 32
0000: 14 00 00 0C C7 99 1D D1   64 56 C8 86 F9 91 C0 0E  ........dV......
0010: E0 C0 5C E7 78 59 C8 72   7C 8E A5 C8 6B 90 C0 75  ..\.xY.r....k..u
main, WRITE: TLSv1 Handshake, length = 32
[Raw write]: length = 37
0000: 16 03 01 00 20 1C 00 C9   12 EE AE 76 26 82 5F CC  .... ......v&._.
0010: 65 93 CA 0C 84 70 A0 34   94 46 C9 86 AE AC A2 23  e....p.4.F.....#
0020: A4 6F EF DB 64                                     .o..d
[Raw read]: length = 5
0000: 14 03 01 00 01                                     .....
[Raw read]: length = 1
0000: 01                                                 .
main, READ: TLSv1 Change Cipher Spec, length = 1
[Raw read]: length = 5
0000: 16 03 01 00 20                                     ....
[Raw read]: length = 32
0000: 38 14 9D A8 51 FA B5 58   CE 7A E2 8A 0F E6 5E 45  8...Q..X.z....^E
0010: D3 4D 65 CF 1C 7B 44 C6   01 BD 69 42 2A 66 DB 8A  .Me...D...iB*f..
main, READ: TLSv1 Handshake, length = 32
Padded plaintext after DECRYPTION:  len = 32
0000: 14 00 00 0C 76 99 74 92   C7 45 2B ED AC 2D 2F 7A  ....v.t..E+..-/z
0010: 24 3E 7A 7A F9 1B 07 9F   1F 99 E6 DC 3C 2C 2B 7E  $>zz........<,+.
*** Finished
verify_data:  { 118, 153, 116, 146, 199, 69, 43, 237, 172, 45, 47, 122 }
***
%% Cached client session: [Session-1, SSL_RSA_WITH_RC4_128_MD5]
[read] MD5 and SHA1 hashes:  len = 16
0000: 14 00 00 0C 76 99 74 92   C7 45 2B ED AC 2D 2F 7A  ....v.t..E+..-/z
Warning: URL Host: localhost vs. localhost
Padded plaintext before ENCRYPTION:  len = 183
0000: 47 45 54 20 2F 74 65 73   74 2F 69 6E 64 65 78 2E  GET /test/index.
0010: 6A 73 70 20 48 54 54 50   2F 31 2E 31 0D 0A 55 73  jsp HTTP/1.1..Us
0020: 65 72 2D 41 67 65 6E 74   3A 20 4A 61 76 61 2F 31  er-Agent: Java/1
0030: 2E 36 2E 30 5F 32 31 0D   0A 48 6F 73 74 3A 20 6C  .6.0_21..Host: l
0040: 6F 63 61 6C 68 6F 73 74   3A 38 34 34 33 0D 0A 41  ocalhost:8443..A
0050: 63 63 65 70 74 3A 20 74   65 78 74 2F 68 74 6D 6C  ccept: text/html
0060: 2C 20 69 6D 61 67 65 2F   67 69 66 2C 20 69 6D 61  , image/gif, ima
0070: 67 65 2F 6A 70 65 67 2C   20 2A 3B 20 71 3D 2E 32  ge/jpeg, *; q=.2
0080: 2C 20 2A 2F 2A 3B 20 71   3D 2E 32 0D 0A 43 6F 6E  , */*; q=.2..Con
0090: 6E 65 63 74 69 6F 6E 3A   20 6B 65 65 70 2D 61 6C  nection: keep-al
00A0: 69 76 65 0D 0A 0D 0A C9   B3 D8 80 FB 69 A2 16 CA  ive.........i...
00B0: 87 1A DD 7B 85 29 77                               .....)w
main, WRITE: TLSv1 Application Data, length = 183
[Raw write]: length = 188
0000: 17 03 01 00 B7 9C 55 72   D7 0D 18 85 09 23 B7 2D  ......Ur.....#.-
0010: E9 8A A7 B7 A2 48 44 B3   7D CB 60 DE 44 7E F8 9C  .....HD...`.D...
0020: FE E8 46 DD 99 25 90 44   B3 8B CE B2 6A 83 38 2E  ..F..%.D....j.8.
0030: F8 F0 DF 4B 4E 08 58 37   D2 39 5F EB 44 B7 38 86  ...KN.X7.9_.D.8.
0040: A2 9A 70 74 33 AA 02 0F   62 05 29 57 7E C5 DF 87  ..pt3...b.)W....
0050: 35 06 EF 5C 4D 96 CF F0   84 73 10 60 BD B0 10 BF  5..\M....s.`....
0060: 1C 18 FE 81 AD B8 08 DD   CF 2C 69 42 41 09 11 AD  .........,iBA...
0070: ED 48 45 8D A7 E2 F8 8D   9B 89 BF 9A F4 00 1F BB  .HE.............
0080: 21 02 10 FE B5 4E 55 BD   63 4C 2E 4B E0 8B C9 84  !....NU.cL.K....
0090: C6 E3 18 39 3F A9 F3 87   52 67 F7 6E 44 91 12 98  ...9?...Rg.nD...
00A0: C3 3C 87 AD 82 9C EF F2   8B E2 A6 C2 FA 96 10 08  .<..............
00B0: F0 D9 82 EA F8 9B 26 44   2F 04 09 A5              ......&D/...
[Raw read]: length = 5
0000: 17 03 01 01 20                                     ....
[Raw read]: length = 288
0000: DF F0 E4 38 81 CE 54 3B   AD 8E 58 08 4D F8 2F 32  ...8..T;..X.M./2
0010: A6 1A 79 EC 5F 5D CC 77   FD 71 65 9B DC C5 A2 40  ..y._].w.qe....@
0020: B0 1A 52 5B BD 46 1F DD   18 85 95 FC F3 82 8E 6A  ..R[.F.........j
0030: D3 DC DB A1 F9 8B A8 C1   62 63 C2 6B BB 95 78 C7  ........bc.k..x.
0040: 89 59 A4 02 D9 C0 35 66   11 7E 6E B8 43 96 7C FD  .Y....5f..n.C...
0050: AE 47 CB 64 52 AB FA DA   40 01 2A 4B AD FD 30 10  .G.dR...@.*K..0.
0060: 40 2A 8D 4B E4 B5 49 E3   CA C5 02 8E 5B C8 66 84  @*.K..I.....[.f.
0070: D2 75 49 48 28 77 90 26   92 E1 48 A9 F1 9A 78 23  .uIH(w.&..H...x#
0080: 90 D1 02 15 89 0F 4D 8A   D7 30 04 17 F5 6E F0 ED  ......M..0...n..
0090: 32 92 1A 9D 5D 27 68 FD   9E BA 52 AD DA 45 2E 66  2...]'h...R..E.f
00A0: 33 A5 D6 B5 05 96 25 6C   F4 C0 20 24 24 A9 A1 87  3.....%l.. $$...
00B0: 02 DE 05 7E DA 9F 7A B3   7F 00 E2 CB 87 1B 6F 09  ......z.......o.
00C0: 1E 3E 6C 90 7C 3E 34 34   F3 FD B5 29 8F 8D 6D 88  .>l..>44...)..m.
00D0: 12 BE 0A B4 B2 5A 12 C4   4F 96 3F 8B 9A 2A 30 46  .....Z..O.?..*0F
00E0: 4C D5 8C C5 03 78 B9 36   AD FA 0A 9E BB 85 35 E0  L....x.6......5.
00F0: E6 AD 70 74 2D E2 F7 BF   7B B8 12 F8 7F 83 E1 92  ..pt-...........
0100: 4F 40 A8 30 BF 4C E6 5D   47 1A 0B 5C 5A 47 A4 6E  O@.0.L.]G..\ZG.n
0110: 35 89 0E E7 42 18 AC F5   26 1B DD B1 7A A9 FC 99  5...B...&...z...
main, READ: TLSv1 Application Data, length = 288
Padded plaintext after DECRYPTION:  len = 288
0000: 48 54 54 50 2F 31 2E 31   20 32 30 30 20 4F 4B 0D  HTTP/1.1 200 OK.
0010: 0A 53 65 72 76 65 72 3A   20 41 70 61 63 68 65 2D  .Server: Apache-
0020: 43 6F 79 6F 74 65 2F 31   2E 31 0D 0A 58 2D 50 6F  Coyote/1.1..X-Po
0030: 77 65 72 65 64 2D 42 79   3A 20 4A 53 50 2F 32 2E  wered-By: JSP/2.
0040: 32 0D 0A 53 65 74 2D 43   6F 6F 6B 69 65 3A 20 4A  2..Set-Cookie: J
0050: 53 45 53 53 49 4F 4E 49   44 3D 53 75 79 36 68 4E  SESSIONID=Suy6hN
0060: 50 4B 49 31 54 5A 56 36   36 6A 46 78 4D 76 70 41  PKI1TZV66jFxMvpA
0070: 55 70 3B 20 50 61 74 68   3D 2F 74 65 73 74 3B 20  Up; Path=/test;
0080: 53 65 63 75 72 65 0D 0A   43 6F 6E 74 65 6E 74 2D  Secure..Content-
0090: 54 79 70 65 3A 20 74 65   78 74 2F 68 74 6D 6C 3B  Type: text/html;
00A0: 63 68 61 72 73 65 74 3D   49 53 4F 2D 38 38 35 39  charset=ISO-8859
00B0: 2D 31 0D 0A 43 6F 6E 74   65 6E 74 2D 4C 65 6E 67  -1..Content-Leng
00C0: 74 68 3A 20 33 33 0D 0A   44 61 74 65 3A 20 53 61  th: 33..Date: Sa
00D0: 74 2C 20 31 38 20 41 75   67 20 32 30 31 32 20 31  t, 18 Aug 2012 1
00E0: 35 3A 33 39 3A 32 31 20   47 4D 54 0D 0A 0D 0A 48  5:39:21 GMT....H
00F0: 65 6C 6C 6C 6C 6C 6C 6C   6C 6C 6C 6C 6C 6F 6F 6F  ellllllllllllooo
0100: 6F 6F 6F 6F 6F 6F 6F 6F   6F 6F 6F 6F 6F 6F 6F 0A  ooooooooooooooo.
0110: FF EB 8A CF 9F 1D 78 F3   94 ED 45 9A B2 B0 A9 DB  ......x...E.....
response code : 200
Received Data: as Following:

Helllllllllllloooooooooooooooooo

.
.
Thanks :)
MiddlewareMagic Team


  • Receive FREE Updates


    FREE Email updates of our new posts Enter your email address:



  • Magic Archives

  • Copyright © 2010-2012 Middleware Magic. All rights reserved. | Disclaimer