Wednesday, December 19, 2012

Resolving Exception Code “Please create at least one open period for this operating unit” in Invoice Processing


Steps to resolve Exception Code “Please create at least one open period for this operating unit” in Invoice Processing

What are accounting periods?
Accounting period in bookkeeping is the period with reference to which accounting books of any entity are prepared. Period for which a firm prepares its internal or external accounts; the period covered by the financial statements. For internal accounts, it may be a month or a quarter; for external accounts it is normally a period of 12 months

It is the period for which books are balanced and the financial statements are prepared. Generally, the accounting period consists of 12 months. However the beginning of the accounting period differs according to the jurisdiction. For example one entity may follow the regular calendar year, i.e. January to December as the accounting year, while another entity may follow April to March as the accounting period

In some of the ERP tools there are more than 12 accounting periods in a financial year

Accounting periods can have one of the following statuses:
Open: Journal entry and posting allowed
While executing any transaction, the transaction date must fall in an open period. If that period is not open then the system prevents us from proceeding any further

Closed: Journal entry and posting not allowed until accounting period is reopened. Reporting and inquiry allowed

Permanently Closed: Journal entry and posting not allowed. You cannot change this period status. Reporting and inquiry allowed

Never Opened: Journal entry and posting are not allowed. General Ledger assigns this status to any period preceding the first period ever opened in your calendar, or to any period that has been defined, but is not yet future-enterable. You cannot change this period status

Future: Journal entry is allowed, but posting is not. Your period is not yet open, but falls within the range of future-enterable periods you designated in the Set of Books window. You cannot change this period status without using the concurrent process to open the period

How to resolve Exception Code “Please create at least one open period for this operating unit” in Invoice Processing?
In case the Exception Code is displayed as below while Invoice Processing i.e. “Please create at least one open period for this operating unit”, in Invoice Processing, follow below steps
 Figure 1


1)      Logon to Oracle E-Business Suite

2)      Locate Payables, Vision Operations (USA) under Main Menu
 Figure 2


3)      Select Accounting Periods
 Figure 3


4)      Click … button next to Never Opened. Select Open from Control Statuses
 Figure 4

Monday, December 17, 2012

WebCenter Content Interface Branding for 11g - Part 1


This component is not much in terms of complexity but it is called for by nearly every client I have ever worked with. The primary objective: Can you change the Oracle logo to our logo?
Long ago it also occurred to me that there is another thing that would be handy as well: tell the user what instance they are logged into. Typically this is not an issues because most users will be in the production instance, and in truth, most of them are not aware of the development and testing instances. But after seeing a team member get confused on the instance and begin to test in production, I decided that the component needed to also state the instance name as well.

Requirements

So the requirements of this component are two:
1.       Change the logo to the customer’s logo
2.       Add the instance name to the heading
Static Home Page


Login Page


Dynamic Pages


Analysis of the requirements

By heading we mean to change this part of the interface that is common to both the top menus and the trays layouts:

The Oracle logo needs to change and the product name (“WebCenter Content”) will be extended to add the value of the environment variable InstanceName to it. The result will be the following heading:

Obviously we need to have the new logo image. But we also need to know where the other parts of the puzzle are.

Pages to change

The logo and heading appear on three pages:

·         The static home page

·         The login page



·         The dynamic page

On the dynamic page the heading is the same for the trays layout and the top menus layout.

Location of the images

By viewing the image information (in FireFox this is a right click – View Image Info) on the three pages we see that the images are as follows:
·         The static home page
o   http://dev:16200/cs/images/stellent/mailheadinglogo.gif
·         The login page
o   http://dev:16200/cs/resources/layouts/Trays/Oracle/oracle_logo.png
o   http://dev:16200/cs/resources/layouts/Top%20Menus/Oracle/oracle_logo.png
·         The dynamic page
o   http://dev:16200/cs/resources/layouts/Trays/Oracle/oracle_logo.png
o   http://dev:16200/cs/resources/layouts/Top%20Menus/Oracle/oracle_logo.png

Instance Description

Lastly, the Instance Description is an environment variable in the config.cfg file for the instance and can be set by manually editing the file or by using the SystemPropertiesapplet for the instance.
o   InstanceDescription=Development instance for CS

System changes needed

In order to accomplish the requirements for this component we will need to research and locate the templates, resources, queries, services and other parts of the system that require change.
My method is to start with what we know and go from there. What we know is the image names. So the first thing is to search the templates and idoc resources for the image file names. In 10g these were in the …/shared/config directory. In 11g, these have moved and are now in the WebCenter Content Home (typically Oracle_ECM1) under the …/ucm/idc/resources/core directory. My development instance in installed in a linux OS, so I can open a terminal to that directory and use grep to locate the files containing these image file names.

stellent/mailheadinglogo.gif

This image is called out in the following templates
·         ./templates/reviewer_mail.htm
·         ./templates/subscription_mail.htm
·         ./templates/contributor_mail.htm
·         ./templates/pr_publisher_mail.htm
·         ./templates/clbra_mail.htm
·         ./templates/query_notification_mail.htm
·         ./templates/reject_mail.htm
·         ./templates/error_page.htm
·         ./templates/pr_contributor_mail.htm
It is also referred to in the home_page_static_content resource in the ./idoc/std_page.idoc file.
This actually presents a small question that I would validate with the client. The requirement is the heading logo in the web pages. There is no mention of the logos in the various mail templates. So if they wish these to change then I would amend the requirement to include them. For this component we will leave these template changes to the reader as an exercise to extend the component. This article will only change the resource in the std_page.idoc file.

oracle_logo.png

This image is referred to in two templates:
·         ./templates/top_menus_layout.js
·         ./templates/trays_layout.js
In these templates, a variable (logoImage) is set to the image name. So we grep for the logoImage variable and find that it is in the std_nav.idoc file in thestd_navigation_header_top_row resource.
I also noticed that this same resource sets up the entire header row, including the description we want to adjust. It is in a variable called headerDescription.  Greping for this locates it in the std_javascript_header_functions resource of the std_page.idoc file.

What about the admin server?

The Oracle logo obviously appears in the admin server pages as well. But I have never had a client that wanted these pages to be changed since only the administrators would ever see them. But for completeness of this analysis we will include this as well. Using the same logic as the main interface analysis, the image used is the casbanner.png. And using grep to locate it, we find it in the admin_page_begin resource of the ./idoc/admin_page.idoc file.
Like the mail templates above, this change will be left to the reader as another exercise to extend the component.

New image considerations

When we replace the logo images we need to consider the shape of the image being replaced. The original images are
Image
width
height
mailheadinglogo.gif
133
19
oracle_logo.png
119
25
casbanner.png
119
25

When we consider replacing these with our new logo, it would be convenient if the new logo matches these dimensions but that is not always the case so we will need to keep that in mind when we make the component so that we maintain the aspect ratio of our new image.
We could also consider a component that would simply overwrite these images with our new image.  That would work as well but it would require that aspect ratios match exactly in order for layouts to be maintained properly.

Our new image, , is 200 x 100 in a file named sena.gif.

Design of the component

The analysis above indicates that our design is relatively simple. There will be three primary parts to the component:
1.       Templates – the top_menus_layout.js and the trays_layout.js templates will be overridden to use the new image.
2.       Resources
a.        the the home_page_static_content resource will be overridden to include the new image and its size as well as the page description
b.      std_navigation_header_top_row will be overridden to adjust the logo image size
c.       std_javascript_header_functions will be overridden to adjust the description
3.       Publish – the new images will be published to the weblayout directory structure to support the templates.
It is possible that during the creation and testing of the component that other templates or resources may be impacted.

Testing Considerations

As with any component, any time an oPatch is applied or the software is upgraded, this component should be tested. For this component it is relatively simple to regression test. Simply pull up the overwritten templates and resources and make sure that they are the same with exception of the change made.
Other than that, the standard testing is sufficient: no errors in the Content Server logs or in the Server Output.

To be Continued in part 2...

Friday, December 14, 2012

Starting WebCenter Content 11g on boot

Starting WebCenter Content 11g is a bit different from the startup of UCM 10g. With 11g, you can start only the managed server for the WebCenter Content instance or you can start the Admin Server with it, or you can start Node Manager, the Admin Server and the Managed Instance.

Starting Node Manager allows you to use the Admin Server to start and stop the WebCenter Content managed server from the browser. Starting Admin Server allows you to monitor the WebCenter Content managed server and to use.

Configuring to use Node Manager

To use Node Manager to start and stop WebCenter Content, you must first
  • Configure a machine
  • Add the Admin Server and Managed Server to the machine
  • Enable Node Manager to use the WebCenter Content startup scripts

Configure a machine

In WebLogic, a Machine is a logical representation of a physical server. The Admin Server uses the machine definition and the Node Manager to manage remote servers. During the initial configuration of WebCenter content there was the opportunity to configure machines. If you did this then you can skip this section. If not, then follow these steps to create a machine.
  1. If not started, then start the Admin Server. 
  2. Under Environment, select Machines.
     
  3. Select to create a new machine
     
  4. Give the machine a meaningful name and set the OS then select Next
     
  5. Complete the rest of the form and select Finish

Add the Admin Server and Managed Server to the machine

  1. Return to the home page and select Environment, Machines. 
  2. Select the name of the machine you just created
     
  3. Select the Servers tab
     
  4. Select to add a server
     
  5. Select the server to add
     
  6. Select Next. Repeat this to add all the servers needed.

Enable Node Manager to use the WebCenter Content startup scripts

The first step is to enable Node Manager to use the startup scripts. To do this, follow these steps:
  1. Log into your system as the user who installed WebCenter Content (oracle in my case)
  2. Navigate to the following directory
    MIDDLEWARE_HOME/oracle_common/common/bin
    MIDDLEWARE_HOME is the directory where Oracle Fusion Middleware is installed.
  3. Run the setNMProps.sh script to set the StartScriptEnabled property to true before starting Node Manager:
    ./setNMProps.sh
    This is a one-time action. After you run this script, you can skip this step before starting Node Manager again.
  4. Start Node Manager with the startNodeManager script.
    Linux script: WL_HOME/server/bin/startNodeManager.sh
    WL_HOME is the directory where Oracle WebLogic Server is installed.
  5. Stop the Node Manager and the Admin Server.

Set Node Manager to run as a startup service

The next step is to set the Node Manager to run as a service on startup. To do this, follow these steps:
  1. Log into Linux as root
  2. Create a new file in /etc/init.d named nodemanager containing the following:
    #!/bin/bash
    
    # nodemanager Oracle Weblogic NodeManager service
    #
    # chkconfig:   2345 85 15
    # description: Oracle Weblogic NodeManager service
    # 
    
    ### BEGIN INIT INFO
    # Provides: nodemanager
    # Required-Start: $network $local_fs $oracle-xe
    # Required-Stop:
    # Should-Start:
    # Should-Stop:
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: Oracle Weblogic NodeManager service.
    # Description: Starts and stops Oracle Weblogic NodeManager.
    ### END INIT INFO
    
    # Source function library.
    if [ -f /lib/lsb/init-functions ]
    then
        . /lib/lsb/init-functions
    elif [ -f /etc/init.d/functions ]
    then
        . /etc/init.d/functions
    fi
    
    # set Weblogic environment defining CLASSPATH and LD_LIBRARY_PATH
    # to start/stop various components.
    export MW_HOME=/u01/app/oracle/Middleware/
    #
    # Note:
    # The setWLSEnv.sh not only does a good job of setting the environment,
    # but also advertises the fact explicitly in the console! Silence it.
    #
    . $MW_HOME/wlserver_10.3/server/bin/setWLSEnv.sh > /dev/null
    
    # set NodeManager environment
    export NodeManagerHome=$WL_HOME/common/nodemanager
    NodeManagerLockFile=$NodeManagerHome/nodemanager.log.lck
    
    # check JAVA_HOME
    if [ -z ${JAVA_HOME:-} ]; then
        export JAVA_HOME=/u01/app/oracle/jdk1.6.0_31
    fi
    
    exec=$MW_HOME/wlserver_10.3/server/bin/startNodeManager.sh
    prog='nodemanager'
    user='oracle'
    
    is_nodemgr_running() {
        local nodemgr_cnt=`ps -ef        | \
            grep -i 'java '                  | \
            grep -i ' weblogic.NodeManager '  | \
            grep -v grep                  | \
            wc -l`
        echo $nodemgr_cnt
    }
    
    get_nodemgr_pid() {
        nodemgr_pid=0
        if [ `is_nodemgr_running` -eq 1 ]; then
            nodemgr_pid=`ps -ef             | \
                grep -i 'java '                 | \
                grep -i ' weblogic.NodeManager ' | \
                grep -v grep                 | \
                tr -s ' '                    | \
                cut -d' ' -f2`
        fi
        echo $nodemgr_pid
    }
    
    check_nodemgr_status () {
        local retval=0
        local nodemgr_cnt=`is_nodemgr_running`
        if [ $nodemgr_cnt -eq 0 ]; then
            if [ -f $NodeManagerLockFile ]; then
                retval=2
            else
                retval=3
            fi
        elif [ $nodemgr_cnt -gt 1 ]; then
            retval=4
        else
            retval=0
        fi
    
        echo $retval
    }
    
    start() {
        ulimit -n 65535
        [ -x $exec ] || exit 5
        echo -n $"Starting $prog: "
        su $user -c "$exec &"
        retval=$?
        echo
        return $retval
    }
    
    stop() {
        echo -n $"Stopping $prog: "
        kill -s 9 `get_nodemgr_pid` &> /dev/null
        retval=$?
        echo
        [ $retval -eq 0 ] && rm -f $NodeManagerLockFile
        return $retval
    }
    
    restart() {
        stop
        sleep 10
        start
    }
    
    reload() {
        restart
    }
    
    force_reload() {
        restart
    }
    
    rh_status() {
        local retval=`check_nodemgr_status`
        if [ $retval -eq 0 ]; then
            echo "$prog (pid:`get_nodemgr_pid`) is running..."
        elif [ $retval -eq 4 ]; then
            echo "Multiple instances of $prog are running..."
        else
            echo "$prog is stopped"
        fi
        return $retval
    }
    
    rh_status_q() {
        rh_status >/dev/null  2>&1
    }
    
    case "$1" in
        start)
            rh_status_q && exit 0
            $1
            ;;
        stop)
            rh_status_q || exit 0
            $1
            ;;
        restart)
            $1
            ;;
        reload)
            rh_status_q || exit 7
            $1
            ;;
        force-reload)
            force_reload
            ;;
        status)
            rh_status
            ;;
        condrestart|try-restart)
            rh_status_q || exit 0
            restart
            ;;
        *)
            echo -n "Usage: $0 {"
            echo -n "start|"
            echo -n "stop|"
            echo -n "status|"
            echo -n "restart|"
            echo -n "condrestart|"
            echo -n "try-restart|"
            echo -n "reload|"
            echo -n "force-reload"
            echo "}"
    
            exit 2
    esac
    exit $?
  3. Edit the nodemanager file and verify the following
    •  # chkconfig:   2345 85 15
      this line tells chkconfig to set the run levels at 2345 (same as Oracle database) it also puts the start at priority 85 and the stop at priority 15 (database is 80 and 05)
    • export MW_HOME=/u01/app/oracle/Middleware/
    • export JAVA_HOME=/u01/app/oracle/jdk1.6.0_31
    • user='oracle'
    • save and exit
  4. make it executable
    [root@dev init.d]# chgmod 755 nodemanager
    [root@dev init.d]#
    
  5. add it to the services list
    [root@dev init.d]# chkconfig --add nodemanager
    [root@dev init.d]#
  6. check that it is there with
    [root@dev init.d]# chkconfig --list|grep nodemanager
    nodemanager     0:off   1:off   2:off   3:on    4:on    5:on    6:off
    [root@dev init.d]#
  7. Test the service
    [root@dev init.d]# 
    [root@dev init.d]#
    
    [root@dev init.d]# service nodemanager start
    Starting nodemanager: 
    :
    :
    INFO: Plain socket listener started on port 5556
    [root@dev init.d]#
    
    [root@dev init.d]# service nodemanager status
    nodemanager (pid:21241) is running...
    [root@dev init.d]#
    

Set domain servers  to run as a startup service

Now that Node Manager starts automatically, we need to get the Admin Server and Managed Servers running.
  1. Log into Linux as root
  2. Create a directory called nm_scripts in the Middleware home and place these files there
    • dev_env.sh
      export wlsAdminServer="AdminServer"
      export nmUserID="weblogic"
      export wlsUserID="weblogic"
      export wlsPassword="welcome1"
      #export wlsHost=`hostname`
      export wlsHost="localhost"
      export nmPort="5556"
      export asPort="7001"
      export wlsAdminURL="t3://${wlsHost}:${asPort}"
      export wlsDomainName="dev_domain"
      export wlsMiddleWareHome="/u01/app/oracle/Middleware"
      export wlsDomainLocation="${wlsMiddleWareHome}/user_projects/domains/dev_domain"
      export wlsNodeManagerHome="${wlsMiddleWareHome}/wlserver_10.3/common/nodemanager"
      
    • startServers.sh
      #!/bin/sh
      #set the Middleware Home
      MW_HOME="/u01/app/oracle/Middleware"
      export MW_HOME
      #Set the WebLogic Server Home
      WL_HOME="${MW_HOME}/wlserver_10.3"
      export WL_HOME
      #Set the Domain Home
      DOMAIN_HOME="${MW_HOME}/user_projects/domains/dev_domain"
      export DOMAIN_HOME
      #Set the Scripts Home
      SCRIPT_HOME="${MW_HOME}/nm_scripts"
      export SCRIPT_HOME
      #Set the WLS environment varables
      . ${WL_HOME}/server/bin/setWLSEnv.sh >> /dev/null
      #Set the domain specific variables
      . ${MW_HOME}/nm_scripts/dev_env.sh
      #Change to the domain directory
      cd ${DOMAIN_HOME}
      #Execute the WLST Script
      java weblogic.WLST ${SCRIPT_HOME}/StartServers.py
      
    • StartServers.py
      import os
      if os.environ.has_key('wlsAdminServer'):
          wlsAdminServer = os.environ['wlsAdminServer']
      if os.environ.has_key('nmUserID'):
          nmUserID = os.environ['nmUserID']
      if os.environ.has_key('wlsUserID'):
          wlsUserID = os.environ['wlsUserID']
      if os.environ.has_key('wlsPassword'):
          wlsPassword = os.environ['wlsPassword']
      if os.environ.has_key('wlsAdminURL'):
          wlsAdminURL = os.environ['wlsAdminURL']
      if os.environ.has_key('wlsNodeManagerHome'):
          wlsNodeManagerHome = os.environ['wlsNodeManagerHome']
      if os.environ.has_key('nmPort'):
          nmPort = os.environ['nmPort']
      if os.environ.has_key('wlsHost'):
          wlsHost = os.environ['wlsHost']
      if os.environ.has_key('wlsDomainName'):
          wlsDomainName = os.environ['wlsDomainName']
      if os.environ.has_key('wlsDomainLocation'):
          wlsDomainLocation = os.environ['wlsDomainLocation']
      print '-- CONNECT TO NODE MANAGER --';
      try:
          nmConnect(nmUserID, wlsPassword, wlsHost, nmPort, wlsDomainName, wlsDomainLocation, 'plain')
      except:
          print '--NODE MANAGER IS NOT RUNNING OR NOT RESPONDING. CANNOT CONTINUE--'
          exit()
      print '-- START ADMIN SERVER --';
      nmStart(wlsAdminServer)
      connect(wlsUserID, wlsPassword, url=wlsAdminURL, adminServerName=wlsAdminServer)
      domainRuntime()
      serverLifeCycles = cmo.getServerLifeCycleRuntimes()
      for serverLifeCycle in serverLifeCycles:
          if (serverLifeCycle.getName() == 'URM_server1'):
                  if (serverLifeCycle.getState() != 'RUNNING'):
                          print 'Starting Server: ' + serverLifeCycle.getName()
                          start(serverLifeCycle.getName(), 'Server')
      print ' -- DISCONNECT FROM ADMIN SERVER --'
      disconnect()
      print '--DISCONNECT FROM NODE MANAGER --'
      nmDisconnect()
      exit()
      
    • statusServers.sh
      #!/bin/sh
      #set the Middleware Home
      MW_HOME="/u01/app/oracle/Middleware"
      export MW_HOME
      #Set the WebLogic Server Home
      WL_HOME="${MW_HOME}/wlserver_10.3"
      export WL_HOME
      #Set the Domain Home
      DOMAIN_HOME="${MW_HOME}/user_projects/domains/dev_domain"
      export DOMAIN_HOME
      #Set the Scripts Home
      SCRIPT_HOME="${MW_HOME}/nm_scripts"
      export SCRIPT_HOME
      #Set the WLS environment varables
      . ${WL_HOME}/server/bin/setWLSEnv.sh >> /dev/null
      #Set the domain specific variables
      . ${MW_HOME}/nm_scripts/dev_env.sh
      #Change to the domain directory
      cd ${DOMAIN_HOME}
      #Execute the WLST Script
      java weblogic.WLST ${SCRIPT_HOME}/StatusServers.py
      
    • StatusServers.py
      import os
      if os.environ.has_key('wlsAdminServer'):
          wlsAdminServer = os.environ['wlsAdminServer']
      if os.environ.has_key('nmUserID'):
          nmUserID = os.environ['nmUserID']
      if os.environ.has_key('wlsUserID'):
          wlsUserID = os.environ['wlsUserID']
      if os.environ.has_key('wlsPassword'):
          wlsPassword = os.environ['wlsPassword']
      if os.environ.has_key('wlsAdminURL'):
          wlsAdminURL = os.environ['wlsAdminURL']
      if os.environ.has_key('wlsNodeManagerHome'):
          wlsNodeManagerHome = os.environ['wlsNodeManagerHome']
      if os.environ.has_key('nmPort'):
          nmPort = os.environ['nmPort']
      if os.environ.has_key('wlsHost'):
          wlsHost = os.environ['wlsHost']
      if os.environ.has_key('wlsDomainName'):
          wlsDomainName = os.environ['wlsDomainName']
      if os.environ.has_key('wlsDomainLocation'):
          wlsDomainLocation = os.environ['wlsDomainLocation']
      try:
          nmConnect(nmUserID, wlsPassword, wlsHost, nmPort, wlsDomainName, wlsDomainLocation, 'plain')
      except:
          print '--NODE MANAGER IS NOT RUNNING OR NOT RESPONDING. CANNOT CONTINUE--'
          exit()
      adminStatus = nmServerStatus(wlsAdminServer)
      if (adminStatus == 'RUNNING'):
          connect(wlsUserID, wlsPassword, url=wlsAdminURL, adminServerName=wlsAdminServer)
      else:
          print '--CANNOT CONTINUE. ADMIN SERVER IS NOT RUNNING--'
          print '--DISCONNECT FROM NODE MANAGER --'
          nmDisconnect()
          exit()
      domainRuntime()
      serverLifeCycles = cmo.getServerLifeCycleRuntimes();
      for serverLifeCycle in serverLifeCycles:
              print 'Server: ' + serverLifeCycle.getName() + ', State: ' + serverLifeCycle.getState();
              if (serverLifeCycle.getState() == 'RUNNING'):
                      cd('ServerRuntimes/' + serverLifeCycle.getName());
                      jvm = cmo.getJVMRuntime();
                      print 'Java VM Vendor: ' + jvm.getJavaVMVendor();
                      print 'Heap Free Space: ' + repr(jvm.getHeapFreePercent()) + '%';
                      print 'Heap Size Current: ' + repr(jvm.getHeapSizeCurrent());
                      print 'Maximum Heap Size: ' + repr(jvm.getHeapSizeMax());
                      cd('/');
      print ' -- DISCONNECT FROM ADMIN SERVER --'
      disconnect()
      print '--DISCONNECT FROM NODE MANAGER --'
      nmDisconnect()
      exit()
      
    • stopServers.sh
      #!/bin/sh
      #set the Middleware Home
      MW_HOME="/u01/app/oracle/Middleware"
      export MW_HOME
      #Set the WebLogic Server Home
      WL_HOME="${MW_HOME}/wlserver_10.3"
      export WL_HOME
      #Set the Domain Home
      DOMAIN_HOME="${MW_HOME}/user_projects/domains/dev_domain"
      export DOMAIN_HOME
      #Set the Scripts Home
      SCRIPT_HOME="${MW_HOME}/nm_scripts"
      export SCRIPT_HOME
      #Set the WLS environment varables
      . ${WL_HOME}/server/bin/setWLSEnv.sh >> /dev/null
      #Set the domain specific variables
      . ${MW_HOME}/nm_scripts/dev_env.sh
      #Change to the domain directory
      cd ${DOMAIN_HOME}
      #Execute the WLST Script
      java weblogic.WLST ${SCRIPT_HOME}/StopServers.py
      
    • StopServers.py
      import os
      if os.environ.has_key('wlsAdminServer'):
          wlsAdminServer = os.environ['wlsAdminServer']
      if os.environ.has_key('nmUserID'):
          nmUserID = os.environ['nmUserID']
      if os.environ.has_key('wlsUserID'):
          wlsUserID = os.environ['wlsUserID']
      if os.environ.has_key('wlsPassword'):
          wlsPassword = os.environ['wlsPassword']
      if os.environ.has_key('wlsAdminURL'):
          wlsAdminURL = os.environ['wlsAdminURL']
      if os.environ.has_key('wlsNodeManagerHome'):
          wlsNodeManagerHome = os.environ['wlsNodeManagerHome']
      if os.environ.has_key('nmPort'):
          nmPort = os.environ['nmPort']
      if os.environ.has_key('wlsHost'):
          wlsHost = os.environ['wlsHost']
      if os.environ.has_key('wlsDomainName'):
          wlsDomainName = os.environ['wlsDomainName']
      if os.environ.has_key('wlsDomainLocation'):
          wlsDomainLocation = os.environ['wlsDomainLocation']
      print '-- CONNECT TO NODE MANAGER AND ADMINSERVER --';
      try:
          nmConnect(nmUserID, wlsPassword, wlsHost, nmPort, wlsDomainName, wlsDomainLocation, 'plain')
      except:
          print '--NODE MANAGER IS NOT RUNNING OR NOT RESPONDING. CANNOT CONTINUE--'
          exit()
      adminStatus = nmServerStatus(wlsAdminServer)
      
      if (adminStatus == 'RUNNING'):
          connect(wlsUserID, wlsPassword, url=wlsAdminURL, adminServerName=wlsAdminServer)
      else:
          print '--CANNOT CONTINUE. ADMIN SERVER IS NOT RUNNING--'
          
          print '--DISCONNECT FROM NODE MANAGER --'
          nmDisconnect()
          exit()
      domainRuntime()
      serverLifeCycles = cmo.getServerLifeCycleRuntimes()
      for serverLifeCycle in serverLifeCycles:
              if (serverLifeCycle.getState() == 'RUNNING') and (serverLifeCycle.getName() != wlsAdminServer ):
                      print 'Stopping Server: ' + serverLifeCycle.getName()
                      nmKill(serverLifeCycle.getName())
      print ' -- DISCONNECT FROM ADMIN SERVER --'
      disconnect()
      print '-- STOP ADMIN SERVER --';
      nmKill('AdminServer')
      print '--DISCONNECT FROM NODE MANAGER --'
      nmDisconnect()
      exit()
      
  3. Create a new file in /etc/init.d named wlsservers containing the following:
    #!/bin/bash
    
    # wlsservers Oracle Weblogic admin and managed servers
    #
    # chkconfig:   2345 86 14
    # description: Oracle Weblogic admin and managed servers
    # 
    
    ### BEGIN INIT INFO
    # Provides: wlsservers
    # Required-Start: $network $local_fs $oracle-xe
    # Required-Stop:
    # Should-Start:
    # Should-Stop:
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: Oracle Weblogic admin and managed servers.
    # Description: Starts and stops Oracle Weblogic admin and managed servers.
    ### END INIT INFO
    
    # Source function library.
    if [ -f /lib/lsb/init-functions ]
    then
        . /lib/lsb/init-functions
    elif [ -f /etc/init.d/functions ]
    then
        . /etc/init.d/functions
    fi
    
    #set the Middleware Home
    MW_HOME="/u01/app/oracle/Middleware"
    export MW_HOME
    
    #Set the WebLogic Server Home
    WL_HOME="${MW_HOME}/wlserver_10.3"
    export WL_HOME
    
    #Set the Domain Home
    DOMAIN_HOME="${MW_HOME}/user_projects/domains/lowes_domain"
    export DOMAIN_HOME
    
    #Set the Scripts Home
    SCRIPT_HOME="${MW_HOME}/nm_scripts"
    export SCRIPT_HOME
    
    #Set the WLS environment varables
    . ${WL_HOME}/server/bin/setWLSEnv.sh >> /dev/null
    
    #Set the domain specific variables
    . ${MW_HOME}/nm_scripts/lowes_env.sh
    
    #Change to the domain directory
    cd ${DOMAIN_HOME}
    
    
    execStart='java weblogic.WLST ${SCRIPT_HOME}/StartServers.py'
    execStop='java weblogic.WLST ${SCRIPT_HOME}/StopServers.py'
    execStatus='java weblogic.WLST ${SCRIPT_HOME}/StatusServers.py'
    prog='wlsservers'
    user='oracle'
    
    start() {
        echo -n $"Starting $prog: "
        su $user -c "$execStart &"
        retval=$?
        echo
        return $retval
    }
    
    stop() {
        echo -n $"Stopping $prog: "
        su $user -c "$execStop &"
        retval=$?
        echo
        return $retval
    }
    
    status() {
        echo -n $"Status $prog: "
        su $user -c "$execStatus &"
        retval=$?
        echo
        return $retval
    }
    
    restart() {
        echo -n $"Stopping $prog: "
        su $user -c "$execStop &"
        retval=$?
        echo $retval
        echo
        echo -n $"Starting $prog: "
        su $user -c "$execStart &"
        retval=$?
        echo
        return $retval
    }
    
    
    case "$1" in
        start)
            $1
            ;;
        stop)
            $1
            ;;
        restart)
            $1
            ;;
        status)
            $1
            ;;
        *)
            echo -n "Usage: $0 {"
            echo -n "start|"
            echo -n "stop|"
            echo -n "status|"
            echo -n "restart|"
            echo "}"
    
            exit 2
    esac
    exit $?
    
  4. Verify the data and settings in these files 
    • Edit the wlsservers file and verify the following
      # chkconfig:   2345 86 14
      this line tells chkconfig to set the run levels at 2345 (same as Oracle database)
      it also puts the start at priority 85 and the stop at priority 15 (database is 80 and 05)
      MW_HOME="/u01/app/oracle/Middleware"
      WL_HOME="${MW_HOME}/wlserver_10.3"
      DOMAIN_HOME="${MW_HOME}/user_projects/domains/lowes_domain"
      SCRIPT_HOME="${MW_HOME}/nm_scripts"
      export SCRIPT_HOME
      user='oracle'
      
    • save and exit
  5. make it executable
    [root@dev init.d]# chgmod 755 wlsservers
    [root@dev init.d]#
    
  6. Add it to the services list
    [root@dev init.d]# chkconfig --add wlsservers
    [root@dev init.d]#
    
  7. Check that it is there with
    [root@dev init.d]# chkconfig --list|grep wlsservers
    wlsservers 0:off   1:off   2:off   3:on    4:on    5:on    6:off
    [root@dev init.d]#
    
  8. Test the service
    [root@dev init.d]# service wlsservers start
    [root@dev init.d]#
    [root@dev init.d]# service wlsservers status
    [root@dev init.d]#
    [root@dev init.d]# service nodemanager stop
    [root@dev init.d]#
    

Reboot and verify

Reboot the system and verify that the service start.