Archive for June, 2013

JProfiler is a tool for profiling JVM. In this tutorial I will show how to start WSO2 carbon servers with JProfiler so you can monitor the carbon servers for memory, threads and performance.¬† I will use WSO2 ESB (Enterprise Service Bus) in this guide, however this is same for any carbon server AS, Greg, API Manager …etc.

Step 1 : Dowload the packs

Download the WSO2 ESB from http://wso2.com/products/enterprise-service-bus/ . You can find all the WSO2 products from the Product page of http://wso2.com/.

Download the JProfiler from http://www.ej-technologies.com/download/jprofiler/files

Step 2 : Start JProfiler

Start the JProfiler  sh $JProfiler_HOME/bin/jprofiler

Step 3 : Step into profiling

Click Start centre at the top left

JProfiler Start Center

JProfiler Start Center

Step 4 :  Select Local or remote

2 local or remote

Step 5 : Select the vendor
Select the vendor

Select the vendor

Step 6 : Select the port the ESB will run
Select the port the carbon server will run

Select the port the carbon server will run

Step 7 : Select the startup mood

wait for

Step 8

Copy the selected text

Step 9 : Copy the above selected text to the $ESB_HOme/bin/wso2server.sh
wso2 server sh
Step 9 : Start the ESB server.
Carbon server waiting for JProfiler

Carbon server waiting for JProfiler

You will find ESB is waiting for JProfiler GUI to start. So start KProfiler

Step 11 : Profiler started

Start profiler by pressing OK button and  ESB server will start.

JProfiler started with WSO2 ESB

JProfiler started with WSO2 ESB

  • Configure tomcat7 to start on port 80

Open /etc/tomcat7/server.xml and locate to the following lines

<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />

Change the port value to 80 as below.

<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
  • Start the tomcat7 as root user

After configuring tomcat7 to start on port 80, if you start the tomcat7 you will get errors in /etc/log/catalina.log file as below

SEVERE: Failed to initialize end point associated with ProtocolHandler ["http-bio-80"]
java.net.BindException: Permission denied <null>:80
at org.apache.tomcat.util.net.JIoEndpoint.bind(JIoEndpoint.java:406)
at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:610)
at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:429)
at org.apache.coyote.http11.AbstractHttp11JsseProtocol.init(AbstractHttp11JsseProtocol.java:119)

The reason for above error is only root users have the permission to start applications on port 80. So lets configure tomcat to start with rot privileges.
So open the file /etc/init.d/tomcat7 and locate to

# Define the tomcat username
TOMCAT_USER="${TOMCAT_USER:-tomcat}"

Then change the TOMCAT_USER to root as below.

# Define the tomcat username
TOMCAT_USER="root"

Please note that the location of the tomcat7 file is dependent of the OS.
Debian wheezy – /etc/default/tomcat7 instead of /etc/init.d/tomcat7
Ubuntu 13.04 – /etc/init.d/tomcat7
Ubuntu 14.04 – /etc/default/tomcat7

Those locations were reported by the viewers commented below

  • Restart the tomcat7
sudo service tomcat7 status

If everything is fine, you will get an output similar to

tomcat7 (pid¬† 24215) is running…

  • Verify tomcat7 running on port 80

You can get the pid of the tomcat7 process from the output of above command which is 24215 in mycase. Using the netstat command you can view what are the ports our tomcat7 process is running on.


sudo netstat -tulpn | grep 24215

If tomcat7 is started on port 80, you will get and output like below.

tcp        0      0 :::80                       :::*                        LISTEN      24215/java

By default WSO2 ESB is configured to accept HTTP messages. But you can configure ESB to accept TCP requests also.

  • Add the following to the $ESB_HOME/repository/conf/axis2/axis2.xml
<transportReceiver name="tcp" class="org.apache.axis2.transport.tcp.TCPTransportListener" >
</transportReceiver>
  • Create a proxy to accept the requests
    
    <?xml version="1.0" encoding="UTF-8"?>
    <proxy xmlns="http://ws.apache.org/ns/synapse" name="Udara-Tcp"   transports="tcp" startOnLoad="true" trace="disable">
       <description/>
       <target>
          <endpoint>
             <address uri=""/>
          </endpoint>
          <inSequence>
             <log level="full" />
          </inSequence>
          <outSequence>
             <send/>
          </outSequence>
       </target>
            <parameter name="transport.tcp.contentType">application/xml</parameter>
            <parameter name="transport.tcp.port">8280</parameter>
    </proxy>
    

    Note that  the parameter  tcp port is given as 8280 which means it is listening on port 8280.

Configure WSO2 ESB as a JMS sender

Posted: June 11, 2013 in esb, linux, ubuntu, wso2
Tags: , ,

The flow of the messages,

  1. ESB receives HTTP SOAP messages
  2. ESB send the JMS messages to the JMS broker
  3. JMS messages are stored in a queue
  4. JMS consumer picks the messages from the queue
Step 1: Setup WSO2 ESB
  • Download and extract ESB from $ESB_downlink
  • Configure ESB to send JMS messages
Step 2 : Setup JMS broker – ActiveMQ
  • Download ActiveMQ from $ActiveMQ_Downline
  • Copy the following jars to the $ESB_HOMe/repository/components/lib
  • Start ActiveMQ as ./activemq start
Step 3 : Setup JMS consumer
Step 4 : Send HTTP messages to the ESB
$JAVA_HOME/bin/jinfo -flag <flag> <process_id_of_jvm>

As an example, if you want to know the PermSize of the the jvm.

$JAVA_HOME/bin/jinfo -flag PermSize <process_id_of_jvm>
    losetup /dev/loop0 image_file.img
    kpartx -av /dev/loop0
    mount /dev/mapper/loop0p1 /mnt
    # now go to /mnt and make the change you want and unmount as below
    umount /mnt
    kpartx -dv /dev/loop0
    losetup -d /dev/loop0

References :

http://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/how-to-mount-a-kvm-image-file-787557/

http://blog.dustinkirkland.com/2008/10/mounting-kvm-disk-image.html

http://blog.dustinkirkland.com/2008/10/mounting-kvm-disk-image.html