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()

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());

 }
}
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