Tuesday, May 13, 2014

WLST script to Enable/Disable the debug flags in Weblogic Server

WLST script to Enable/Disable the debug flags in Weblogic Server


This tutorial explains the approach to enable/disable the debug flags in Weblogic Server.

The Debugging flags will help us to enable/disable the debugging for different modules in weblogic.

The flags can be enabled/disabled in different ways

Admin Console


Access admin console — http://localhost:7001/console
Navigate to Environment →Servers → <<Server>> → Debug



Select the required flags and click on Enable/Disable.



WLST Script


The below WLST script enable the Debug Flag ‘DebugSSL’ for configured servers

EnableORDisableDFlags.properties

serverflagconfigs=AdminServer=DebugSSL:false,MS1=DebugSSL:true


EnableORDisableDFlags.py
import re
from java.io import FileInputStreamdef EnableORDisableDFlags(): edit()
 startEdit()
 propInputStream = FileInputStream('EnableORDisableDFlags.properties')
 configProps = Properties()
 configProps.load(propInputStream)  
 
 serverflagconfigs = re.split(",",configProps.get("serverflagconfigs"))
 print serverflagconfigs
 
 for serverConfig in serverflagconfigs: 
 
   serverName=re.split("=",serverConfig)[0]
   config=re.split("=",serverConfig)[1]
   print config
   cd('/Servers/'+serverName+'/ServerDebug/'+serverName)
   flagName=re.split(":",config)[0]
   flagValue=re.split(":",config)[1]
   set(flagName,flagValue)
   print 'Modified the DFlag for '+serverName+' '+ flagName+':'+flagValue
 save()
 activate()  
   
  
def main():
    adminURL='t3://localhost:7001'
    adminUserName='weblogic'
    adminPassword='weblogic1'
    connect(adminUserName, adminPassword, adminURL)
    EnableORDisableDFlags();
    print 'Successfully Modified the DFlags'
    disconnect()
main()


Script -
https://github.com/techforum-repo/youttubedata/tree/master/scripts/wlst/EnableORDisableDFlags

Before executing the script, change the configurations as required.

Execute the script — <<Oracle_Home>>\oracle_common\common\bin\wlst.cmd EnableORDisableDFlags.py




Now the DebugFlag is Enabled/Disabled based on the configurations



JVM start arguments


The debug flags can be enabled/disabled through server start up arguments

Add the flags with -D to the server start up arguments through console Environment →Servers →<<Server>> →Server Start

-Dweblogic.debug.DebugSSL=false



Other option is add the debug flags to the start up file startWebLogic.cmd/startWebLogic.sh or startManagedWebLogic.cmd/startManagedWebLogic.sh based on which file is used to start the server.

e.g.

JAVA_OPTIONS=”${JAVA_OPTIONS} -Dweblogic.debug.DebugSSL=true

The changes will take effect after restarting the server

Debug flags for the Reference


DebugAbbreviation
DebugAppContainer
DebugAsyncQueue
DebugBootstrapServlet
DebugClassRedef
DebugClassSize
DebugCluster
DebugClusterAnnouncements
DebugClusterFragments
DebugClusterHeartbeats
DebugConfigurationEdit
DebugConfigurationRuntime
DebugConnection
DebugConsensusLeasing
DebugDGCEnrollment
DebugDRSCalls
DebugDRSHeartbeats
DebugDRSMessages
DebugDRSQueues
DebugDRSStateTransitions
DebugDRSUpdateStatus
DebugDeploy
DebugDeployment
DebugDeploymentService
DebugDeploymentServiceInternal
DebugDeploymentServiceStatusUpdates
DebugDeploymentServiceTransport
DebugDeploymentServiceTransportHttp
DebugDescriptor
DebugDiagnosticAccessor
DebugDiagnosticArchive
DebugDiagnosticArchiveRetirement
DebugDiagnosticCollections
DebugDiagnosticContext
DebugDiagnosticDataGathering
DebugDiagnosticFileArchive
DebugDiagnosticImage
DebugDiagnosticInstrumentation
DebugDiagnosticInstrumentationActions
DebugDiagnosticInstrumentationConfig
DebugDiagnosticInstrumentationEvents
DebugDiagnosticInstrumentationWeaving
DebugDiagnosticInstrumentationWeavingMatches
DebugDiagnosticJdbcArchive
DebugDiagnosticLifecycleHandlers
DebugDiagnosticQuery
DebugDiagnosticWatch
DebugDiagnosticWlstoreArchive
DebugDiagnosticsHarvester
DebugDiagnosticsHarvesterData
DebugDiagnosticsHarvesterMBeanPlugin
DebugDiagnosticsHarvesterTreeBeanPlugin
DebugDiagnosticsModule
DebugDomainLogHandler
DebugEjbCaching

DebugEjbCmpDeployment
DebugEjbCmpRuntime
DebugEjbCompilation
DebugEjbDeployment
DebugEjbInvoke
DebugEjbLocking
DebugEjbMdbConnection
DebugEjbPooling
DebugEjbSecurity
DebugEjbSwapping
DebugEjbTimers
DebugEmbeddedLDAP
DebugEmbeddedLDAPLogToConsole
DebugEmbeddedLDAPWriteOverrideProps
DebugEventManager
DebugFailOver
DebugFileDistributionServlet
DebugHttp
DebugHttpLogging
DebugHttpSessions
DebugIIOP
DebugIIOPConnection
DebugIIOPMarshal
DebugIIOPNaming
DebugIIOPOTS
DebugIIOPReplacer
DebugIIOPSecurity
DebugIIOPStartup
DebugIIOPTransport
DebugIIOPTunneling
DebugJ2EEManagement
DebugJAXPIncludeClass
DebugJAXPIncludeLocation
DebugJAXPIncludeName
DebugJAXPIncludeTime
DebugJAXPUseShortClass
DebugJDBCConn
DebugJDBCDriverLogging
DebugJDBCInternal
DebugJDBCONS
DebugJDBCRAC
DebugJDBCRMI
DebugJDBCSQL
DebugJMSAME
DebugJMSBackEnd
DebugJMSBoot
DebugJMSCDS
DebugJMSCommon
DebugJMSConfig
DebugJMSDispatcher
DebugJMSDistTopic
DebugJMSDurableSubscribers
DebugJMSFrontEnd
DebugJMSJDBCScavengeOnFlush
DebugJMSLocking
DebugJMSMessagePath
DebugJMSModule
DebugJMSPauseResume
DebugJMSSAF
DebugJMSStore
DebugJMST3Server
DebugJMSWrappers

DebugJMSXA
DebugJMX
DebugJMXCompatibility
DebugJMXCore
DebugJMXDomain
DebugJMXEdit
DebugJMXRuntime
DebugJNDI
DebugJNDIFactories
DebugJNDIResolution
DebugJTA2PC
DebugJTA2PCStackTrace
DebugJTAAPI
DebugJTAGateway
DebugJTAGatewayStackTrace
DebugJTAHealth
DebugJTAJDBC
DebugJTALLR
DebugJTALifecycle
DebugJTAMigration
DebugJTANaming
DebugJTANamingStackTrace
DebugJTANonXA
DebugJTAPropagate
DebugJTARMI
DebugJTARecovery
DebugJTARecoveryStackTrace
DebugJTAResourceHealth
DebugJTATLOG
DebugJTAXA
DebugJTAXAStackTrace
DebugJpaDataCache
DebugJpaEnhance
DebugJpaJdbcJdbc
DebugJpaJdbcSchema
DebugJpaJdbcSql
DebugJpaManage
DebugJpaMetaData
DebugJpaProfile
DebugJpaQuery
DebugJpaRuntime
DebugJpaTool
DebugLeaderElection
DebugLibraries
DebugLoadBalancing
DebugLoggingConfiguration
DebugMessaging
DebugMessagingBridgeRuntime
DebugMessagingBridgeRuntimeVerbose
DebugMessagingBridgeStartup
DebugMessagingKernel
DebugMessagingKernelBoot
DebugMuxer
DebugMuxerConnection
DebugMuxerDetail
DebugMuxerException
DebugMuxerTimeout
DebugPathSvc
DebugPathSvcVerbose
DebugRA
DebugRAClassloader
DebugRAConnEvents

DebugRAConnections
DebugRADeployment
DebugRALifecycle
DebugRALocalOut
DebugRAParsing
DebugRAPoolVerbose
DebugRAPooling
DebugRASecurityCtx
DebugRAWork
DebugRAWorkEvents
DebugRAXAin
DebugRAXAout
DebugRAXAwork
DebugRC4
DebugRSA
DebugReplication
DebugReplicationDetails
DebugRouting
DebugSAFAdmin
DebugSAFLifeCycle
DebugSAFManager
DebugSAFMessagePath
DebugSAFReceivingAgent
DebugSAFSendingAgent
DebugSAFStore
DebugSAFTransport
DebugSAFVerbose
DebugSNMPAgent
DebugSNMPExtensionProvider
DebugSNMPProtocolTCP
DebugSNMPToolkit
DebugSSL
DebugScaContainer
DebugSecurityAdjudicator
DebugSecurityAtn
DebugSecurityAtz
DebugSecurityAuditor
DebugSecurityCertPath
DebugSecurityCredMap
DebugSecurityEEngine
DebugSecurityEncryptionService
DebugSecurityJACC
DebugSecurityJACCNonPolicy
DebugSecurityJACCPolicy
DebugSecurityKeyStore
DebugSecurityPasswordPolicy
DebugSecurityPredicate
DebugSecurityRealm
DebugSecurityRoleMap
DebugSecuritySAML2Atn
DebugSecuritySAML2CredMap
DebugSecuritySAML2Lib
DebugSecuritySAML2Service
DebugSecuritySAMLAtn
DebugSecuritySAMLCredMap
DebugSecuritySAMLLib
DebugSecuritySAMLService
DebugSecuritySSL
DebugSecuritySSLEaten
DebugSecurityService
DebugSecurityUserLockout
DebugSelfTuning
DebugServerLifeCycle
DebugServerMigration
DebugServerStartStatistics
DebugStoreAdmin
DebugStoreIOLogical
DebugStoreIOLogicalBoot
DebugStoreIOPhysical
DebugStoreIOPhysicalVerbose
DebugStoreXA
DebugStoreXAVerbose
DebugTunnelingConnection
DebugTunnelingConnectionTimeout
DebugURLResolution
DebugWANReplicationDetails
DebugWTCConfig
DebugWTCCorbaEx
DebugWTCGwtEx
DebugWTCJatmiEx
DebugWTCTDomPdu
DebugWTCUData
DebugWTCtBridgeEx
DebugWebAppIdentityAssertion
DebugWebAppModule
DebugWebAppSecurity
DebugWorkContext
DebugXMLEntityCacheIncludeClass
DebugXMLEntityCacheIncludeLocation
DebugXMLEntityCacheIncludeName
DebugXMLEntityCacheIncludeTime
DebugXMLEntityCacheUseShortClass
DebugXMLRegistryIncludeClass
DebugXMLRegistryIncludeLocation
DebugXMLRegistryIncludeName
DebugXMLRegistryIncludeTime
DebugXMLRegistryUseShortClass


Saturday, May 3, 2014

WLST script to enable Backup/Archive configurations in weblogic server

WLST script to enable Backup/Archive configurations in weblogic server


By enabling the backup/archiving in Weblogic, the administration Server can automatically backups the domain configuration (the entire domain-name/config directory) during the server boot to DOMAIN_HOME\config-original.jar and config-booted.jar.

Also multiple versions of the domain config will be archived by the Administration Server, each time the domain configuration is modified into the DOMAIN_CONFIG\configArchive folder.

The configuration archives can be used for system restoration in cases where accidental configuration changes need to be reversed.

This tutorial explains how to use WLST script to enable backup/archive configurations.


WLST Script


The below WLST script will help us to enable the backup/archive configurations

EnableArchiving.py

adminURL='t3://localhost:7001'
adminUserName='weblogic'
adminPassword='weblogic1'
connect(adminUserName, adminPassword, adminURL)
domainRuntime()
edit()
startEdit()
cmo.setConfigBackupEnabled(true)
cmo.setArchiveConfigurationCount(5)
save()
activate()



Script
https://github.com/techforum-repo/youttubedata/blob/master/scripts/wlst/EnableArchiving.py

Execute the script

<<Oracle_Home>>\oracle_common\common\bin\wlst.cmd EnableArchiving.py



Verify the configuration


To verify the configuration- Login to admin console →Click on Domain in the left panel →Expand the Advanced in General Configuration section



When the Admin Server starts up it automatically makes a backup of DOMAIN_HOME/config directory and stores it in DOMAIN_HOME/config-original.jar(original configuration file while restarting the server) and once the start up completed(booted) successfully it makes a backup of DOMAIN_HOME/config directory and stores it in DOMAIN_HOME/config-booted.jar(the config file on which the server is booted successfully) .

Most of the cases both of the file contents will be same. If the server fails to boot successfully the config-booted.jar will not be generated and the old config-booted.jar file will be left as it is.



Also whenever the domain configuration is modified, the admin server archive the previous configurations to the DOMAN_HOME\configArchive folder.The files use the naming convention as config-number.jar, where number is the sequential number of the archive.After it reaches the maximum number of archive files specified in the configuration(ArchiveConfigurationCount — 5), older archive files will be discarded



Recover the configurations


Follow the below steps to recover the configurations from archive

Stop the servers

Rename the current <<DOMAIN-HOME>>/config folder to config-bkp

Create a folder with name config under <<DOMAIN-HOME>>

cd to <<DOMAIN-HOME>>/configArchive in a command prompt

Execute the below command(change the archive file name as required)

tar -xf config-1.jar -C <<DOMAIN-HOME>>\config



Start the server — now the configurations are restored from the archive.


Tuesday, April 29, 2014

WLST script to set the XA Transaction timeout values for a data source in weblogic server

WLST script to set the XA Transaction timeout values for a data source in weblogic server


This tutorial explains the approach to set some of the important timeout properties for XA data sources in weblogic server through WLST script.

Set XA Transaction Timeout


Enables WebLogic Server to set a transaction branch timeout based on the value for XaTransactionTimeout.

When enabled, the WebLogic Server Transaction Manager calls XAResource.setTransactionTimeout() before calling XAResource.start, and passes either the XA Transaction Timeout value or the global transaction timeout.

XA Transaction Timeout


The number of seconds to set as the transaction branch timeout.
If set, this value is passed as the transaction timeout value in the XAResource.setTransactionTimeout() call on the XA resource manager, typically the JDBC driver.

When this value is set to 0, the WebLogic Server Transaction Manager passes the global WebLogic Server transaction timeout in seconds in the method.

If set, this value should be greater than or equal to the global WebLogic Server transaction timeout.


XA Retry Duration


Determines the duration in seconds for which the transaction manager will perform recover operations on the resource. A value of zero indicates that no retries will be performed.
XA Retry Interval

The number of seconds between XA retry operations if XARetryDurationSeconds is set to a positive value.

Please note the above configurations are only available to the data sources created with XA supported driver


WLST Script


The below wlst script set the required XA timeout properties

SetXATimeoutProperties.py
def setXATimeoutProperties():
   dsName='JDBC Data Source-0'
   edit()
   startEdit()
       
   server='AdminServer'
   cd("Servers/"+server)
   target=cmo
 
   print '========================================='
   print 'Setting the timeout properties for DataSource....'
   print '========================================='  
           
   cd('/JDBCSystemResources/'+dsName+'/JDBCResource/'+dsName+'/JDBCXAParams/'+dsName)
   cmo.setXaSetTransactionTimeout(true)cd('/JDBCSystemResources/'+dsName+'/JDBCResource/'+dsName+'/JDBCXAParams/'+dsName)
   cmo.setXaTransactionTimeout(3000)cd('/JDBCSystemResources/'+dsName+'/JDBCResource/'+dsName+'/JDBCXAParams/'+dsName)
   cmo.setXaRetryDurationSeconds(300)cd('/JDBCSystemResources/'+dsName+'/JDBCResource/'+dsName+'/JDBCXAParams/'+dsName)
   cmo.setXaRetryIntervalSeconds(60)save()
   activate()print 'Timeout settings for the datasource '+dsName+' has been completed'
 
 
def main():
     
    adminURL='t3://localhost:7001'
    adminUserName='weblogic'
    adminPassword='weblogic1'
    connect(adminUserName, adminPassword, adminURL)
    setXATimeoutProperties()
    disconnect()main()

Script

https://github.com/techforum-repo/youttubedata/blob/master/scripts/wlst/SetXATimeoutProperties.py

Before executing the script change the configuration values as required

Execute the script — <<Oracle_Home>>\oracle_common\common\bin\wlst.cmd SetXATimeoutProperties.py



Restart the server after successful execution. Now the XA configurations are enabled as required.



Monday, April 28, 2014

WLST script to set the JDBC Connection timeout properties in weblogic server

WLST script to set the JDBC Connection timeout properties in weblogic server


There are different timeout properties in JDBC connection, this tutorial explains the approach to set some of the important JDBC Connection timeout properties in weblogic server through WLST script.

Inactive Connection Timeout


The number of inactive seconds on a reserved connection before WebLogic Server reclaims the connection and releases it back into the connection pool.
You can use the Inactive Connection Timeout feature to reclaim leaked connections — connections that were not explicitly closed by the application.


Connection Reserve Timeout


The number of seconds after which a call to reserve a connection from the connection pool will timeout.
When set to 0, a call will never timeout.
When set to -1, a call will timeout immediately.


Statement Timeout


The time after which a statement currently being executed will time out.
A value of -1 disables this feature.
A value of 0 means that statements will not time out.


oracle.jdbc.ReadTimeout


The property oracle.jdbc.ReadTimeout helps to set read timeout while reading from the socket.

oracle.net.READ_TIMEOUT for jdbc versions < 10.1.0.5 oracle.jdbc.ReadTimeout for jdbc versions >=10.1.0.5


oracle.net.CONNECT_TIMEOUT


The property oracle.net.CONNECT_TIMEOUT helps to set the login time out in Oracle.
WLST Script

The below WLST script will help us to set the JDBC connection timeout properties

SetJDBCTimeoutProperties.py
def setJDBCTimeoutProperties():
   dsName='CRM6EAIReference'
   edit()
   startEdit()
       
   server='AdminServer'
   cd("Servers/"+server)
   target=cmo
 
   print '========================================='
   print 'Setting the timeout properties for DataSource....'
   print '========================================='  
           
   cd('/JDBCSystemResources/'+dsName+'/JDBCResource/'+dsName+'/JDBCDriverParams/'+dsName+'/Properties/'+dsName)
   #cmo.destroyProperty(getMBean('/JDBCSystemResources/'+dsName+'/JDBCResource/'+dsName+'/JDBCDriverParams/'+dsName+'/Properties/'+dsName+'/Properties/oracle.net.CONNECT_TIMEOUT'))
   cmo.createProperty('oracle.net.CONNECT_TIMEOUT')


Script

https://github.com/techforum-repo/youttubedata/blob/master/scripts/wlst/SetJDBCTimeoutProperties.py

Before executing the script, change the configurations as required.

Execute the script — <<Oracle_Home>>\oracle_common\common\bin\wlst.cmd SetJDBCTimeoutProperties.py



Restart the server after successful execution. Now the JDBC connection timeout properties are set to the datasource.



Under advanced section



Wednesday, April 23, 2014

Error while creating datasource using WLST - java.lang.ClassCastException

Error while creating datasource using WLST - java.lang.ClassCastException

When we are creating the datasource through WLST script in weblogic server may may receive the following exception in create method.

Creating DataSource:  EAISOAMetadataSource  ....
Problem invoking WLST - Traceback (innermost last):
  File "/reuters/oracle/as01/wlst/GridLinkDatasourceCreation.py", line 115, in ?
  File "/reuters/oracle/as01/wlst/GridLinkDatasourceCreation.py", line 108, in main
  File "/reuters/oracle/as01/wlst/GridLinkDatasourceCreation.py", line 39, in createGridLinkJDBCResources
  File "<iostream>", line 528, in create
        at weblogic.management.scripting.EditHandler.create(EditHandler.java:531)
        at weblogic.management.scripting.WLScriptContext.create(WLScriptContext.java:332)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)

java.lang.ClassCastException: java.lang.ClassCastException: java.lang.reflect.InvocationTargetException cannot be cast to weblogic.management.scripting.ScriptException

I colud not able to find the exact root cause but able to resolve the issue "Undo All Changes" from weblogic console and re-exectiong the script.

Steps to resolve the issue

Login to weblogic admin console
Verify whether any changes are pending to be activated.
Perform Activate Changes or Undo All Changes


Re-execute the script, this time script will create the datasource successfully.