Monthly Archive: March 2011

Application State Monitoring using WLST

There are scenarios when you would want to monitor the Application state of the currently deployed applications in the Domain using the WebLogic Server Runtime Mbeans. Properties like Application State.
This can be achieved through many ways like the Admin Console, JMX code, WLST scripts etc. WLST allows us to automate the monitoring.

WebLogic Server runtime MBeans are arranged in a hierarchical data structure. When connected to an Administration Server, you access the runtime MBean hierarchy by entering the serverRuntime or the domainRuntime command. The serverRuntime command places WLST at the root of the server runtime management objects, ServerRuntimeMBean; the domainRuntime command, at the root of the domain-wide runtime management objects, DomainRuntimeMBean. When connected to a Managed Server, the root of the runtime MBeans is ServerRuntimeMBean. The domain runtime MBean hierarchy exists on the Administration Server only; you cannot use the domainRuntimecommand when connected to a Managed Server.

The below post depicts the usage of WLST to monitor the Application State deployed in the domain.
Steps:
1. Script to monitor Application Runtime States
a. Save the below script ApplicationStatus.py on to your local machine.
**************************************************************************

 

connect('weblogic','weblogic','t3://localhost:8001')
domainRuntime()
cd('AppRuntimeStateRuntime/AppRuntimeStateRuntime')
AppList = cmo.getApplicationIds()
print '####### Application ####### Application State\n'
print '***********************************************\n'
for App in AppList:
print '#######',App ,' #######', cmo.getIntendedState(App)
print '***********************************************\n'

 

 

**************************************************************************
2. Execute the WLST Script
a. Set the CLASSPATH by running the setDomainEnv script from the
Alternatively you can set the CLASSPATH by specifying the –cp argument while executing the WLST Script
For Ex: java –cp $BEA_HOME/wlserver_10.3/server/lib/weblogic.jar weblogic.WLST ApplicationStatus.py

Downloads

You can download the WLST script from the below link.

ApplicationStatus.py

Note: Rename the file as ApplicationStatus.py

References:

http://download.oracle.com/docs/cd/E11035_01/wls100/config_scripting/monitoring.html

Regards,
Wonders Team. 🙂

Apache Administration FAQ’s

How to disable Case Sensitivity in Apache?

Apache is case sensitive. When you application is hosted in case-insensitive webserver(like IIS) and moved to case-sensitive webserver (like Apache) you may get some problems related to non availability of URLS(HTTP 404 error). Apach provides a module which helps to make URLs case-insensitive.

Open httpd.conf(your apache configuration file) and find out the below line

LoadModule speling_module modules/mod_speling.so

If the above module is avilable with your apache, turn on the CheckSpelling directive

CheckSpelling On

How to monitor Apache server status?

There is a built in module mod_status available in apache which helps to get server status from a web browser

To monitor Apache webserver,

Open httpd.conf(Placed at <Apache Install Dir>/conf/httpd.conf)

vi httpd.conf

Set the Location directive as below. It will alow only from 192.13.24.57

<Location /server-status>

SetHandler server-status

Order Deny,Allow

Deny from all

Allow from 192.13.24.57

</Location>

Set ExtendendStatus to on

ExtendedStatus on

Save the httpd.conf and restart the webserver

Now you can monitor your apache webserver with http://servername/server-status from 192.13.24.57 browser

How to know whether a library is built on 32-bit or 64-bit?

Type below command at shell

file /usr/local/apache2.2.11/lib/libapr-1.so.0.3.3

The output of above command is,

/usr/local/apache2.2.11/lib/libapr-1.so.0.3.3: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), not stripped

The output tells that the libapr-1.so.0.3.3 file is built on 32-bit machines

Monitoring WebLogic Server Runtime using WLST

There are scenarios when you would want to monitor the properties of your alive servers in the Domain using the WebLogic Server Runtime Mbeans. Properties like Server State, Server Health, Listen Port, Listen Addresses etc.

This can be achieved through many ways like the Admin Console, JMX code, WLST scripts etc. WLST allows us to automate the monitoring.

WebLogic Server runtime MBeans are arranged in a hierarchical data structure. When connected to an Administration Server, you access the runtime MBean hierarchy by entering the serverRuntime or the domainRuntime command. The serverRuntime command places WLST at the root of the server runtime management objects, ServerRuntimeMBean; the domainRuntime command, at the root of the domain-wide runtime management objects, DomainRuntimeMBean. When connected to a Managed Server, the root of the runtime MBeans is ServerRuntimeMBean. The domain runtime MBean hierarchy exists on the Administration Server only; you cannot use the domainRuntimecommand when connected to a Managed Server.

The below post depicts the usage of WLST to monitor the Server State of all the running servers in the domain.

Steps:

1. Script to monitor Server Runtime States

a. Save the below script ServerStatus.py on to your local machine.

**************************************************************************

 

username = 'weblogic'

password = 'weblogic'

URL='t3://localhost:8001'

connect(username,password,URL)

domainRuntime()

cd('ServerRuntimes')

servers=domainRuntimeService.getServerRuntimes()

for server in servers:

serverName=server.getName();

print '**************************************************\n'

print '##############    ', serverName,    '###############'

print '**************************************************\n'

print '##### Server State           #####', server.getState()

print '##### Server ListenAddress   #####', server.getListenAddress()

print '##### Server ListenPort      #####', server.getListenPort()

print '##### Server Health State    #####', server.getHealthState()

 

**************************************************************************

2. Execute the WLST Script

a.  Set the CLASSPATH by running the setDomainEnv script from the

Alternatively you can set the CLASSPATH by specifying the –cp argument while executing the WLST Script

For Ex:  java –cp $BEA_HOME/wlserver_10.3/server/lib/weblogic.jar  weblogic.WLST ServerStatus.py

Downloads

You can download the WLST script from the below link.

ServerStatus.py

Note: Save the script as ServerStatus.py

References:

http://download.oracle.com/docs/cd/E11035_01/wls100/config_scripting/monitoring.html

Regards,

Wonders Team. 🙂

How to Analyze verbosegc of IBM JDK

 

We can use IBM Pattern Modeling and Analysis Tool for this purpose.
Its a very simple and effective tool to analyze gc activity.
It provides many views like graph view, chart view and analysis view.

Details and download link can be found here

Download the software from the link above.

Start the tool using the following command line.

E:\tools\ga412>java -jar ga412.jar

Open the file (xxx_native_stderr.log)  that you want to analze.

Go to Analysis > Graph View All

It will open up the Chart View where you will be able to see the heap usage over time.

From the image below you will notice that the heap usage raches the max at around 13:40.

 

We need to check the server logs for any Out of Memory errors. Also need to check what the application is doing during that time.
The number of users accessing the application. If these don’t give enough information, we can take heapdumps and analyze it.

Reference :-

http://www-01.ibm.com/support/docview.wss?uid=swg27007240&aid=1

Changing default application in Jboss

The below post describes how we can change the default application deployed on the Jboss Server and changing the default ports to access the same.

By Default when a Jboss Server is started, it would deploy the ROOT.war file present in the $JBOSS_HOME/server/$PROFILE/deploy folder.

Hence when you access http://localhost:8080/ , it loads the default index page as below.

There could be scenarios, where you would like to customize this configuration and might want to deploy a custom application as a default application.

Steps to change the default application.

*******************************************************

1. Change the context-root for ROOT.war

By default, the web context root for the ROOT.war file is ‘/’, hence this application is picked up as the default  one.         Create a jboss-web.xml , with a new context root other than ‘/’ under $JBOSS_HOME/server/ $PROFILE/ deploy/ROOT.war/WEB-INF  folder.

<jboss-web>

<context-root>/root</context-root>

</jboss-web>

Now the ROOT.war file is available at http://localhost:8080/root/

2. Define context-root of custom application as ‘/’

In WEB-INF folder of your application, add a jboss-web.xml file with context-root as ‘/’.

A sample jboss-web.xml file would look like.

<?xml version="1.0"?>

<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 5.0//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_5_0.dtd">

<jboss-web>

<context-root>/root</context-root>

</jboss-web>

Now your custom application is available at http://localhost:8080/

Changing the default Jboss Web Server port from 8080

*******************************************************

By default, the Jboss Web Server runs on port 8080. Hence you need to specify the port while accessing the default application.

However we can change the default port of 8080 to HTTP port which is 80.

This port 8080 is defined in the  bindings-jboss-beans.xml file present under the $JBOSS_HOME/server/$PROFILE/ conf/bindingservice.beans/META-INF/ folder.

The port entry looks like below

<bean>

<property name="serviceName">jboss.web:service=WebServer</property>

<property name="port">8080</property>

<property name="description">JBoss Web HTTP connector socket; also drives the values for the HTTPS and AJP sockets</property>

Modify the port to 80.

Re-start the server and access your application at  http://localhost/ or any domain names  for example http://abc.com/

For further reading:

http://docs.redhat.com/docs/en-US/JBoss_Enterprise_Web_Platform/5/html/Getting_Started_Guide/The_JBoss_Server___A_Quick_Tour-Basic_Configuration_Issues.html

Cheers,

Wonders Team.:)

 

Unit Of Order with Distributed Destinations

The below post gives a good understanding of need of Unit Of Order with Distributed Destinations and ways to configure the same.

Message Unit-of-Order is a WebLogic Server value-added feature that enables a stand-alone message producer, or a group of producers acting as one, to group messages into a single unit with respect to the processing order (a sub-ordering). This single unit is called a Unit-of-Order (or UOO) and requires that all messages from that unit be processed sequentially in the order they were created.

The message processing of a single message is complete when a message is acknowledged, committed, recovered, or rolled back. Until message processing for a message is complete, the remaining unprocessed messages for that Unit-of-Order are blocked.

This feature works best when a group of messages from a single producer must be processed sequentially.

For example, producer A sends messages X, Y, and Z in a unit-of-order. An MDB picks up message X and processes it. Until the MDB instance commits the transaction, message Y and Z remain on the queue. Only when the MDB commits message X does message Y get processed, and so on.

Prerequisites:

1. A distributed destination pre configured.

You can refer the below link to do so.

http://weblogic-wonders.com/weblogic/2011/02/17/uniform-distributed-destinations-udd-feature-in-weblogic/

 

There are two ways to create a unit-of-order

1. Programmatically.

2. Administratively

Programmatically:  WebLogic supplies a weblogic.jms.extensions.WLMessageProducer class, which implements the javax.jms.MessageProducer interface.

It has two methods:

getUnitOfOrder(): To get the name of the current Unit Of Order.

setUnitOfOrder()To set the name of the Current Unit Of Order.

Usage:


queue = (Queue)(ctx.lookup(destName));
qsender = (WLMessageProducer) qs.createProducer(queue);
qsender.setUnitOfOrder();
uooname = qsender.getUnitOfOrder();
System.out.println("Using UnitOfOrder :" + uooname);

Administrative ways:

Steps to implement Unit Of Order feature with Distributed Destination:

NOTE: You can configure the Unit Of Order name at two levels.

1 . Connection Factory

2. Distributed Destination.

1:  Unit Of Order at Connection Factory level:

There are two types of Unit Of Order naming that is done.

User Defined Unit Of Order:  You can configure the Connection Factories to use User-Defined Unit Of Order name. All producers created from such a connection factory have Unit-of-Order enabled.

a.  Login into the admin console, navigate to the ConnectionFactory  –> Click on the DefaultDelivery subtab –> Select the type of Unit Of Order name that you would like to configure.

b. If you are selecting User Defined Unit Of Order, you need to specify the value for “User-generated Unit-of-Order Name:” attribute.

System Defined: If you want you can configure the system defined Unit Of Order name for the Connection Factory for each sessions.

2. Unit Of Order at the Distributed Destination level:

a. Navigate to the Distributed Destination –> General –> Advanced properties.

Enable the “Auto-generate Unit Of Order Name ” attribute.

Specify the routing algorithm as well. By default it would be Hash.


Hash, indicates that a message producer computes the member destination from the hashCode of the unit-of-order.

PathService indicates that the configured Path Service determines the member destination.

This completes the JMS Unit Of Order configuration.

This typical Unit Of Order configuration would look like below in the  config/jms/<systemModule>-jms.xml file.

 

<uniform-distributed-queue name="DistributedQueue-1">

<sub-deployment-name>subManaged</sub-deployment-name>

<default-targeting-enabled>false</default-targeting-enabled>

<attach-sender>supports</attach-sender>

<production-paused-at-startup>false</production-paused-at-startup>

<insertion-paused-at-startup>false</insertion-paused-at-startup>

<consumption-paused-at-startup>false</consumption-paused-at-startup>

<jndi-name>DistQueue</jndi-name>

<default-unit-of-order>true</default-unit-of-order>

<saf-export-policy>All</saf-export-policy>

<messaging-performance-preference>25</messaging-performance-preference>

<unit-of-work-handling-policy>PassThrough</unit-of-work-handling-policy>

<incomplete-work-expiration-time>-1</incomplete-work-expiration-time>

<load-balancing-policy>Round-Robin</load-balancing-policy>

<unit-of-order-routing>Hash</unit-of-order-routing>

<forward-delay>-1</forward-delay>

<reset-delivery-count-on-forward>true</reset-delivery-count-on-forward>

</uniform-distributed-queue>

 

Further reading:

http://download.oracle.com/docs/cd/E12840_01/wls/docs103/jms/uoo.html#wp1040259

Cheers,

Wonders Team. 🙂