Followers

Thursday, November 7, 2013

WLST Script to Deploy the applicaiton

save the below content as  deploy.py file and run like

java weblogic.WLST deploy.py


###################****##############****######################## 
# Generic script applicable on any Operating Environments (Unix, Windows) 
# ScriptName    : deploy.py 
# Author        : Madhusudhana Chilipi 
###############     Connecting to AdminConsole     ################################# 

print '*********connecting to the AdminConsole*********'
connect('weblogic','weblogic1','t3://localhost:7001')

###############     Deploying applicaiton1    ################################# 

print '*********deploying applicaiton1********'

deploy('benefits', 'C:/MADHU/NewFolder/wlst/antdep/Benifits/benefits.war', targets='Server1')


###############     Starting the applicaitons   ################################# 
startApplication('benefits')

exit()

SSL steps

Appendix C:  SSL Configuration

#Create new Certs for
# create keystore in home directory
Login to [Server Long Name] with RDP

Open the command prompt

Navigate to D:\Oracle\Middleware\user_projects\domains\SSL

type 'keytool -genkey -keystore vendorTrust.jks -storepass srinfosolutions -alias [Server Long Name] -validity 3650 -keyalg RSA -keysize 2048' and press 'Enter'
When prompted, 'What is your first and last name?' type '[Server Long Name]' and press 'Enter'
When prompted, 'What is the name of your organizational unit?', type 'Global Solutions' and press 'Enter'
When prompted, 'What is the name of your organization?', type 'srinfosolutions' and press 'Enter'
When prompted, 'What is then name of your City or Locality?, type 'chennai' and press 'Enter'
When prompted, 'What is the name of your State or Province?', type 'TN' and press 'Enter'
When prompted, 'What is the two-letter country code for this unit?', type IN  and press 'Enter'
When prompted if entries are correct, verify and type 'yes' and press 'Enter'
When prompted to 'Enter key password for <[Server Long Name]> press ENTER.

keytool -certreq -alias 127.0.0.1 -storepass srinfosolutions -keyalg RSA -file certreq.csr -keystore vendorTrust.jks


#Download Certificate Authority files

https://uskan-secsa01.srinfosolutions.net/certsrv/

Click on Download a CA certificate, certificate chain, or CRL
Select 'Base64' encoding method and click on 'Download CA Certificate chain'
When prompted, 'Do you want to open or save this file?' click Save.
Save in a location for later
When 'Download Complete' dialog appears, click 'Open'
When 'certificates' application appears drill down to 'certificates' folder
Right-click [Portal Server Long name], select 'All Tasks->Export'
On Welcome screen, click 'Next'
On 'Export File Format' screen, click 'Base-64 encoded X.509(.CER) and click 'Next'

Right-click uskan-secs02, select 'All Tasks->Export'
On Welcome screen, click 'Next'
On 'Export File Format' screen, click 'Base-64 encoded X.509(.CER) and click 'Next'
On File to Export screen, type '[Directory]\s02.cer' as 'File name', click 'Next' where [Directory] is desired save location directory
On Completing the Certificate Export Wizard, click 'Finish'
On 'The export was successful' message, click 'Ok'

Right-click uskan-secsa01, select 'All Tasks->Export'
On Welcome screen, click 'Next'
On 'Export File Format' screen, click 'Base-64 encoded X.509(.CER) and click 'Next'
On File to Export screen, type '[Directory]\a01.cer' as 'File name', click 'Next' where [Directory] is desired save location directory
On Completing the Certificate Export Wizard, click 'Finish'
On 'The export was successful' message, click 'Ok'


#copy s02.cer and a01.cer from [Directory] to D:\Oracle\Middleware\user_projects\domains\SSL

# Import the Chain Certificate into the keystore as follows (need three different files (Cert Authority1, Cert Authority2):

Login to [Server Long Name] with RDP

Open the command prompt

Navigate to D:\Oracle\Middleware\user_projects\domains\SSL


Type 'keytool -import -alias uskan-secs02 -keystore vendorTrust.jks -trustcacerts -storepass srinfosolutions -file sec.cer' and press 'Enter'
If prompted 'Trust this certificate?', type 'yes' and press 'Enter'

Type 'keytool -import -alias USKAN-SECSA01 -keystore vendorTrust.jks -trustcacerts -storepass srinfosolutions -file a01.cer' and press 'Enter'

#Download Third Party certificates from TFS

Download the Trusted Certificates (ca.webcrf, GoDaddyClass2CA, GoDaddySecureCA, usadc-vsab8p01.srinfosolutions.net
) from D:\5_Setup\SSL to D:\Oracle\Middleware\user_projects\domains\SSL

# Import the Trusted Certificates into the keystore
Type “keytool -import -keystore vendorTrust.jks -storepass srinfosolutions -alias usadc-vsab8p01.srinfosolutions.net -file usadc-vsab8p01.srinfosolutions.net.cer” and press 'Enter'


Type “keytool -import -keystore vendorTrust.jks -storepass srinfosolutions -alias GoDaddyClass2CA -file GoDaddyClass2CA.cer” and press 'Enter'


Type “keytool -import -keystore vendorTrust.jks -storepass srinfosolutions -alias GoDaddySecureCA -file GoDaddySecureCA.cer”  and press 'Enter'

Type “keytool -import -keystore vendorTrust.jks -storepass srinfosolutions -alias ca.webcrf -file ca.webcrf.cer” and press 'Enter'
Repeat above steps for each Server

#Manual steps for SSL Configuration on WLS Servers
#WLS1 Managed Server

Logon to the server [FQDN Admin Server] with administrator privileges with terminal emulator using SSH.
Launch browser, go to ‘http://[FQDN Admin Server]:7001/console’, type valid username and password and click ‘Login’
Click ‘Servers’ link in the ‘Environment’ section.
Click on ‘WLS1’ link.
Click on ‘Keystores’ tab.
Click on ’Lock & Edit’ link in Change Center.
Select ‘Custom Identity and Custom Trust’ option in the ‘Keystores’ pull down menu
Enter ‘ D:\Oracle\Middleware\user_projects\domains\SSL\vendorTrust.jks in the ‘ Custom Trust Keystore  field.
Enter ‘JKS’ in the ‘Custom Trust Keystore Type’ field.
Enter ‘srinfosolutions’ in the ‘Custom Trust Keystore Passphrase’ and ‘Confirm Custom Trust Keystore Passphrase’ fields.
Click on the ‘Save’ button.
Click on ‘SSL’ tab and select ‘Keystores’ in the ‘Identity and Trust Locations’ pull down menu.
Enter [FQDN WLS1 Server] in Private Key Alias
Enter ‘srinfosolutions’ in the ‘Private Key Passphrase’, ‘Confirm Private Key Passphrase’ fields and click ‘Save’.
Click on ‘Advanced’ link and
Select ‘None’ in the ‘Host Name Verification’ pull down menu.
Click on check box ‘USE JSSE SSL’
Click on the ‘Save’ button

#WLS2 Managed Server

Click ‘Home’ link
Click ‘Servers’ link in the ‘Environment’ section.
Click on ‘WLS2’ link.
Click on ‘Keystores’ tab.
Select ‘Custom Identity and CustomTrust’ option in the ‘Keystores’ pull down menu
Enter ‘D:\Oracle\Middleware\user_projects\domains\SSL\vendorTrust.jks in the ‘Custom Trust Keystore’ field.
Enter ‘JKS’ in the ‘Custom Trust Keystore Type’ field.
Enter ‘srinfosolutions’ in the ‘Custom Trust Keystore Passphrase’ and ‘Confirm Custom Trust Keystore Passphrase’ fields.
Click on the ‘Save’ button.
Click on ‘SSL’ tab and select ‘Keystores’ in the ‘Identity and Trust Locations’ pull down menu.
Enter [FQDN WLS2 Server] in Private Key Alias
Enter ‘srinfosolutions’ in the ‘Private Key Passphrase’ and ‘Confirm Private Key Passphrase’ fields.
Click on ‘Advanced’ link and
Select ‘None’ in the ‘Host Name Verification’ pull down menu.
Click on check box ‘USE JSSE SSL’
Click on the ‘Save’ button

Click on ‘Activate Changes’ link
Click on ‘Home’ link           
Click ‘Clusters’ link in the ‘Environment’ section.
Click on ‘WLSCluster’ link
Click on ‘Control’ tab
At the bottom of the screen select the checkbox to the left of ‘Servers’ and click on the ‘Shutdown’ button and then click on ‘Force Shutdown Now’
Click ‘Yes’ button in Cluster Life Cycle Assistant Screen.
At the bottom of the screen select the checkbox to the left of ‘Servers’ and click on the ‘Start’ button
Click ‘Yes’ button in Cluster Life Cycle Assistant Screen.



to check validation of certificates

keytool -list -v -keystore vendorTrust.jks

keytool -delete -alias <> -keystore vendorTrust.jks



Saturday, October 26, 2013

Weblogic 10.3.6 Installation

Oracle Weblogic  10.3.6.0 installation steps


Oracle Weblogic 10.3.6.0 installation machine minimum requirements.

Operating SystemMinimum Physical Memory RequiredMinimum Available Memory Required
Linux2 GB4 GB
UNIX2 GB4 GB
Windows2 GB4 GB

Step 1 - Obtain the appropriate installation file as for your platform

The following installation is particularly in Windows

Step 2 - Determine the appropriate installation mode for your situation.There are three installation modes:                       graphical mode, console mode, or silent mode.

At present we are going to see Graphical Mode installation.

Step 3 - Double click on the .exe file and click Next.


Step 4 - choose create new middleware home directory at first time installation and click Next

Step 5- Register for security updates. In this uncheck the I receive the security updates and click           the Next.

Step 6- Choose installation Type
          Typical- All the software install in our machine 
          Custom- we can choose what we need while the installation time.
select what we need and click Next.

Step 7- Choose Product installation directories and click Next. 
          Here user can choose his own path also.

Step 8- Choose shortcut location this is for security only. click Next


Step 9- click Next. (This page contain which application install in our machine in installation time)

Step 10-  After reach 100% you can use weblogic in your machine.


            




















Sunday, September 22, 2013

Thread Dump in weblogic

Thread Dump in weblogic

Thread Dump:
  1. What is Thread dump?
  2. When we will take Thread dump? (Scenarios)
  3. How  Many  ways take Thread Dumps
  4. Thread Dump Generating Procedure
  5. What can I Analysis with Thread Dump?
  6. How can I analysis thread dump?
  7. Actions taken for Issue resolving
  8. References
Coming to step by step learning:
——————————–
What is Thread dump?
Thread Dump is a textual dump of all active threads and monitors of Java apps running in a Virtual Machine.
When we will take Thread dump? (Scenarios)

  1. Scenario 1: when server is hang Position, i.e. that time server will not respond to coming requests.

  1. 2. Scenario 2: While sever is taking more time to restart

  1. Scenario 3: When we are Getting exception like “java.lang.OutOfMemoryException”
  1. Scenario 4: Process running out of File descriptors. Server cannot accept further requests because sockets cannot be created
  1. 5. Scenario 5: Infinite Looping in the code
How many ways take Thread Dumps?

Many types we have to take a Thread dumps. As per your flexibility you can choose one Procedure. For analyzing take dumps some Intervals (like every 10mins, 10mins etc.).



Generating Dump Talking Procedures

1. Take Thread dump from Console by Using of below command
$kill -3 PID
(For Getting PID, Use this Command ps –ef | grep “java”)
Here The Output of the Thread Dump will be generated in the Server STDOUT.
(Note: If a process is not responding to kill -3 <PID> then it’s a JVM bug.)
2. Generation Thread Dump via Admin Console
  1. login to Admin Console(with Admin Username/Password)
  2. Click on Server, after choose your server
  3. Goto Monitoring TAB
  4. Goto Threads TAB, after click on “Dump Thread Stack” Button
  5. Now you can view the all the Threads in Same page
  6. Copy and paste in a txt file.
3.  We can Collect Thread Dump Using “WebLogic.Admin” which is deprecated, but still available or may be available in near future as well As i think because it is one of the best debugging utility for Admins.
java WebLogic.Admin -url t3://hostname: port -username Weblogic -password Weblogic THREAD_DUMP
This Thread Dumps will be generated in Servers STDOUT file

4. Getting Thread Dumps by using Jstack Utility
a.jstack –m <pid> (to connect to a live java process)

b. jstack –m [server_id@]<remote server IP or hostname>
(to connect to a remote debug server)
(-m Means print both java and native frames (mixed mode))
5. By Using WLST Script, can contain extension of (.py)

connect(‘weblogic’,’weblogic’,’t3://hostname:port′)
cd (”Servers’)
ls()
cd (‘AdminServer’)
ls()
threadDump()


Execute this Script in console.
What can I Analysis with Thread Dumps?
We need to analyze the thread dumps for analyzing running threads and their states to identifying.
How can I analysis thread dumps?

For analyze thread dumps we have lots of tools to understand easily thread states

  1. 1. samurai tool :
(Visit: http://yusuke.homeip.net/samurai/en/index.html)
In this tool you can identify all the Thread states by     identifying colors. We need to take care about Deadlocks and waiting state threads.
More Details:
    $ java -jar samurai.jar
After running we will get a Screen like below
Goto Thread dump tab
When Samurai detects a thread dump in your log, a tab named “Thread Dump” will appear.
You can just click “Thread dumps” tab to see the analysis result.
Samurai colors idle threads in gray, blocked threds in red and running threds in green.
There are three result views and Samurai shows “Table view” by default.
In many case you are just interested in the table view and the sequence view. Use the table view to decide which thread needs be inspected, the sequence view to understand the thread’s behavior.
You should takecare especially threds always in red.
  1. 2. TDA Tool :
(Visit: https://tda.dev.java.net/)

Actions taken for Issue resolving

  1. Classic Dead Locks : Look for the threads waiting for monitor entry
For Example :
“ExecuteThread: ‘95′ for queue: ‘default’” daemon prio=5 tid=0×411cf8 nid=0×6c waiting for monitor entry [0xd0f80000..0xd0f819d8]
at weblogic.common.internal.ResourceAllocator.release(ResourceAllocator.java:766)
at weblogic.jdbc.common.internal.ConnectionEnv.destroy(ConnectionEnv.java:590)
Reason: The above thread is waiting to acquire lock on Resource Allocator object. The next step is to identify the thread that is holding the Resource Allocator object
“ExecuteThread: ‘0′ for queue: ‘__weblogic_admin_rmi_queue’” daemon prio=5 tid=0×41b978 nid=0×77 waiting for monitor entry [0xd0480000..0xd04819d8]
at weblogic.jdbc.common.internal.ConnectionEnv.getPrepStmtCacheHits(ConnectionEnv.java:174)
at weblogic.common.internal.ResourceAllocator.getPrepStmtCacheHitCount   (ResourceAllocator.java:1525)
Reason: This thread is holding lock on source Allocator object, but is waiting for Connection Env object. This is a classic deadlock.


  1. 2. Threads in wait() state:
A sample dump:
“ExecuteThread: ‘10′ for queue: ‘SERV_EJB_QUEUE’” daemon prio=5 tid=0×005607f0 nid=0×30 in Object.wait() [83300000..83301998]
at java.lang.Object.wait(Native Method)
- waiting on <0xc357bf18> (a weblogic.ejb20.pool.StatelessSessionPool)
at weblogic.ejb20.pool.StatelessSessionPool.waitForBean(StatelessSessionPool.java:222)
Reason: The above thread would come out of wait() under two conditions
(Depending on application logic)
1)  One of the thread available in the execute queue pool would call notify() on this object when an instance is available. (If the wait() is indefinite).
This can cause the thread to hang for ever if server never does a notify() to this object.
2) If the timeout exceeds, the thread would throw an exception and back to execute queue thread pool

Tuesday, September 17, 2013

Enable GC logs in manged servers

Please do the configuration 

-verbose:gc –Xloggc:gc.log –XX:+PrintGCDetails –XX:+PrintGCTimeStamps

 

 

Friday, September 13, 2013

SOA Purge Scripts


To execute the purge scripts:

  1. In SQL*Plus, connect to the database AS SYSDBA:
    CONNECT SYS AS SYSDBA
    
  2. Execute the following SQL commands:
    GRANT EXECUTE ON DBMS_LOCK to USER;
    GRANT CREATE ANY JOB TO USER;
    
    where USER is the soainfra account to execute the scripts. These privileges are required to run the scripts.
  3. Load the purge scripts by executing the main purge script in the MW_HOME/SOA_ORACLE_HOME/rcu/integration/soainfra/sql/soa_purge directory.
    For a parallel purge, the debug logs from the jobs spawned by a parallel purge are logged into files created in the directory named SOA_PURGE_DIR. This directory must be accessible to the Oracle database.
  4. Create SOA_PURGE_DIR and grant write permissions to the soainfra user.
    mkdir -p /tmp/purgelog
    CREATE OR REPLACE DIRECTORY SOA_PURGE_DIR AS 'SERVER_DIRECTORY'
    
    where SERVER_DIRECTORY is the name of the directory to create (for example, '/tmp/purgelog/'). Note the required single quotes around the directory path.
  5. If you want to execute the scripts in debug mode, run common/debug_on.sql and set serverout to on in SQL*Plus. This step is optional.
    SET SERVEROUTPUT ON
    
    The logs from the spawned jobs are logged into the directory created in Step 4 (separate files per job). The rest of the logs are displayed on stdout (or the spool file, if configured).
    There are two options for purging:
    • Looped purge
    • Parallel purge
  6. Execute the purge scripts as shown below. Examples are provided for both options.
    1. For looped purge:
      DECLARE
      
         MAX_CREATION_DATE timestamp;
         MIN_CREATION_DATE timestamp;
         batch_size integer;
         max_runtime integer;
         retention_period timestamp;
      
        BEGIN
      
         MIN_CREATION_DATE := to_timestamp('2010-01-01','YYYY-MM-DD');
         MAX_CREATION_DATE := to_timestamp('2010-01-31','YYYY-MM-DD');
          max_runtime := 60;
          retention_period := to_timestamp('2010-01-31','YYYY-MM-DD');
         batch_size := 10000;
           soa.delete_instances(
           min_creation_date => MIN_CREATION_DATE,
           max_creation_date => MAX_CREATION_DATE,
           batch_size => batch_size,
           max_runtime => max_runtime,
           retention_period => retention_period,
           purge_partitioned_component => false);
        END;
        /
      
    2. For parallel purge:
      DECLARE
      
         max_creation_date timestamp;
         min_creation_date timestamp;
         retention_period timestamp;
        BEGIN
      
         min_creation_date := to_timestamp('2010-01-01','YYYY-MM-DD');
         max_creation_date := to_timestamp('2010-01-31','YYYY-MM-DD');
         retention_period := to_timestamp('2010-01-31','YYYY-MM-DD');
      
          soa.delete_instances_in_parallel(
           min_creation_date => min_creation_date,
           max_creation_date => max_creation_date,
           batch_size => 10000,
           max_runtime => 60,
           retention_period => retention_period,
           DOP => 3,
           max_count => 1000000,
           purge_partitioned_component => false);
      
       END;
      

How to Start Adminserver

Navigate to DOMAIN_HOME> run the startWeblogic.cmd command








Wednesday, August 7, 2013

Setting up the JMS resources through WLST script



The below WLST script help us to set up the JMS resources.
JMSConpiguration.py
connect('weblogic','weblogic', 't3://localhost:8000')

edit()
startEdit()

print 'Creating File Store'
cd('/')
cmo.createFileStore('BAMMonitoringJMSFileStore')
cd('/FileStores/BAMMonitoringJMSFileStore')
cmo.setDirectory('BAMMonitoringJMSFileStore')
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))


print 'Creating JMS Server'
cd('/')
print 'Creating JMS Server.'
cmo.createJMSServer('BAMMonitoringServer')
cd('/JMSServers/BAMMonitoringServer')
cmo.setPersistentStore(getMBean('/FileStores/BAMMonitoringJMSFileStore'))
cmo.setTemporaryTemplateResource(None)
cmo.setTemporaryTemplateName(None)
cmo.addTarget(getMBean('/Servers/AdminServer'))

print 'Creating JMS Module'
cd('/')
cmo.createJMSSystemResource('BAMJMSSystemResource')
cd('/JMSSystemResources/BAMJMSSystemResource')
cmo.addTarget(getMBean('/Servers/AdminServer'))
cmo.createSubDeployment('BAMSubdeDloyment')

print 'Creating Connection Factory'
cd('/')
cd('/JMSSystemResources/BAMJMSSystemResource/JMSResource/BAMJMSSystemResource')
cmo.createConnectionFactory('BAMMonitoringConnectionfactory')
cd('/JMSSystemResources/BAMJMSSystemResource/JMSResource/BAMJMSSystemResource/ConnectionFactories/BAMMonitoringConnectionfactory')
cmo.setJNDIName('jms/BAMMonitoringConnectionfactory')
#set('SubDeploymentName','BAMSubdeDloyment')
cd('/JMSSystemResources/BAMJMSSystemResource/JMSResource/BAMJMSSystemResource/ConnectionFactories/BAMMonitoringConnectionfactory/SecurityParams/BAMMonitoringConnectionfactory')
cmo.setAttachJMSXUserId(false)
cd('/JMSSystemResources/BAMJMSSystemResource/JMSResource/BAMJMSSystemResource/ConnectionFactories/BAMMonitoringConnectionfactory/ClientParams/BAMMonitoringConnectionfactory')
cmo.setClientIdPolicy('Restricted')
cmo.setSubscriptionSharingPolicy('Exclusive')
cmo.setMessagesMaximum(10)
#cd('/JMSSystemResources/BAMJMSSystemResource/JMSResource/BAMJMSSystemResource/ConnectionFactories/BAMMonitoringConnectionfactory/TransactionParams/BAMMonitoringConnectionfactory')
#cmo.setXAConnectionFactoryEnabled(true)
cd('/JMSSystemResources/BAMJMSSystemResource/JMSResource/BAMJMSSystemResource/ConnectionFactories/BAMMonitoringConnectionfactory')
cmo.setDefaultTargetingEnabled(true)

print 'Creating Queue'
cd('/')
cd('/JMSSystemResources/BAMJMSSystemResource/JMSResource/BAMJMSSystemResource')
cmo.createQueue('BAMMonitoringQueue')
cd('/JMSSystemResources/BAMJMSSystemResource/JMSResource/BAMJMSSystemResource/Queues/BAMMonitoringQueue')
set('JNDIName','jms/BAMMonitoringQueue')
set('SubDeploymentName','BAMSubdeDloyment')
cd('/JMSSystemResources/BAMJMSSystemResource/SubDeployments/BAMSubdeDloyment')
cmo.addTarget(getMBean('/JMSServers/BAMMonitoringServer'))

print 'JMS Resources are Successfully Created'
activate()
Executing the script:
Set the environment by executing the below script
$WL_Home/wlserver_10.3/server/bin/setWLSEnv.sh
Execute JMSConpiguration.py
Wlst.sh JMSConpiguration.py

Creating JMS Adapter connection factory through WLST script

The below WLST script will help us to create the JMS adapter connection factories. Before Executing the script change the details accordingly.

configureJMSAdapterConnection.py

TargetServerName='AdminServer'

soaHome='oracle/Middleware/Oracle_SOA1'

appPathJms=soaHome+'/soa/connectors/JmsAdapter.rar'
appNameJms='JmsAdapter'
moduleOverrideNameJms=appNameJms+'.rar'
JMSJNDIName = 'eis/wls/BAMQueueConnection'
JMSConnectionfactory='jms/BAMMonitoringConnectionfactory'
#Sever Details

moduleDescriptorName='META-INF/weblogic-ra.xml'
planPathJms=soaHome+'/soa/connectors/Plan_JMS.xml'

def createJMSConnectionFactory():

        edit()
        startEdit()
        startApplication(appNameJms)
        myPlanJms=loadApplication(appPathJms, planPathJms)
        makeDeploymentPlanVariable(myPlanJms,'ConnectionInstance_eis/Jms_JNDIName_13102979357209', JMSJNDIName , '/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="oracle.tip.adapter.jms.IJmsConnectionFactory"]/connection-instance/[jndi-name="'+JMSJNDIName+'"]/jndi-name',moduleOverrideNameJms)
        makeDeploymentPlanVariable(myPlanJms, 'ConfigProperty_eis/JMS_JNDIName_ConnectionFactory_Name_13102979357210', JMSConnectionfactory,'/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="oracle.tip.adapter.jms.IJmsConnectionFactory"]/connection-instance/[jndi-name="'+JMSJNDIName+'"]/connection-properties/properties/property/[name="ConnectionFactoryLocation"]/value',moduleOverrideNameJms)

        myPlanJms.save();
        save();
        cd('/AppDeployments/JmsAdapter/Targets');
        updateApplication(appNameJms, planPathJms);
        activate(block='true');
     
  
def makeDeploymentPlanVariable(wlstPlan, name, value, xpath,overrideName, origin='planbased'):
    wlstPlan.destroyVariable(name)
    wlstPlan.destroyVariableAssignment(name, overrideName, moduleDescriptorName)
    variableAssignment = wlstPlan.createVariableAssignment(name, overrideName, moduleDescriptorName)
    variableAssignment.setXpath(xpath)
    variableAssignment.setOrigin(origin)
    wlstPlan.createVariable(name, value)
    print 'moduleDescriptorName=',moduleDescriptorName


def main():
       adminURL='t3://localhost:9001'
       adminUserName='weblogic'
       adminPassword='welcome1'
       connect(adminUserName, adminPassword, adminURL)
       createJMSConnectionFactory()
       disconnect()
main()

Login to the server, cd to the folder where the script is available and execute the script as shown below.

%MIDDLEWARE_HOME%\wlserver_10.3\common\bin\wlst.cmd configureJMSAdapterConnection.py

JMS foreign server creation with WLST

The below WLST script help us to create a Foreign JNDI server in a local server for a JMS resources running in a remote server(in different domain).

The JMS clients can use the local JNDI configured in the local server to send the messages to the remote JMS server.

ConfigureForeignJMSServer.py

connect('weblogic','welcome1', 't3://localhost:9001')
edit()
startEdit()

cd('/')
cmo.createJMSSystemResource('
BAMForeginJMSResource')

cd('/SystemResources/BAMForeginJMSResource')
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))

cd('/JMSSystemResources/BAMForeginJMSResource/JMSResource/BAMForeginJMSResource')
cmo.createForeignServer('BAMForeignJMSServer')

cd('/JMSSystemResources/BAMForeginJMSResource/JMSResource/BAMForeginJMSResource/ForeignServers/BAMForeignJMSServer')
cmo.setDefaultTargetingEnabled(true)

cmo.setJNDIPropertiesCredential('welcome1')

cmo.setConnectionURL('t3://localhost:8000')
cmo.createJNDIProperty('java.naming.security.principal')

cd('/JMSSystemResources/BAMForeginJMSResource/JMSResource/BAMForeginJMSResource/ForeignServers/BAMForeignJMSServer/JNDIProperties/java.naming.security.principal')
cmo.setValue('weblogic')

cd('/JMSSystemResources/BAMForeginJMSResource/JMSResource/BAMForeginJMSResource/ForeignServers/BAMForeignJMSServer')

cmo.createForeignConnectionFactory('ForeignJMSConnectionFactory')

cd('/JMSSystemResources/BAMForeginJMSResource/JMSResource/BAMForeginJMSResource/ForeignServers/BAMForeignJMSServer/ForeignConnectionFactories/ForeignJMSConnectionFactory')
cmo.setLocalJNDIName('jms/BAMMonitoringConnectionfactory')
cmo.setRemoteJNDIName('jms/BAMMonitoringConnectionfactory')

cd('/JMSSystemResources/BAMForeginJMSResource/JMSResource/BAMForeginJMSResource/ForeignServers/BAMForeignJMSServer')
cmo.createForeignDestination('ForeignJMSDestination')

cd('/JMSSystemResources/BAMForeginJMSResource/JMSResource/BAMForeginJMSResource/ForeignServers/BAMForeignJMSServer/ForeignDestinations/ForeignJMSDestination')
cmo.setLocalJNDIName('jms/BAMMonitoringQueue')
cmo.setRemoteJNDIName('jms/BAMMonitoringQueue')

activate()


The same script can be modified to create a Foreign JNDI Server for other JMS providers.

Login to the server, cd to the folder where the script is available and execute the script as shown below.

%MIDDLEWARE_HOME%\wlserver_10.3\common\bin\wlst.cmd ConfigureForeignJMSServer.py

Tuesday, August 6, 2013

WLST Script for force Garbage collection


  1. # WLST script which calls GC.
  2. from java.util import *
  3. from javax.management import *
  4. import javax.management.Attribute
  5. print 'starting the script .... '
  6. connect('userid','password',url='t3://192.168.17:9001')
  7. state('AdminServer')
  8. # For Force GC ....
  9. domainRuntime()
  10. cd('/ServerRuntimes/AdminServer/JVMRuntime/AdminServer')
  11. print ' Performing Force GC...'
  12. cmo.runGC()
  13. disconnect()
  14. print 'End of script ...'
  15. exit()

WLST script to delete the JMS messages in the Queue

wls:/offline> connect('weblogic','welcome1','t3://localhost:7001')
wls:/WLST_domain/serverConfig> serverRuntime()
wls:/WLST_domain/serverRuntime>cd('JMSRuntime/AdminServer.jms/JMSServers/JMSServer-0/Destinations/SystemModule-0!Queue-0')
wls:/WLST_domain/serverRuntime/JMSRuntime/AdminServer.jms/JMSServers/JMSServer-0/Destinations/SystemModule-0!Queue-0> ls()
wls:/WLST_domain/serverRuntime/JMSRuntime/AdminServer.jms/JMSServers/JMSServer-0/Destinations/SystemModule-0!Queue-0> cmo.deleteMessages('')

Garbage Collection Notes



    The heap size influences the following:

– The GC frequency and the pause during collections
– The number of short and long term objects
– Fragmentation and locality problems

    An undersized heap with the concurrent collector leads to full GCs with an increase in load and also fragmentation problems.

    An oversized heap leads to increased collection times and locality problems (smear problem).

    The permanent generation may be a factor on applications that dynamically generate and load many classes (JSP and CFM application servers).

    Size the heap to handle peak and burst loads.

    Be sure to increase the memory as you increase the number of processors, since allocation can be parallelized.

    Configure as much memory as possible to the virtual machine unless you have problems with pauses.

    Do not choose a maximum value for the heap unless you know that the heap is greater than the default maximum heap size.

 – Explicit garbage collection calls (System.gc())  force a major collection.

    Measure the effectiveness of explicit GC calls by disabling them using the following option:

 -XX:+DisableExplicitGC

    Increase the MaxPermSize to accommodate the dynamically generated classes.

-XX:MaxPermSize=nnn

    Use -XX:+AggressiveHeap for throughput applications.

    Applications that rely on finalization (finalize method) will cause lag in garbage collection. Try reducing the dependency on finalization.

    The more CPUs, the more the advantages of the concurrent collector increase.

    The increase in the lifetime of objects increases the frequency of collection as live objects take heap space. So keep live objects to the needed minimum.

– Set a limit for pooled objects and do not set this value too high.

    Avoid setting old generation size too small as this may result in undersized heaps.

– An undersized heap may reduce collection time and lead to fragmentation and frequent full GCs.

    Increase young generation to decrease the frequency of collection, but this will increase pause. So choose a size for the young generation where the pause is tolerable.

    An increase in load will fill up the heap faster and this will increase the collection frequency. To reduce the collection frequency, increase the heap size.

    Use the default serial collector for smaller applications.

    For larger applications hosted on WebLogic Server, use the throughput collector.

-XX:+UseParallelGC

Read more: http://www.wikiconsole.com/wiki/?p=4662#ixzz2bF1JyO2c

Thursday, June 13, 2013

JVM parameter TLASIZE

A short background on TLA-sizing:

A TLA is a chunk of memory where a thread can do fast object allocation. Only objects that are small enough to fit in the TLA can be allocated there. This means that increasing the TLA size allows you to allocate larger objects in the TLAs. On the other hand, if you are using a nursery, all TLAs come from the nursery. This means that you can get fewer TLAs from the same sized nursery if you use a larger TLA size. Also, threads that don't allocate much get the same TLAs as other threads, which potentially wastes memory if they can not fill the TLAs.

In your case you get 500/8 = 62 TLAs from your nursery as opposed to 500/0.256 = 1953 TLAs if you would have used the default value (256k) for TLA size.

So, a large TLA size may mean that you can allocate larger object in TLAs (and thus in the nursery as opposed to in old space) but it may also increase the YC frequency.

You mention that all of you objects are about the same size. What size is that? I think it would be wise to make sure that the TLA size is large enough to fit those object in, but the TLA size should not be too large.

My feeling is that 8 MB is quite a large size for TLAs. There is a way to specify a range for the TLA size. You can set a minimum value and a preferred size. This allows for more dynamic (and hopefully more efficient) TLA sizing.

-XXtlaZize:min=2k,preferred=256k