Tuesday Oct 09, 2012

Set up Work Manager Shutdown Trigger in WebLogic Server 10.3.4 Using WLST

WebLogic Server's Work Managers provide a way to control work and allocated threads. You can set different scheduling guidelines for different applications, depending on your requirements.

There is a default self-tuning Work Manager, but you might want to set up a custom work manager in some circumstances: for example,

  • when you want the server to prioritize one application over another
  • when a response time goal is required, or
  • when a minimum thread constraint is needed to avoid deadlock.

The Work Manager Shutdown Trigger is a tool to help with stuck threads in which will do the following:

  1. Shut down the Work Manager.
  2. Move the application to Admin State (not active).
  3. Change the Server instance health state to failed.

Example of a Shutdown Trigger set on the config.xml for your domain:

<work-manager>
  <name>stuckthread_workmanager</name>
  <work-manager-shutdown-trigger>
    <max-stuck-thread-time>30</max-stuck-thread-time>
    <stuck-thread-count>2</stuck-thread-count>
  </work-manager-shutdown-trigger>
</work-manager>

Understand that any misconfiguration on the Work Manager can lead to poor performance on the server. Any changes must be done and tested before going to production.

How can one create a WorkManagerShutdownTrigger for WLS 10.3.4 using WLST?

You should be able to create a WorkManagerShutdownTrigger using WLST by following these steps:

edit()
startEdit()
cd('/SelfTuning/mydomain/WorkManagers')
create('myWM','WorkManager')
cd('myWM/WorkManagerShutdownTrigger')
create('myWMst','WorkManagerShutdownTrigger')
cd('myWMst')
ls()

JMS : Specifying Message Paging Directory on Weblogic server.

Two ways to configure or modify Paging directory, here the examples :

1.- Via config.xml file.

<paging-directory>C:\temp</paging-directory>

<jms-server>
<name>JMSServerMS1</name>
<target>MS1</target>
<persistent-store xsi:nil="true"></persistent-store>
<hosting-temporary-destinations>true</hosting-temporary-destinations>
<temporary-template-resource xsi:nil="true"></temporary-template-resource>
<temporary-template-name xsi:nil="true"></temporary-template-name>
<message-buffer-size>-1</message-buffer-size>
<paging-directory>C:\temp</paging-directory>
<paging-file-locking-enabled>true</paging-file-locking-enabled>
<expiration-scan-interval>30</expiration-scan-interval>
</jms-server>

-------------------------------------------------------


2 .- Via WLST (Weblogic scripting tool)


startEdit()
cd('/Deployments/JMSServerMS1')
cmo.setPagingDirectory('C:\\temp')
activate()

Configuring log4j on weblogic server for web applications.

To configure Weblogic server :

1.- Read the following link :
How to Use Log4j with WebLogic Logging Services

http://download.oracle.com/docs/cd/E12840_01/wls/docs103/logging/config_logs.html#wp1014610


Here the step by step :

2.- Go to WL_HOME/server/lib and copy wllog4j.jar to the server CLASSPATH, to do this copy the file into DOMAIN_NAME/lib
3.- Download log4j jar (in my case I had not the file) from http://logging.apache.org/log4j/1.2/download.html , in this case the last available version is log4j-1.2.17.jar, and copy the file into DOMAIN_NAME/lib (As step 2).
4.- In this case I activate log4j using WLST (Weblogic Scripting Tool), as bellow :

4.1 .- As you're using windows, execute a terminal window and go to DOMAIN_NAME/bin and run the file setDomainEnv.cmd (this file will set the environment to run java).
4.2 .- Execute the following comands :


C:\>java weblogic.WLST
wls:/offline> connect('username','password')
wls:/mydomain/serverConfig> edit()
wls:/mydomain/edit> startEdit()
wls:/mydomain/edit !> cd("Servers/$YOUR_SERVER_NAME/Log/$YOUR_SERVER_NAME";)
wls:/mydomain/edit/Servers/myserver/Log/myserver !> cmo.setLog4jLoggingEnabled(true)
wls:/mydomain/edit/Servers/myserver/Log/myserver !> save()
wls:/mydomain/edit/Servers/myserver/Log/myserver !> activate()


you can use ls() to list the objects under the WLS directory

this will activate log4j to use it with WLS.



Configuring WebLogic Logging Services


http://download.oracle.com/docs/cd/E12840_01/wls/docs103/logging/config_logs.html

To configure applications :

1. Create a log4j.properties file as bellow


log4j.debug=TRUE
log4j.rootLogger=INFO, R
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=/home/server.log
log4j.appender.R.MaxFileSize=100KB
log4j.appender.R.MaxBackupIndex=5
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSSS} %p %t %c – %m%n

2. Copy the file to /WEB-INF/classes directory. of your application.

3.- implement also the last action provided to activate log4j on WLS

How to set up secure cookie on weblogic server

WebLogic Server allows a user to securely access HTTPS resources in a session that was initiated using HTTP, without loss of session data. To enable this feature, add AuthCookieEnabled="true" to the WebServer element in config.xml:


<WebServer Name="myserver" AuthCookieEnabled="true"/>


Setting AuthCookieEnabled to true, which is the default setting, causes the WebLogic Server instance to send a new secure cookie, _WL_AUTHCOOKIE_JSESSIONID, to the browser when authenticating via an HTTPS connection. Once the secure cookie is set, the session is allowed to access other security-constrained HTTPS resources only if the cookie is sent from the browser.

Thus, WebLogic Server uses two cookies: the JSESSIONID cookie and the _WL_AUTHCOOKIE_JSESSIONID cookie. By default, the JSESSIONID cookie is never secure, but the _WL_AUTHCOOKIE_JSESSIONID cookie is always secure. A secure cookie is only sent when an encrypted communication channel is in use. Assuming a standard HTTPS login (HTTPS is an encrypted HTTP connection), your browser gets both cookies.

For subsequent HTTP access, you are considered authenticated if you have a valid JSESSIONID cookie, but for HTTPS access, you must have both cookies to be considered authenticated. If you only have the JSESSIONID cookie, you must re-authenticate.


To configure on Admin Console :

  1. Log into WebLogic Admin Console.
  2. Under Domain Structure, press click on <domainname>
  3. Select the "Web Applications" tab
  4. Select "Lock and Edit" in change center.
  5. Click on  "Auth Cookie Enabled" checkbox.
  6. Restart to confirm changes.
  7. Test an application and view the cookie which got stored as "JSESSIONID"

To Configure the Web application's weblogic-application.xml file:

  1. Run the following to extract the file from the web application's weblogic-application.xml: $PATH_JDK_HOME\binjar -xvf easy-web-examples.ear META-INF/weblogic-application.xml
  2. Add <cookie-secure>true</cookie-secure> between <session-descriptor> </session-descriptor> to the weblogic-application.xml.
  3. Run the following to repackage the file to the application: $PATH_JDK_HOME\bin\jar -uvf easy-web-examples.ear META-INF/weblogic-application.xml
  4. Deploy the application into WebLogic

For further information, please read the documentation on "Using Secure Cookies to Prevent Session Stealing " :

Time Zone on WebLogic Server

In order to configure the time zone with WebLogic Server, use the following JVM startup command:

-Duser.timezone=<timezone>

For example, in the java arguments in the admin console at Environments -> Servers -> Servername -> - Server Start tab, configure the startup settings that Node Manager will use to start the particular server. For example:

-Duser.timezone='America/Arizona'

There are many different time zones, each with its own code. For a complete list please refer to :

http://en.wikipedia.org/wiki/List_of_zoneinfo_time_zones

For testing, you can run the following code on WLS with a JSP, servlet, or deploying the class:

import java.util.Calendar;
import java.util.TimeZone;

public class TestTimeZone {

 public static void main(String[] args) {

   Calendar calendar = Calendar.getInstance();

   TimeZone timeZone = calendar.getTimeZone();

   System.out.println(" your Current TimeZone is : " + timeZone.getDisplayName());
   System.out.println(" Time Zone id : "+ timeZone.getID());

 }
}

Rotating WebLogic Server logs to avoid large files using WLST.

By default, when WebLogic Server instances are started in development mode, the server automatically renames (rotates) its local server log file as SERVER_NAME.log.n.  For the remainder of the server session, log messages accumulate in SERVER_NAME.log until the file grows to a size of 500 kilobytes.

Each time the server log file reaches this size, the server renames the log file and creates a new SERVER_NAME.log to store new messages. By default, the rotated log files are numbered in order of creation filenamennnnn, where filename is the name configured for the log file. You can configure a server instance to include a time and date stamp in the file name of rotated log files; for example, server-name-%yyyy%-%mm%-%dd%-%hh%-%mm%.log.

By default, when server instances are started in production mode, the server rotates its server log file whenever the file grows to 5000 kilobytes in size. It does not rotate the local server log file when the server is started. For more information about changing the mode in which a server starts, see Change to production mode in the Administration Console Online Help.

You can change these default settings for log file rotation. For example, you can change the file size at which the server rotates the log file or you can configure a server to rotate log files based on a time interval. You can also specify the maximum number of rotated files that can accumulate. After the number of log files reaches this number, subsequent file rotations delete the oldest log file and create a new log file with the latest suffix.

 Note: WebLogic Server sets a threshold size limit of 500 MB before it forces a hard rotation to prevent excessive log file growth.

To Rotate via WLST :

#invoke WLST
C:\>java weblogic.WLST

#connect WLST to an Administration Servera
wls:/offline> connect('username','password')

#navigate to the ServerRuntime MBean hierarchy
wls:/mydomain/serverConfig> serverRuntime()
wls:/mydomain/serverRuntime>ls()

#navigate to the server LogRuntimeMBean
wls:/mydomain/serverRuntime> cd('LogRuntime/myserver')
wls:/mydomain/serverRuntime/LogRuntime/myserver> ls()
-r-- Name myserver
-r-- Type LogRuntime

-r-x forceLogRotation java.lang.Void :

#force the immediate rotation of the server log file
wls:/mydomain/serverRuntime/LogRuntime/myserver> cmo.forceLogRotation()
wls:/mydomain/serverRuntime/LogRuntime/myserver>

The server immediately rotates the file and prints the following message:

<Mar 2, 2012 3:23:01 PM EST> <Info> <Log Management> <BEA-170017> <The log file C:\diablodomain\servers\myserver\logs\myserver.log will be rotated. Reopen the log file if tailing has stopped. This can happen on some platforms like Windows.>

<Mar 2, 2012 3:23:01 PM EST> <Info> <Log Management> <BEA-170018> <The log file has been rotated to C:\diablodomain\servers\myserver\logs\myserver.log00001. Log messages will continue to be logged in C:\diablodomain\servers\myserver\logs\myserver.log.>

To specify the Location of the archived Log Files

The following command specifies the directory location for the archived log files using the -Dweblogic.log.LogFileRotationDir Java startup option:

java -Dweblogic.log.LogFileRotationDir=c:\foo
-Dweblogic.management.username=installadministrator
-Dweblogic.management.password=installadministrator weblogic.Server

For more information read the following documentation ;

Using the WebLogic Scripting Tool

http://download.oracle.com/docs/cd/E13222_01/wls/docs103/config_scripting/using_WLST.html

Configuring WebLogic Logging Services

http://download.oracle.com/docs/cd/E12840_01/wls/docs103/logging/config_logs.html



About

Antonio De Juan Image

I was formerly a Senior Technical Support Engineer in the Middleware Application Server Team. I worked supporting Weblogic Server, Java EE, Jrockit, Coherence among other Oracle products.
You can find my new blog at :
http://antoniodejuan.wordpress.com/
Oracle WebLogic

Search

Categories
Archives
« October 2012
SunMonTueWedThuFriSat
 
1
2
3
4
5
6
7
8
10
11
12
13
15
16
17
19
20
21
22
23
24
25
26
27
28
29
30
31
   
       
Today