Friday, May 27, 2011

Which Weblogic version is installed

Ever wondered what type of Weblogic version is installed including all the sub components? A simple script shows you this. This info is very usefull for Oracle Support, when you create a service request.

$ . setDomainEnv.sh
$ java weblogic.version -verbose

WebLogic Server 10.3.4.0 Fri Dec 17 20:47:33 PST 2010 1384255 ImplVersion: 10.3.4.0
Oracle Service Bus Server Side Dependencies 11.1 Thu Aug 19 02:10:08 PDT 2010 ImplVersion: 11.1.1.4
Oracle WebLogic Server Module Dependencies 10.3 Thu Oct 28 06:03:12 PDT 2010 ImplVersion: 10.3.4.0
Oracle WebLogic Server on JRockit Virtual Edition Module Dependencies 10.3 Thu Sep 23 15:02:15 PDT 2010 ImplVersion: 10.3.4.0
Oracle Virtual Machine Manager Client implementation ImplVersion: 1.1.0.0
WebLogic Descriptors for J2EE 1.5 Wed May 5 14:32:58 EDT 2010 ImplVersion: 1.5.0.0
WebLogic Descriptors for J2EE 1.5 Binding Bundle ImplVersion: 1.5.0.0
WebLogic Specific Descriptors 1.3 Tue Sep 14 18:48:42 PDT 2010 ImplVersion: 1.3.3.0
WebLogic Specific Descriptors 1.3 Binding Bundle ImplVersion: 1.3.3.0
WebLogic Datasource 1.9 Tue Oct 26 13:50:26 PDT 2010 ImplVersion: 1.9.0.0
WebLogic Datasource 1.9 Binding Bundle ImplVersion: 1.9.0.0
WebLogic Beangen Client Capable 1.7 Wed Feb 24 16:02:48 PST 2010 ImplVersion: 1.7.0.0
WebLogic Beangen 1.7 Binding Bundle ImplVersion: 1.7.0.0
WebLogic Management Core Interfaces Client Capable 2.8 Wed Aug 11 08:20:03 PDT 2010 ImplVersion: 2.8.0.0
WebLogic Management Core Interfaces 2.8 Binding Bundle ImplVersion: 2.8.0.0
WebLogic EJBGen Client Capable 1.1 Thu Jun 3 13:17:07 EDT 2010 ImplVersion: 1.1.0.2
WebLogic STAX Client Capable 1.8 Sat May 15 16:38:03 EDT 2010 ImplVersion: 1.8.0.0
WebLogic Utils Client Capable 1.9 Thu Nov 11 13:50:07 PST 2010 ImplVersion: 1.9.0.0
WebLogic SAAJ 1.6 Wed Jun 16 22:02:31 EDT 2010 ImplVersion: 1.6.0.0
WebLogic Apache Classes Client Capable 1.2 Thu Feb 18 22:06:19 PST 2010 ImplVersion: 1.2.0.1
WebLogic BeanInfo Caching and Discovery Client Capable 2.4 Sat Oct 25 20:46:29 PDT 2008 ImplVersion: 2.4.0.0
WebLogic Descriptor Client Capable 1.9 Tue Jul 20 16:03:09 EDT 2010 ImplVersion: 1.9.0.0
Oracle JFR 1.0 Thu Feb 18 19:06:33 PST 2010 ImplVersion: 1.0.0.0
WebLogic Diagnostics Core Interfaces Client Capable 2.5 Thu Jun 3 05:20:41 PDT 2010 ImplVersion: 2.5.0.0
WebLogic Diagnostics Logging Client Capable 1.2 Fri Dec 12 11:37:59 MST 2008 ImplVersion: 1.2.0.0
WebLogic Diagnostics Query Module Client Capable 1.2 Tue Oct 27 02:48:36 PDT 2009 ImplVersion: 1.2.0.0
WebLogic Diagnostics Instrumentor Tool 1.7 Tue May 18 03:51:46 PDT 2010 ImplVersion: 1.7.0.0
WebLogic Diagnostics Instrumentor Config Tool 1.7 Tue Jun 29 16:41:19 EDT 2010 ImplVersion: 1.7.0.0
WebLogic Diagnostics JRockit Flight Recorder Interfaces Client Capable 1.1 Fri Oct 29 16:32:05 EDT 2010 ImplVersion: 1.1.0.0
WebLogic i18n Runtime Support Client Capable 1.8 Fri Sep 10 08:12:34 EDT 2010 ImplVersion: 1.8.0.0
WebLogic i18n Build Support Client Capable 1.5 Fri Feb 19 15:03:15 EST 2010 ImplVersion: 1.5.0.0
WebLogic I18N tools Client Capable 1.3 Sun Nov 22 16:03:32 PST 2009 ImplVersion: 1.3.0.0
WebLogic Management JMX Interfaces 1.4 Thu Aug 12 11:16:22 PDT 2010 ImplVersion: 1.4.1.0
WebLogic Security Provider Generation Tool 1.5 Wed Oct 14 16:39:28 MDT 2009 ImplVersion: 1.5.0.0
WebLogic Security Provider Generation Tool Client Capable 1.5 Wed Oct 14 16:39:28 MDT 2009 ImplVersion: 1.5.0.0
WebLogic Messaging Kernel Client Capable 1.8 Mon Aug 23 21:42:11 EDT 2010 ImplVersion: 1.8.0.0
WebLogic Resource Pool Client Capable 1.7 Mon Sep 27 12:00:08 EDT 2010 ImplVersion: 1.7.0.0
WebLogic Socket Muxer API Client Capable 1.2 Thu Apr 1 21:16:27 EDT 2010 ImplVersion: 1.2.0.0
WebLogic RMI Client Capable 1.8 Fri Sep 24 18:35:21 EDT 2010 ImplVersion: 1.8.0.0
WebLogic Store Client Capable 1.7 Fri Dec 17 16:52:31

Thursday, May 26, 2011

Disable and Enable OSB Proxy services via WLST

The following WLST script shows you how to enable and disable OSB Proxy Services through WLST. The script is a bit sophisticated. It can enable/disable a single Proxy Service or a whole set of Proxy Services through a file.

Usage

Usage: Enable/Disable Proxy services
setProxyState [-d|-e] [-v] [-f proxy-list-file] admin-url wls-password [path-to-proxy]
-v verbose output
-d disable the proxy state
-e enable the proxy state
-f file with a list of proxy services

Note: 
The python script must by started from the common/bin directory in which the OSB is installed (ORACLE_HOME). I assume that the connection is made through the default 'weblogic' user. Make sure you have set the domain environment (setDomainEnv.sh).

Example Single Service (enable)
$ORACLE_HOME/common/bin/wlst.sh setproxystate.py -e t3://osb.vijfhuizen.com:7001 welcome1 MyProxyProject/MyProxyService_v2r0

Example via a file (disable)

$ORACLE_HOME/common/bin/wlst.sh setproxystate.py -d -f listofproxies.txt t3://osb.vijfhuizen.com:7001 welcome1 

The listofproxies.txt file is a list of Proxy Services that includes the whole project path without a beginning '/'. Example:

listofproxies.txt
=================
#
# This is a list of services that are read in this sequence
# to be enabled or enabled.
#
MyProxyProject/MyProxyService_v1r0
MyProxyProject/MyProxyService_v2r0
MyProxyProject/MyProxyService_v2r1

The whole python script is here.

setproxystate.py:
#
# Make sure you have set the domain environment settings:
#
# . $WLS_DOMAIN/bin/setDomainEnv.sh
# 
# Usage:
# 
# /opt/weblogic/Middleware/Oracle_OSB/common/bin/wlst.sh setproxystate.py -e -f listofproxies.txt t3://l2-mslfonapp02:7001 webl0gic
# 
import getopt 
import sys
import os

from com.bea.wli.sb.management.configuration import SessionManagementMBean
from com.bea.wli.sb.management.configuration import ALSBConfigurationMBean
from com.bea.wli.config import Ref
from com.bea.wli.monitoring import StatisticType
from com.bea.wli.sb.util import Refs
from com.bea.wli.sb.management.configuration import CommonServiceConfigurationMBean

wl_user="weblogic"
verbose=False

#########################################################################################

def ConnectToWLS(u, p, h):
  msg("Connect to " + h + " as user " + u)
  connect(u,p, h)
  domainRuntime()

def DisconnectFromWLS():
  msg("Disconnect")
  disconnect()

def CreateOSBSession():
  sessionName  = "SetProxyStateSession_" + str(System.currentTimeMillis())
  sessionMBean = findService(SessionManagementMBean.NAME, SessionManagementMBean.TYPE)
  sessionMBean.createSession(sessionName)
  msg("OSB Session Created: " + sessionName)
  return sessionMBean, sessionName

def ActivateSession(b, n, s, a):
  msg("Activate OSB Session: " + n)
  b.activateSession(n, a + " " + s)

def FindService(f, s, session, n):
  msg("Find proxy service: " + f + "/" + s)
  pxyConf = "ProxyServiceConfiguration." + n
  mbean = findService(pxyConf, 'com.bea.wli.sb.management.configuration.ProxyServiceConfigurationMBean')
  folderRef = Refs.makeParentRef(f + '/')
  serviceRef = Refs.makeProxyRef(folderRef, s)
  return serviceRef, mbean

def setStateService(b, s, a):
  if a == 'disable':
    msg("Disable Service")
    b.disableService(s)
  else:
    msg("Enable Service")
    b.enableService(s)

#########################################################################################

def usage():
  print "Usage: Enable/Disable Proxy services"
  print "setProxyState [-d|-e] [-v] [-f list-of-proxy-services] admin-url wls-password [proxy-service]"
  print "-v verbose output"
  print "-d disable the proxy state"
  print "-e enable the proxy state"
  print "-f file with a list of proxy services"

def main():

############################################################
## Parse Arguments
##
  proxy_file=""
  noofargs = 3
  try:
    opts, args = getopt.getopt(sys.argv[1:], "vdehf:", ["help"])

    for o, a in opts:
      if o == '-h':
        usage()
        exit()
      elif o == '-v':
        global verbose
        verbose = True
      elif o == '-d':
        state = "disable"
      elif o == '-e':
        state = "enable"
      elif o == '-f':
        proxy_file = a
        noofargs = noofargs - 1 
      else:
        print "Unknown argument."
        print ""
        usage()
        exit()

    if len(args) != noofargs:
      print "Invalid number of arguments."
      print ""
      usage()
      exit()

    admin_server = args[0]       
    wl_password = args[1]       

    if len(proxy_file) > 0:
      setStateListOfProxyService(proxy_file, state, wl_password, admin_server)
    else:
      proxy_service = args[2]
      setStateOfProxyService(proxy_service, state, wl_password, admin_server)

  except getopt.GetoptError, err:
    # print help information and exit: 
    print str(err)
    print ""
    usage()

############################################################

def msg(m):
  if verbose:
    print m

def setStateListOfProxyService(pfile, stateOnOff, wl_password, admin_server):
  try:
    ConnectToWLS(wl_user, wl_password, admin_server)

    file = open(pfile, "r")
    osbSession, sessionName = CreateOSBSession()

    appliedServices = ""
    for line in file.readlines():
      line = line.lstrip().rstrip()
      msg("Read line: " + line)
      if line.find("#") < 0 and len(line) > 0:
        relativePath = os.path.dirname(line)
        pServiceName = os.path.basename(line)
        appliedServices = appliedServices + " " + pServiceName
        service, sessionBean = FindService(relativePath, pServiceName, osbSession, sessionName)
        setStateService(sessionBean, service, stateOnOff)
  
    file.close()
    ActivateSession(osbSession, sessionName, appliedServices, stateOnOff)

    DisconnectFromWLS()

  except:
    print "Unexpected error: ", sys.exc_info()[0]
    dumpStack()
    raise

def setStateOfProxyService(pservice, stateOnOff, wl_password, admin_server):
  try:
    ConnectToWLS(wl_user, wl_password, admin_server)

    osbSession, sessionName = CreateOSBSession()

    relativePath = os.path.dirname(pservice)
    pServiceName = os.path.basename(pservice)

    service, sessionBean = FindService(relativePath, pServiceName, osbSession, sessionName)
    setStateService(sessionBean, service, stateOnOff)
    ActivateSession(osbSession, sessionName, pServiceName, stateOnOff)

    DisconnectFromWLS()

  except:
    print "Unexpected error: ", sys.exc_info()[0]
    dumpStack()
    raise

############################################################

main()
exit()

Wednesday, May 25, 2011

Using the SoapUI mockupserver in a OSB / SOA environment.

http://groovy.codehaus.org/When developing applications you always need to connect to others systems. Those systems are not always available or not in place at the right time. A mock-up server, also known as stub server, is a good temporary solution. In the product stack of SoapUI a very good mock-up server is available. Apart of a nice GUI interface to develop the mock services, scripting based on Groovy, it is free of license:-)

Info on SoapUI Mockup server:
In your development environment you should place the mock-up server along your OSB and/or SOA development server. Deploy your mock-up services to the mock-up server. Now make sure your endpoints of your services are pointing to the mock-up server and you are able to test.
To make it even transparent, place an Apache webserver in front of the OSB/SOA and mock-up server and let Apache decide of the service call is being executed on the OSB/SOA server or on the mock-up server.

With de deploy server (your workstation or a central deploy server) you deploy your OSB and/or SOA artefacts as normally to the server. You also deploy your SoapUI project to the mock-up server.
With Apache you control via rewrite rules if the request for tht service is passed to the OSB/SOA Server or to the mock-up server.

Apache Rewrite
To rewrite your request to the OSB/SOA server or the Mockup server is done in the Apache config file. Create a separate file to read this. Here is an example

#
# This files shows the list of services that are being stubbed/mock-uped.
#

#
# GENERIC, DO NOT CHANGE
#
LoadModule proxy_module modules/mod_proxy.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule proxy_http_module modules/mod_proxy_http.so

# Enable rewrite engine
RewriteEngine On
RewriteLogLevel 9
RewriteLog /data/www/logs/stub_rewrite.log
#
#
# OFF: GENERIC, DO NOT CHANGE

#
# Add here your stubbed services
#
RewriteRule ^/MyProject/MyService http://mockupserver.vijfhuizen.com:8080/MyProject/MyService [P]

SoapUI Mockup Server
A lot of discussing is going on on the SOapUI mockup server how to start and stop it as a background process. Here is a script to stop and start this in  the background.
#!/bin/bash
#
# soapui_mockupserver: Start the Eviware SoapUI Mockup Server
#
# chkconfig: 23 99 5
# description:  Start the Eviware SoapUI Mockup Server
#
#

# Source function library.
. /etc/rc.d/init.d/functions
SOAPPID=`ps -ef | grep mockservicerunner.sh | grep -v grep | awk ' { print $2 }'`
BAD_USER="This script should be run as root or as weblogic user. Exiting......."

if [ "$USER" != 'root' -a "$USER" != 'weblogic' -a "$USER" != '' ]; then echo $BAD_USER && exit 1;fi

if [ "$USER" == 'root' -o "$USER" == '' ]; then SOAPUI_DIR=`su - weblogic -c 'echo $SOAPUI_DIR'`;fi

cd $SOAPUI_DIR/bin

start()
{
        echo -n $"Starting $0"
        if [ "$USER" == 'root' -o "$USER" == '' ]; then
          su -c 'nohup $SOAPUI_DIR/bin/mockservicerunner.sh /data/mockup/mockup-services-soapui-project.xml -p 8080 -Djava.awt.headless=true -f /data/mockup/output 2>&1 &' - weblogic
        else
                 nohup $SOAPUI_DIR/bin/mockservicerunner.sh /data/mockup/mockup-services-soapui-project.xml -p 8080 -Djava.awt.headless=true -f /data/mockup/output  2>&1 &
        fi
        echo
  echo "Restart Apache gracefully..."
  for i in `ls /etc/init.d/*fon`
  do 
    echo $i graceful
    $i graceful
  done
}

stop()
{
        echo -n $"Shutting down $0"
        for i in `ps -ef | grep soap | grep -v $0 | awk ' { print $2 }'`
        do
          echo -n " $i"
          kill -9 $i
        done
        unset SOAPPID
        echo
}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart|reload)
        stop; start
        ;;
  condrestart)
        stop; start;
        ;;
  status)
        if [ $SOAPPID ]; then echo "Running"; else echo "Not running";fi
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|reload|condrestart}"
        exit 1
esac

exit 0

Friday, May 13, 2011

OSB/SOA: Performance Improvement with DBAdapter and Toplink

After struggeling with performance issues on the production environment, we fixed a major performance and stability improvement on our OSB environment. This solution is also valid for the SOA Suite.

When you use the DbAdapter to query one-to-many (1:M) table sctructure, Toplink is reading the whole result structure into memory. If you have a large amount of data (milions of records) and you use this OSB Proxy Service or SOA Composite very often, a few times per second, you can expect the Java memory is aggressively used and the Weblogic server is doing a lot of garbage collection. This can even result into time-outs or even out-of-memory errors.

The fix is rather simple, but this can not be done via JDeveloper or Eclipse via the common interface. You have to edit the following file and change the default value from true to false:

<DBAdapterFunction>-or-mappings.xml: <batch-reading>false</batch-reading>

Reference: Toplink Optimaztion