Thursday, April 17, 2014

WLST script to update Graceful Shutdown parameters in weblogic server

WLST script to update Graceful Shutdown parameters in weblogic server


A graceful shutdown gives WebLogic Server subsystems time to complete certain application processing currently in progress.

Graceful Shutdown


The Graceful Shutdown command transitions a server instance from the RUNNING state to the SHUTDOWN state, allowing work in process to be handled gracefully, with this sequence of state transitions:

RUNNING > SUSPENDING > ADMIN > SHUTTING_DOWN > SHUTDOWN

Controlling Graceful Shutdown


Ignore Sessions During Shutdown — If you enable this option WebLogic Server will drop all HTTP sessions immediately, rather than waiting for them to complete or timeout. Waiting for abandoned sessions to timeout can significantly lengthen the graceful shutdown process, because the default session timeout is one hour.

Graceful Shutdown Timeout — Specifies a time limit for a server instance to complete a graceful shutdown. If you supply a timeout value, and the server instance does not complete a graceful shutdown within that period, WebLogic Server performs a forced shutdown on the server instance.

This tutorial explains the approach to update graceful update parameters through WLST script in weblogic

WLST Script


The script will help us to update the Graceful Shutdown parameter for the servers in the weblogic domain.

UpdateGracefulShutdownParameters.py


Script

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

Before executing the script, change the configurations as required.

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

Now the Graceful Shutdown Parameters updated for all the servers in the domain




Monday, April 14, 2014

Backing up the MDS Repository Artifacts - Oracle SOA Suite 11g

Backing up the MDS Repository Artifacts - Oracle SOA Suite

In Oracle SOA Suite 11g and Oracle SOA Suite 12c , all the common artifacts , the deployed composites and the common configurations are stored in the MDS database schema. Sometimes there is a possibility of MDS schema getting corrupted (the best example is the composites getting corrupted frequently)those scenario we will not be able to bring up the soa-infra and also we may loose all the deployments.

Backing up the MDS artifacts is the the solution for these kind of issues.

In this post i will be explaining some of the different options to back up the MDS artifacts.

The best approach is do a full back up of MDS repository schema using database backup utilities(dbexp).The backup can be restored if there is any issue with the MDS schema.

EM console - MDS configuration Page :

Right click on soa-infra and click on Administration and MDS Configuration.
Click Export on MDS Configuration page.


This will export the MDS artifacts to local machine as zip file.




Thursday, April 3, 2014

Re-Targeting the singleton Applications to a single OSB node through WLST script

Re-Targeting the singleton Applications to a single OSB node through WLST script

While setting up a OSB cluster environment some of the singleton applications should be targeted to a single node in the cluster.Also we have to make sure these applications are targeted to the active OSB node in the cluster.

The below WLST script will help us to re-target the singleton applications to a single active OSB node.

ReTargetSingletontoActiveNode.py

adminURL='t3://localhost:8080
adminUserName='weblogic'
adminPassword=welcome1
connect(adminUserName, adminPassword, adminURL)

runtime()
edit()
startEdit()

print "Targeting Intiated..."

cd('/AppDeployments/ALSB Domain Singleton Marker Application')
set('Targets',jarray.array([], ObjectName))
set('Targets',jarray.array([ObjectName('com.bea:Name=OSB2,Type=Server')], ObjectName))
print "Targeted the Domain Singleton Marker Application to OSB2..."

cd('/AppDeployments/ALSB Cluster Singleton Marker Application')
set('Targets',jarray.array([], ObjectName))
set('Targets',jarray.array([ObjectName('com.bea:Name=OSB2,Type=Server')], ObjectName))
print "Targeted the Cluster Singleton Marker Application to OSB2..."

cd('/AppDeployments/Message Reporting Purger')
set('Targets',jarray.array([], ObjectName))
set('Targets',jarray.array([ObjectName('com.bea:Name=OSB2,Type=Server')], ObjectName))
print "Targeted the Message Reporting Purger to OSB2..."

activate()
exit()


Tuesday, January 28, 2014

ODL handler configuration through WLST script - Oracle SOA Suite

ODL handler configuration through WLST script - Oracle SOA Suite:

Oracle Fusion Middleware components write diagnostic log files in the Oracle Diagnostic Logging (ODL) format. Log file naming and the format of the contents of log files conforms to an Oracle standard. By default, the diagnostic messages are written in text format.

ODL provides the following benefits:

The capability to limit the total amount of diagnostic information saved. You can set the level of information saved and you can specify the maximum size of the log file and the log file directory.

When you reach the specified size, older segment files are removed and newer segment files are saved in chronological fashion.

Components can remain active, and do not need to be shutdown, when older diagnostic logging files are deleted.

The ODL configuration can be changed from EM console or WLST script.

Below is the WLST script help us to change the ODL handler setting.

Configureodlloghandlers.py

folderPath="/oracle/product/soa/11g/fmw/fmwlogs/SOACoreDomain"
domainAdminUserName = "weblogic"
domainAdminPassword = "welcome1"
connect(domainAdminUserName, domainAdminPassword, "t3://localhost:7001")
servers = adminHome.getMBeansByType('Server')
for s in servers:
edit()
startEdit()
serverName1 = s.getName()
path = '/Servers/' + serverName1
cd(path)
lh = listLogHandlers()
for l in lh:
lname = l.get('name')
odlfile = folderPath + '/logs/' + serverName1 + '/' + serverName1 + '-' + lname + '-diagnostic.log'
print 'Diagnostic path===>',odlfile
configureLogHandler(target=serverName1,name=lname, path=odlfile)
save()
activate()

The other details like maxFileSize,rotationFrequency and retentionPeriod  etc can also be changed through configureLogHandler method.

Executing the script:

$MIDDLEWARE_HOME/Oracle_SOA/common/bin/wlst.sh Configureodlloghandlers.py



Tuesday, March 12, 2013

Creating Foreign JMS Server configurations through WLST script in Weblogic server

Creating Foreign JMS Server configurations through WLST script in Weblogic server


WebLogic JMS enables you to reference foreign (that is, external) JMS providers within a local WebLogic JNDI tree. Using the Foreign JMS Server node, you can quickly map a foreign JMS provider so that its connection factories and destinations appear in the WebLogic JNDI tree as a local JMS objects.

A Foreign JMS Server configuration can also be used to reference remote instances of WebLogic Server in another cluster or domain in the local WebLogic JNDI tree

Once the Foreign Provider is configured within Weblogic, for all practical purposes within the code — it can be called as if it was on local JNDI lookup. Weblogic will make the remote calls transparent to your code. This allows you to change your destination via configuration on the Weblogic console.

This tutorial explains the approach to configure Foreign JMS server through WLST script
WLST Script

The below WLST script help us to create a Foreign JMS server in a local server for a JMS resources running in a remote weblogic server(in different domain) but the same can be used to configure Foreign Server with external providers .

The JMS Server running on t3://localhost:7002 is configured as a Foreign JMS Server for t3://localhost:7002

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

The same script can be modified to create a Foreign JNDI Server for other JMS providers, some of the important remote server properties to be modified is remoteDestinationJNDI, remoteConnectionFactoryJNDI, remoteConnectionURL, initialJNDIContextFactory, remoteUserName and remotePassword

ConfigureForeignJMSServer.properties

adminUserName=weblogic
adminUserPassword=weblogic1
adminServerHost=localhost
adminServerPort=7001foreignJMSModuleName=BAMForeginJMSResource
foreignJMSServerName=BAMForeignJMSServer
localConnectionFactoryJNDI=jms/BAMMonitoringConnectionfactory1
remoteConnectionFactoryJNDI=jms/BAMMonitoringConnectionfactory1
localDestinationJNDI=jms/BAMMonitoringQueue1
remoteDestinationJNDI=jms/BAMMonitoringQueue1remoteConnectionURL=t3://localhost:7002
initialJNDIContextFactory= weblogic.jndi.WLInitialContextFactory
remoteUserName=weblogic
remotePassword=welcome1

ConfigureForeignJMSServer.py

from java.io import FileInputStreampropInputStream = FileInputStream("ConfigureForeignJMSServer.properties")
configProps = Properties()
configProps.load(propInputStream)connect(configProps.get("adminUserName"),configProps.get("adminUserPassword"), 't3://'+configProps.get("adminServerHost")+':'+configProps.get("adminServerPort"))foreignJMSModuleName=configProps.get("foreignJMSModuleName")
foreignJMSServerName=configProps.get("foreignJMSServerName")
localConnectionFactoryJNDI=configProps.get("localConnectionFactoryJNDI")
localDestinationJNDI=configProps.get("localDestinationJNDI")remoteDestinationJNDI=configProps.get("remoteDestinationJNDI")
remoteConnectionFactoryJNDI=configProps.get("remoteConnectionFactoryJNDI")remoteConnectionURL=configProps.get("remoteConnectionURL")
initialJNDIContextFactory=configProps.get("initialJNDIContextFactory")
remoteUserName=configProps.get("remoteUserName")
remotePassword=configProps.get("remotePassword")edit()
startEdit()cd('/')
cmo.createJMSSystemResource(foreignJMSModuleName)cd('/SystemResources/'+foreignJMSModuleName)
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))cd('/JMSSystemResources/'+foreignJMSModuleName+'/JMSResource/'+foreignJMSModuleName)
cmo.createForeignServer(foreignJMSServerName)cd('/JMSSystemResources/'+foreignJMSModuleName+'/JMSResource/'+foreignJMSModuleName+'/ForeignServers/'+foreignJMSServerName)
cmo.setDefaultTargetingEnabled(true)cmo.setJNDIPropertiesCredential(remotePassword)cmo.setInitialContextFactory(initialJNDIContextFactory)
cmo.setConnectionURL(remoteConnectionURL)
cmo.createJNDIProperty('java.naming.security.principal')cd('/JMSSystemResources/'+foreignJMSModuleName+'/JMSResource/'+foreignJMSModuleName+'/ForeignServers/'+foreignJMSServerName+'/JNDIProperties/java.naming.security.principal')
cmo.setValue(remoteUserName)cd('/JMSSystemResources/'+foreignJMSModuleName+'/JMSResource/'+foreignJMSModuleName+'/ForeignServers/'+foreignJMSServerName)cmo.createForeignConnectionFactory('ForeignJMSConnectionFactory')cd('/JMSSystemResources/'+foreignJMSModuleName+'/JMSResource/'+foreignJMSModuleName+'/ForeignServers/'+foreignJMSServerName+'/ForeignConnectionFactories/ForeignJMSConnectionFactory')
cmo.setLocalJNDIName(localConnectionFactoryJNDI)
cmo.setRemoteJNDIName(remoteConnectionFactoryJNDI)cd('/JMSSystemResources/'+foreignJMSModuleName+'/JMSResource/'+foreignJMSModuleName+'/ForeignServers/'+foreignJMSServerName)
cmo.createForeignDestination('ForeignJMSDestination')cd('/JMSSystemResources/'+foreignJMSModuleName+'/JMSResource/'+foreignJMSModuleName+'/ForeignServers/'+foreignJMSServerName+'/ForeignDestinations/ForeignJMSDestination')
cmo.setLocalJNDIName(localDestinationJNDI)
cmo.setRemoteJNDIName(remoteDestinationJNDI)activate()

Script

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

Before executing the script, change the configurations as required.

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







Now the foreign JMS server is configured and ready for use — the messages can be send/receive through local JNDI’s , Weblogic server internally communicate to the remote server. The foreign JMS server configuration helps as to abstract the remote server details from clients, the remote server implementations can be changed any time without impacting the clients


Monday, March 11, 2013

Creating JMS Adapter connection factory through WLST script in weblogic server

Creating JMS Adapter connection factory through WLST script in weblogic server:

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


Monday, March 4, 2013

WLST script to configure JMS resources in weblogic server

WLST script to configure JMS resources in weblogic server

A JMS queue/Topic in Weblogic Server is associated with a number of additional resources:

JMS Server


A JMS server acts as a management container for resources within JMS modules. Some of its responsibilities include the maintenance of persistence and state of messages and subscribers. A JMS server is required in order to create a JMS module.

JMS Module


A JMS module is a definition which contains JMS resources such as queues and topics. A JMS module is required in order to create a JMS queue.

Subdeployment


JMS modules are targeted to one or more WLS instances or a cluster. Resources within a JMS module, such as queues and topics are also targeted to a JMS server or WLS server instances. A subdeployment is a grouping of targets. It is also known as advanced targeting.

Connection Factory


A connection factory is a resource that enables JMS clients to create connections to JMS destinations.

Persistent Store


It can be a UserDefined Persistent Store or a Default Persistent store. It is used for storing the Data (Messages).

JMS Queue/JMS Topic


JMS queue is a point-to-point destination type. A message is written to a specific queue or received from a specific queue.

JMS Topic follows Publish/Subscribe(Pub/Sub) model. Pub/sub messaging applications send and receive messages by subscribing to a topic

In this tutorial, we are going to configure JMS Queue with required additional resources through WLST script

WLST Script


The below script will help us to define the required JMS resources to enable the messaging queue

JMSConfiguration.properties
adminUserName=weblogic
adminUserPassword=weblogic1
adminServerHost=localhost
adminServerPort=7001
JMSConfiguration.py
from java.io import FileInputStream


Script

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

Before executing the script, change the configurations as required.

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



Now the required JMS resources are created and the queue is ready for messaging

The queue can be accessed using the below JNDI names

jms/BAMMonitoringConnectionfactory
jms/BAMMonitoringQueue







Friday, September 7, 2012

Modifying the targets of JDBC datasources through WLST script in weblogic server

Modifying the targets of JDBC datasources through WLST script in weblogic server

This tutorial explains the details on WLST script to change or add the targets for JDBC data sources in weblogic server.

The targeting can be enabled through weblogic admin console but the script helps us to automate the server configurations and reduce the manual effort if multiple data-sources need to be configured.
wlst-modify-jdbc-datasource-targets
The script will target the server MS3 and the Cluser1 to the data source with name “CRM6EAIReference”

Define JDBCProperties.properties with required configurations(sample script to show the configuration for multiple data-sources)

domain1.total.DS=2
domain1.prefix.1=om
domain1.om.datasource.name.1=CRM6EAIReference
domain1.om.datasource.target.1=Clusters/Cluster1,Servers/MS3
domain1.prefix.2=soa
domain1.soa.datasource.name.2=CRM6EAISOAMetadataSource
domain1.soa.datasource.target.2=Clusters/SOACluster

Before executing the script change the properties as required.If the target is a Server then it should be added like Servers/ServerName and if it is a cluster then it should be defined as Clusters/ClusterName. Configure domain1.total.DS with total number of data sources need to be configured.

Let us now define a WLST script file to change the targets using the property file defined above.

import re
from java.io import FileInputStream   

def UntargetTargetJDBCResources():
    edit()
    startEdit()
    propInputStream = FileInputStream('JDBCProperties.properties')
    configProps = Properties()
    configProps.load(propInputStream)    

    totalDataSource_to_untargetTarget=configProps.get("domain1.total.DS")
    
    server='AdminServer'
    cd("Servers/"+server)
       
    i=1
    while (i <= int(totalDataSource_to_untargetTarget)) :
    prefix = configProps.get("domain1.prefix."+ str(i))
    dsName = configProps.get("domain1."+prefix+".datasource.name."+ str(i))
    datasourceTargets = re.split(",",configProps.get("domain1."+prefix+".datasource.target."+ str(i)))
    targetArray=[] 
    
    for datasourceTarget in datasourceTargets:
   print 'DataSourceTargets',datasourceTargets
   print 'DataSourceTarget',datasourceTarget
   if datasourceTarget=='':
    print ''
   else:
    cd ('/JDBCSystemResources/'+dsName)
    set('Targets',jarray.array([], ObjectName))
    target=datasourceTarget[datasourceTarget.index("/")+1:len(datasourceTarget)]       
    if datasourceTarget.startswith('Cluster'):
     targetArray.append(ObjectName('com.bea:Name='+target+',Type=Cluster'))     
    elif datasourceTarget.startswith('Server'):
     targetArray.append(ObjectName('com.bea:Name='+target+',Type=Server'))         
   
    print 'Targets: ',targetArray
    set('Targets',jarray.array(targetArray, ObjectName))
    print 'DataSource: ',dsName,',Target has been updated Successfully !!!'
    print '========================================='    
    i = i + 1

    print '========================================='
    save()
    activate()
def main():
    adminURL='t3://localhost:7001'
    adminUserName='weblogic'
    adminPassword='weblogic1'
    connect(adminUserName, adminPassword, adminURL)
    UntargetTargetJDBCResources();
    print 'Successfully Modified the JDBC resources'
    disconnect()
main()

Script - 

The above script update the JDBC data source targets based on the configurations enabled in the property file.

Execute the script — <<Oracle_Home>>\oracle_common\common\bin\wlst.cmd ModifyJDBCResourcesTargets.py
wlst-modify-jdbc-datasource-targets
The JDBC data source targets changed now with the enabled configurations,the WLST script can be used to automate the server configurations and reduce the manual effort need for configurations.


Wednesday, September 5, 2012

Creating Socket Adapter connection factories through WLST script - Oracle SOA Suite

Creating Socket Adapter connection factories through WLST script - Oracle SOA Suite

The below WLST script will help us to create the Socket adapter connection factories in Oracle SOA Suite 11g or Oracle SOA Suite 12c

Change the Socket/SOA server details accordingly in the script.

Before executing the script make sure the SocketAdapter is targeted to the servers.

socket_adapter_target_servers

CreateSocketConnectionFactory.py

TargetServerName='AdminServer'

soaHome='C:\EnvSetup\MiddlewareBlog\Oracle_SOA1'

appPathSock=soaHome+'\soa\connectors\SocketAdapter.rar'
appNameSock='SocketAdapter'
moduleOverrideNameSock=appNameSock+'.rar'
SockJNDIName = 'eis/socket/SocketAdapterBlog'
#Socket Sever Details
HostName='101.63.203.129'
Password='blogenv1'
Port='7001'
UserName='weblogic'

moduleDescriptorName='META-INF/weblogic-ra.xml'
planPathSock='C:\EnvSetup\MiddlewareBlog\Oracle_SOA1\soa\connectors\Plan_Soket.xml'

def createSocketConnectionFactory(): 

        edit()
        startEdit()
        startApplication(appNameSock)
        myPlanSock=loadApplication(appPathSock, planPathSock)
        makeDeploymentPlanVariable(myPlanSock,'ConnectionInstance_eis/Socket_JNDIName_13102979357209', SockJNDIName , '/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="javax.resource.cci.ConnectionFactory"]/connection-instance/[jndi-name="'+SockJNDIName+'"]/jndi-name',moduleOverrideNameSock)
        makeDeploymentPlanVariable(myPlanSock, 'ConfigProperty_eis/Socket_JNDIName_Host_Name_13102979357210', HostName,'/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="javax.resource.cci.ConnectionFactory"]/connection-instance/[jndi-name="'+SockJNDIName+'"]/connection-properties/properties/property/[name="Host"]/value',moduleOverrideNameSock)
        makeDeploymentPlanVariable(myPlanSock, 'ConfigProperty_eis/Socket_JNDIName_Port_13102979357212', Port,'/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="javax.resource.cci.ConnectionFactory"]/connection-instance/[jndi-name="'+SockJNDIName+'"]/connection-properties/properties/property/[name="Port"]/value',moduleOverrideNameSock)
               
        myPlanSock.save();
        save();
        cd('/AppDeployments/SocketAdapter/Targets');
        updateApplication(appNameSock, planPathSock);
        startApplication(appNameSock);
        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():
       #SOA Server Details
       adminURL='t3://localhost:7001'
       adminUserName='weblogic'
       adminPassword='blogenv1'
       connect(adminUserName, adminPassword, adminURL)
       createSocketConnectionFactory()
       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 CreateSocketConnectionFactory.py




DOWNLOAD  CreateSocketConnectionFactory.py


Tuesday, September 4, 2012

Creating Oracle BAM Adapter connection factories through WLST script in Oracle SOA Suite

Creating Oracle BAM Adapter connection factories through WLST script in Oracle SOA Suite

The below WLST script will help us to create the Oracle  BAM adapter connection factories in Oracle SOA Suite.
Change the BAM/SOA server details accordingly.

Before executing the script make sure the OracleBamAdapter is targeted to the server.

oraclebamadapter_target_server

CreateBAMConnectionFactory.py

TargetServerName='AdminServer'

soaHome='C:\EnvSetup\MiddlewareBlog\Oracle_SOA1'

appPathBAM=soaHome+'\soa\connectors\OracleBamAdapter.rar'
appNameBAM='OracleBamAdapter'
moduleOverrideNameBAM=appNameBAM+'.rar'
BAMJNDIName = 'eis/BAM/Connection'
#BAM Server Details
HostName='localhost'
Password='blogenv1'
Port='7001'
UserName='weblogic'

moduleDescriptorName='META-INF/weblogic-ra.xml'
planPathBAM='C:\EnvSetup\MiddlewareBlog\Oracle_SOA1\soa\connectors\Plan_BAM.xml'

def createBAMConnectionFactory(): 

        edit()
        startEdit()
        startApplication(appNameBAM)
        myPlanBAM=loadApplication(appPathBAM, planPathBAM)
        makeDeploymentPlanVariable(myPlanBAM, 'ConnectionInstance_eis/BAM/BAM_JNDIName_13102979357209', BAMJNDIName , '/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="javax.resource.cci.ConnectionFactory"]/connection-instance/[jndi-name="'+BAMJNDIName+'"]/jndi-name',moduleOverrideNameBAM)
       
        makeDeploymentPlanVariable(myPlanBAM, 'ConfigProperty_eis/BAM/BAM_JNDIName_Host_Name_13102979357210', HostName,'/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="oracle.bam.adapter.adc.RMIConnectionFactory"]/connection-instance/[jndi-name="'+BAMJNDIName+'"]/connection-properties/properties/property/[name="HostName"]/value',moduleOverrideNameBAM)
       
        makeDeploymentPlanVariable(myPlanBAM, 'ConnectionInstance_eis/BAM/BAM_JNDIName_Password_13102979357211', Password , '/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="oracle.bam.adapter.adc.RMIConnectionFactory"]/connection-instance/[jndi-name="'+BAMJNDIName+'"]/connection-properties/properties/property/[name="Password"]/value',moduleOverrideNameBAM)
       
        makeDeploymentPlanVariable(myPlanBAM, 'ConfigProperty_eis/BAM/BAM_JNDIName_Port_13102979357212', Port,'/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="oracle.bam.adapter.adc.RMIConnectionFactory"]/connection-instance/[jndi-name="'+BAMJNDIName+'"]/connection-properties/properties/property/[name="PortNumber"]/value',moduleOverrideNameBAM)
       
        makeDeploymentPlanVariable(myPlanBAM, 'ConnectionInstance_eis/BAM/BAM_JNDIName_UserName_13102979357211', UserName , '/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="oracle.bam.adapter.adc.RMIConnectionFactory"]/connection-instance/[jndi-name="'+BAMJNDIName+'"]/connection-properties/properties/property/[name="UserName"]/value',moduleOverrideNameBAM)
       
        myPlanBAM.save();
        save();
        cd('/AppDeployments/OracleBamAdapter/Targets');
        updateApplication(appNameBAM, planPathBAM);
        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():
       #SOA Server Details
       adminURL='t3://localhost:7001'
       adminUserName='weblogic'
       adminPassword='blogenv1'
       connect(adminUserName, adminPassword, adminURL)
       createBAMConnectionFactory()
       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 CreateBAMConnectionFactory.py




The same script will not work in Oracle SOA Suite 12c - the connection-factory-interface javax.resource.cci.ConnectionFactory is not working with 12c. Refer the attached script specific to 12c

DOWNLOAD CreateBAMConnectionFactory.py    CreateBAMConnectionFactory_12c.py


Wednesday, May 2, 2012

WLST script to reset data source password in weblogic server

WLST script to reset data source password in weblogic server


This tutorial explains the approach to reset the password of all the data sources in weblogic server. Sometime we may need to reset the password of all the data sources, the below WLST script can be used to achieve the same.

The reset through console takes more time, the below WLST script helps to reset the password quickly

WLST Script


ResetAllDataSourcePassword.py

adminIP = raw_input("Enter domain1.AdminIP:")
adminPort = raw_input("Enter domain1.AdminPort:")
adminPassword = raw_input("Enter adminPassword:")
DBPASSWORD= raw_input("Enter new DBPASSWORD:")
DOMAIN_PATH='C://Albin/SW/Oracle/Middleware/Oracle_Home/user_projects/domains/base_domain'
es = encrypt(DBPASSWORD,DOMAIN_PATH)
adminURL='t3://'+adminIP+':'+adminPort
adminUserName='weblogic'
connect(adminUserName, adminPassword, adminURL)
server='AdminServer'
cd('Servers/'+server)
target=cmo
edit()
startEdit()# SOADomain Datasource Configuration
cd('JDBCSystemResources')
allDS=cmo.getJDBCSystemResources()
for tmpDS in allDS:
    dsName=tmpDS.getName();
    print  'Changing the Password for DataSource ', dsName
    cd('/JDBCSystemResources/'+dsName+'/JDBCResource/'+dsName+'/JDBCDriverParams/'+dsName)
    set('PasswordEncrypted',es)
save()
activate()
disconnect()


Script

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

Before executing the script, change the configurations as required.

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



Now the data sources password reset to new value.


Friday, February 3, 2012

WLST script to create JDBC Multi Data Source in weblogic server

Creating JDBC Multi Data Source through WLST in weblogic server

This tutorial explains the approach to create JDBC Multi data source through WLST script in weblogic

Refer the below URL for details on JDBC Multi data source.

https://www.albinsblog.com/2012/02/jdbc-multi-data-sources-in-weblogic.html

WLST Script


The below WLST script creates the JDBC Multi data source with enabled configurations

CreateMultiDataSource.py

adminURL='t3://localhost:7001'
adminUserName='weblogic'
adminPassword='weblogic1'
connect(adminUserName, adminPassword, adminURL)
edit()
startEdit()
jdbcSystemResource = create("MS1","JDBCSystemResource")
jdbcResource = jdbcSystemResource.getJDBCResource()
jdbcResource.setName("MS1")
dsParams = jdbcResource.getJDBCDataSourceParams()
jndiName='jdbc/MS1'
dsParams.setJNDINames([jndiName])
dsParams.setAlgorithmType('Failover')
dsParams.setDataSourceList('DS1,DS2')
dsParams.setFailoverRequestIfBusy(true)
jdbcSystemResource.addTarget(getMBean('Servers/AdminServer'))
print('MDS1 created successfully...')
save()
activate()
disconnect()



Script

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

Before executing the script, change the configurations as required.

The individual data sources(DS1 & DS2) should be created before executing the script




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

Now the JDBC Multi source is created with required configurations









Saturday, December 10, 2011

WLST script to change the log setting for all the servers in the weblogic domain

WLST script to change the log setting for all the servers in the weblogic domain


This tutorial explains the approach to change the log settings for all the servers in the weblogic domain

WLST Script


The below WLST script will help us to change the log setting for all the servers in the weblogic domain.

domain_log.properties

fileCount = 10
fileMinSize = 20000
fileTimeSpan = 12
log4jEnabled = false
httpAccessLoggingEnabled = true
stdoutSeverity = Info
logBRSeverity = Info
logFileSeverity = Info
memBufferSeverity = Info
memBufferSize = 400
numOfFilesLimited = true
redirectStdout = true
redirectStdErr = true
rotateOnStartup = true
rotateType = bySize

domain.folderPath = C:\Albin\SW\Oracle\Middleware\Oracle_Home\user_projects\domains\base_domain
domain.admin.url=t3://127.0.0.1:7001
domain.admin.username=weblogic
domain.admin.password=weblogic1

DomainLogConfigurtionChange.py

from java.io import FileInputStream


Script

Before executing the script, change the configurations as required.

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



Now the log settings are changed as required




Wednesday, October 26, 2011

Oracle SOA Suite – Creating Resource Adapter Connection factories through WLST for Database Adapter,MQ Adapter and FTP Adapter


Oracle SOA Suite – Creating Resource Adapter Connection factories through WLST for Database Adapter,MQ Adapter and FTP Adapter:

WLST script can be use to create the Resource Adapter connection factories (DB, FTP and MQ) and set the different configuration parameters in weblogic server.
Here we will use the property file to configure the connection factories details, the WLST script will create the connection factories in the server based on the property file.
Just edit the ResourceAdapter.properties file with the connection factories details.
Set the global.resource.deployment.plan.path property with the where the generated deploymentPlan files needs to be stored.

ResourceAdapter.properties


domain.AdminIP=xxxxxxxx
domain.AdminPort=xxxx
domain.AdminPasswd=xxxxxxxxxx
global.resource.deployment.plan.path= /config/deployplan
domain.resource.ftpHost = 10.10.10.10
domain.resource.ftpUserName=
domain.resource.ftpPassword=
domain.resource.mqQueueManager=TCRMGEN1
domain.resource.mqHost=LOCALHOST
domain.resource.mqport=2022
domain.resource.mqChannel=L_CRM_FUSION_CLNT_N2

The below WLST code snippet will create the required connection factories in the server.
Set the DB data source Connection Factory JNDI Name and the data source name as per the requirement. In this sample we are creating two connection factories. Change the method createDBConnectionFactory to create more Database Adapter connection factories.
Change the method createFTPConnectionFactory to create more FTP Adapter connection factories.
Change the method createMQConnectionFactory to create more FTP Adapter Connection factories.

ResourceAdapterCreation.py


from java.io import FileInputStream
TargetServerName='AdminServer'
#Connect
#The directory of the SOA binaries
soaHome=os.environ["SOAHOME"]
print "SOAHOME="+soaHome
appPathDB=soaHome+'/soa/connectors/DbAdapter.rar'
appNameDB='DbAdapter'
moduleOverrideNameDB=appNameDB+'.rar'
appPathFTP=soaHome+'/soa/connectors/FtpAdapter.rar'
appNameFTP='FtpAdapter'
moduleOverrideNameFTP=appNameFTP+'.rar'
appPathMQ=soaHome+'/soa/connectors/MQSeriesAdapter.rar'
appNameMQ='MQSeriesAdapter'
moduleOverrideNameMQ=appNameMQ+'.rar'
moduleDescriptorName='META-INF/weblogic-ra.xml'
ConnFactory1JNDIName = 'eis/DB/OM'
ConnFactory1DataSourceName = 'eai/ds/EAIReference'
ConnFactory2JNDIName = 'eis/DB/XRef'
ConnFactory2DataSourceName = 'eai/ds/EAIXRef'
transactionSupport='LocalTransaction'
ftpJNDIName='eis/Ftp/ProductRefXML'
mqJNDIName='eis/MQ/MQSeriesAdapterRemoteCRMtoEAI'
domainName='standalone_domain'
def createDBConnectionFactory():
propInputStream = FileInputStream("ResourceAdapter.properties")
configProps1 = Properties()
configProps1.load(propInputStream)
planPathDB=configProps1.get('global.resource.deployment.plan.path')+'/'+domainName+'_PlanDB.xml'
edit()  
startEdit()
myPlanDB=loadApplication(appPathDB, planPathDB)
makeDeploymentPlanVariable(myPlanDB, 'ConnectionInstance_eis/DB/OM_JNDIName_13102979357209', ConnFactory1JNDIName , '/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="javax.resource.cci.ConnectionFactory"]/connection-instance/[jndi-name="'+ConnFactory1JNDIName+'"]/jndi-name',moduleOverrideNameDB)
makeDeploymentPlanVariable(myPlanDB, 'ConfigProperty_dataSourceName_Value_13102979357210', ConnFactory1DataSourceName,'/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="javax.resource.cci.ConnectionFactory"]/connection-instance/[jndi-name="'+ConnFactory1JNDIName+'"]/connection-properties/properties/property/[name="xADataSourceName"]/value',moduleOverrideNameDB)
makeDeploymentPlanVariable(myPlanDB, 'ConnectionInstance_eis/DB/XRef_JNDIName_13102979357211', ConnFactory2JNDIName , '/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="javax.resource.cci.ConnectionFactory"]/connection-instance/[jndi-name="'+ConnFactory2JNDIName+'"]/jndi-name',moduleOverrideNameDB)
makeDeploymentPlanVariable(myPlanDB, 'ConfigProperty_dataSourceName_Value_13102979357213', ConnFactory2DataSourceName,'/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="javax.resource.cci.ConnectionFactory"]/connection-instance/[jndi-name="'+ConnFactory2JNDIName+'"]/connection-properties/properties/property/[name="xADataSourceName"]/value',moduleOverrideNameDB)
makeDeploymentPlanVariable(myPlanDB, 'ConnectionDefinitionProperties_TransactionSupport_13123107532320', transactionSupport,'/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="javax.resource.cci.ConnectionFactory"]/connection-instance/[jndi-name="'+ConnFactory1JNDIName+'"]/connection-properties/transaction-support',moduleOverrideNameDB)
makeDeploymentPlanVariable(myPlanDB, 'ConnectionDefinitionProperties_TransactionSupport_13123107532320', transactionSupport,'/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="javax.resource.cci.ConnectionFactory"]/connection-instance/[jndi-name="'+ConnFactory2JNDIName+'"]/connection-properties/transaction-support',moduleOverrideNameDB)
myPlanDB.save();
save();
cd('/AppDeployments/DbAdapter/Targets');
updateApplication(appNameDB, planPathDB);
startApplication(appNameDB)
#redeploy(appNameDB, planPathDB,targets=cmo.getTargets());
activate(block='true');
def createFTPConnectionFactory():
propInputStream = FileInputStream("ResourceAdapter.properties")
configProps1 = Properties()
configProps1.load(propInputStream)
planPathFTP=configProps1.get('global.resource.deployment.plan.path')+'/'+domainName+'_PlanFTP.xml'
ftpHost=configProps1.get('domain.resource.ftpHost')
ftpUserName=configProps1.get('domain.resource.ftpUserName')
ftpPassword=configProps1.get('domain.resource.ftpPassword')
edit()
startEdit()
myPlanFTP=loadApplication(appPathFTP, planPathFTP)
makeDeploymentPlanVariable(myPlanFTP, 'ConnectionInstance_eis/Ftp/FtpPRD_JNDIName', ftpJNDIName, '/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="javax.resource.cci.ConnectionFactory"]/connection-instance/[jndi-name="'+ftpJNDIName+'"]/jndi-name',moduleOverrideNameFTP)
makeDeploymentPlanVariable(myPlanFTP, 'ConfigProperty_useSftp_Value_FtpPRD', 'true', '/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="javax.resource.cci.ConnectionFactory"]/connection-instance/[jndi-name="'+ftpJNDIName+'"]/connection-properties/properties/property/[name="useSftp"]/value',moduleOverrideNameFTP)
makeDeploymentPlanVariable(myPlanFTP, 'ConfigProperty_host_Value_FtpPRD', ftpHost, '/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="javax.resource.cci.ConnectionFactory"]/connection-instance/[jndi-name="'+ftpJNDIName+'"]/connection-properties/properties/property/[name="host"]/value',moduleOverrideNameFTP)
makeDeploymentPlanVariable(myPlanFTP, 'ConfigProperty_password_Value_FtpPRD', ftpUserName, '/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="javax.resource.cci.ConnectionFactory"]/connection-instance/[jndi-name="'+ftpJNDIName+'"]/connection-properties/properties/property/[name="username"]/value',moduleOverrideNameFTP)
makeDeploymentPlanVariable(myPlanFTP, 'ConfigProperty_password_Value_FtpPRD', ftpPassword, '/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="javax.resource.cci.ConnectionFactory"]/connection-instance/[jndi-name="'+ftpJNDIName+'"]/connection-properties/properties/property/[name="password"]/value',moduleOverrideNameFTP)
myPlanFTP.save();
save();
cd('/AppDeployments/FtpAdapter/Targets');
updateApplication(appNameFTP, planPathFTP);
startApplication(appNameFTP)
#redeploy(appNameFTP, planPathFTP,targets=cmo.getTargets());
activate(block='true');
def createMQConnectionFactory():
propInputStream = FileInputStream("ResourceAdapter.properties")
configProps1 = Properties()
configProps1.load(propInputStream)
planPathMQ=configProps1.get('global.resource.deployment.plan.path')+'/'+domainName+'_PlanMQ.xml'
mqQueueManager=configProps1.get('domain.resource.mqQueueManager')
mqHostName=configProps1.get('domain.resource.mqHost')
MqPort=configProps1.get('domain.resource.mqport')
mqChannelName=configProps1.get('domain.resource.mqChannel')
edit()
startEdit()
myPlanMQ=loadApplication(appPathMQ, planPathMQ)
makeDeploymentPlanVariable(myPlanMQ, 'ConnectionInstance_eis_MQ_MQSeriesAdapterRemoteCRMtoEAI_JNDIName', mqJNDIName, '/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="javax.resource.cci.ConnectionFactory"]/connection-instance/[jndi-name="'+mqJNDIName+'"]/jndi-name',moduleOverrideNameMQ)
makeDeploymentPlanVariable(myPlanMQ, 'ConfigProperty_host_Value_mqQueueManagerPRD', mqQueueManager, '/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="javax.resource.cci.ConnectionFactory"]/connection-instance/[jndi-name="'+mqJNDIName+'"]/connection-properties/properties/property/[name="queueManagerName"]/value',moduleOverrideNameMQ)
makeDeploymentPlanVariable(myPlanMQ, 'ConfigProperty_password_Value_mqHostNamePRD', mqHostName, '/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="javax.resource.cci.ConnectionFactory"]/connection-instance/[jndi-name="'+mqJNDIName+'"]/connection-properties/properties/property/[name="hostName"]/value',moduleOverrideNameMQ)
makeDeploymentPlanVariable(myPlanMQ, 'ConfigProperty_password_Value_MqPortPRD', MqPort, '/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="javax.resource.cci.ConnectionFactory"]/connection-instance/[jndi-name="'+mqJNDIName+'"]/connection-properties/properties/property/[name="portNumber"]/value',moduleOverrideNameMQ)
makeDeploymentPlanVariable(myPlanMQ, 'ConfigProperty_password_Value_mqChannelNamePRD', mqChannelName, '/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="javax.resource.cci.ConnectionFactory"]/connection-instance/[jndi-name="'+mqJNDIName+'"]/connection-properties/properties/property/[name="channelName"]/value',moduleOverrideNameMQ)
myPlanMQ.save();
save();
cd('/AppDeployments/MQSeriesAdapter/Targets');
updateApplication(appNameMQ, planPathMQ);
startApplication(appNameMQ)
#redeploy(appNameFTP, planPathMQ,targets=cmo.getTargets());
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():
propInputStream1 = FileInputStream("ResourceAdapter.properties")
domainProps = util.Properties()
domainProps.load(propInputStream1)
adminURL='t3://'+domainProps.get('domain.AdminIP')+':'+domainProps.get('domain.AdminPort')
adminUserName='weblogic'
adminPassword=domainProps.get("domain.AdminPasswd")
connect(adminUserName, adminPassword, adminURL)
createDBConnectionFactory()
createFTPConnectionFactory()
createMQConnectionFactory()
disconnect()
main()

Set the environment variable “SOAHOME”  in the server and execute the WLST script that will create the required Resource Adapter connection factories. Also this will create the deploymentPlan files to the location specified. The generated plan file can be used to modify the configuration of connection factories also to move the connection factories from one server to another server.

>$ORACLE_HOME/common/bin/wlst.sh ResourceAdapterCreation.py

Download: ResourceAdapter.properties   ResourceAdapterCreation.py