Creating Datasource using WLST

connect(‘weblogic’,’weblogic’,’t3://localhost:7001′) edit() startEdit() cd(‘/’) cmo.createJDBCSystemResource(‘PegaRULES’) cd(‘/JDBCSystemResources/PegaRULES/JDBCResource/PegaRULES’) cmo.setName(‘PegaRULES’) cd(‘/JDBCSystemResources/PegaRULES/JDBCResource/PegaRULES/JDBCDataSourceParams/PegaRULES’) set(‘JNDINames’,jarray.array([String(‘jdbc/PegaRULES’)], String)) cd(‘/JDBCSystemResources/PegaRULES/JDBCResource/PegaRULES/JDBCDriverParams/PegaRULES’) cmo.setUrl(‘jdbc:sqlserver://localhost:1433’) cmo.setDriverName(‘com.microsoft.sqlserver.jdbc.SQLServerDriver’) cmo.setPassword(‘pega612’) cd(‘/JDBCSystemResources/PegaRULES/JDBCResource/PegaRULES/JDBCConnectionPoolParams/PegaRULES’) cmo.setTestTableName(‘SQL SELECT 1\r\n\r\n’) cd(‘/JDBCSystemResources/PegaRULES/JDBCResource/PegaRULES/JDBCDriverParams/PegaRULES/Properties/PegaRULES’) cmo.createProperty(‘user’) cd(‘/JDBCSystemResources/PegaRULES/JDBCResource/PegaRULES/JDBCDriverParams/PegaRULES/Properties/PegaRULES/Properties/user’) cmo.setValue(‘pega612’) cd(‘/JDBCSystemResources/PegaRULES/JDBCResource/PegaRULES/JDBCDriverParams/PegaRULES/Properties/PegaRULES’) cmo.createProperty(‘databaseName’) cd(‘/JDBCSystemResources/PegaRULES/JDBCResource/PegaRULES/JDBCDriverParams/PegaRULES/Properties/PegaRULES/Properties/databaseName’) cmo.setValue(‘prpc612’) cd(‘/JDBCSystemResources/PegaRULES/JDBCResource/PegaRULES/JDBCDataSourceParams/PegaRULES’) cmo.setGlobalTransactionsProtocol(‘OnePhaseCommit’) cd(‘/SystemResources/PegaRULES’) set(‘Targets’,jarray.array([ObjectName(‘com.bea:Name=AdminServer,Type=Server’)], ObjectName)) activate() dumpStack() exit()

Continue reading »

Delete Messages From JMS Queue Using WLST

Connect to the server using WLST by entering the command java weblogic.WLST Enter the command connect() Enter the username, password, and the admin server url you want to connect to. Change the location to serverRuntime by entering the command serverRuntime(). Traverse to the below location: – cd(‘JMSRuntime’) – cd(‘AdminServer.jms’) –

Continue reading »

A short Article on CMO’s — WLST variables

WLST, CMO’s and Built-in Variables CMO is the WLST in built variable. These are like our JAVA keywords having a dedicated meaning and functionality. CMO stands for Current Management Object. While programming in WLST we can use cmo to point the current MBean (object) instance you are navigating into. The

Continue reading »

ConfigToScript command

ConfigToScript The WLST command ConfigToScript converts an existing server configuration (config directory) to an executable WLST python script.The syntax for this command is : configToScript([configPath], [pyPath], [overwrite], [propertiesFile], [createDeploymentScript]) – configPath : Optional value. This is the path to the config directory that contains the configuration of the domain that

Continue reading »

WLST Script to Monitor Throughput and HeapSize of Weblogic Server

In this simple example ill demonstrate how to browse to ThreadPoolRuntime and JVMRuntime Mbeans of Weblogic Server and monitor their attributes. We get a lot of useful runtime date from this Mbeans which we can store for later reference. cd(“/ServerRuntimes/AdminServer/ThreadPoolRuntime/ThreadPoolRuntime”) -r– HealthState State: HEALTH_OK,ReasonCode:[]-r– HoggingThreadCount 0-r– MinThreadsConstraintsCompleted 20485-r– MinThreadsConstraintsPending 0-r–

Continue reading »

Create JMS Resources Using WLST

connect(’system’,’weblogic’, ‘t3://localhost:7001′) # Creating a JMS Server edit()startEdit()cd(‘/’)print ‘Creating JMS Server.’cmo.createJMSServer(‘JMSServer0′)cd(‘/JMSServers/JMSServer0′)cmo.addTarget(getMBean(‘/Servers/AdminServer’))activate() # Creating a Module startEdit()cd(‘/’)cmo.createJMSSystemResource(‘JMSSystemResource0′)cd(‘/JMSSystemResources/JMSSystemResource0′)cmo.addTarget(getMBean(‘/Servers/AdminServer’))cmo.createSubDeployment(’subdeployment0′)activate() # Creating Queue startEdit()print ‘Creating Queue & Topic ‘cd(‘/’)cd(‘/JMSSystemResources/JMSSystemResource0/JMSResource/JMSSystemResource0′)cmo.createQueue(‘Queue0′)cd(‘/JMSSystemResources/JMSSystemResource0/JMSResource/JMSSystemResource0/Queues/Queue0′)set(‘JNDIName’,’jms/Queue0′)set(‘SubDeploymentName’,’subdeployment0′)cd(‘/JMSSystemResources/JMSSystemResource0/SubDeployments/subdeployment0′)cmo.addTarget(getMBean(‘/JMSServers/JMSServer0′))activate() # Creating Topic startEdit()cd(‘/’)cd(‘/JMSSystemResources/JMSSystemResource0/JMSResource/JMSSystemResource0′)cmo.createTopic(‘Topic0′)cd(‘/JMSSystemResources/JMSSystemResource0/JMSResource/JMSSystemResource0/Topics/Topic0′)set(‘JNDIName’,’jms/Topic0′)set(‘SubDeploymentName’,’subdeployment0′)cd(‘/JMSSystemResources/JMSSystemResource0/SubDeployments/subdeployment0′)set(‘Targets’,jarray.array([ObjectName(‘com.bea:Name=JMSServer0,Type=JMSServer’)],ObjectName)) activate()

Continue reading »

WLST Script to add users, groups and modify roles

connect(‘weblogic’,’weblogic’,’t3://localhost:7001′)edit()startEdit(-1,-1,’false’)serverConfig()cd(‘/SecurityConfiguration/First_Domain/Realms/myrealm/AuthenticationProviders/DefaultAuthenticator’)cmo.createUser(‘faisal’,’weblogic’,”)cmo.groupExists(‘TestGrp’)cmo.createGroup(‘TestGrp’,”)cmo.addMemberToGroup(‘testgrp’,’faisal’)cd(‘/SecurityConfiguration/First_Domain/Realms/myrealm/RoleMappers/XACMLRoleMapper’)cmo.setRoleExpression(”,’Admin’,’Grp(TestGrp)|Grp(Administrators)’)edit()undo(defaultAnswer=’y’, unactivatedChanges=’true’)stopEdit(‘y’)

Continue reading »

Import and Export users from Embedded LDAP using WLST

Export connect(‘weblogic’,’weblogic’, ‘t3://localhost:8003′) domainRuntime() cd(‘/DomainServices/DomainRuntimeService/DomainConfiguration/DomainA/SecurityConfiguration/DomainA/DefaultRealm/myrealm/AuthenticationProviders/DefaultAuthenticator’) cmo.exportData(‘DefaultAtn’,’c:/export.ldif’, Properties()) Import connect(‘weblogic’,’weblogic’, ‘t3://localhost:8003′) domainRuntime() cd(‘/DomainServices/DomainRuntimeService/DomainConfiguration/DomainB/SecurityConfiguration/DomainB/DefaultRealm/myrealm/AuthenticationProviders/DefaultAuthenticator’) cmo.importData(‘DefaultAtn’,’c:/export.ldif’, Properties())

Continue reading »

Creating Users in Weblogic Server Embedded LDAP Programatically.

I have received many requests from Clients for code snippet to create users programmatically.Below is a sample code by which we can create users in the Embedded LDAP of Weblogic Server.Put simple, this program creates an MBean Server connection, traverses to the relevant Mbean and invokes the right method to

Continue reading »