Wednesday, October 26, 2011

Oracle SOA Suite – Creating Weblogic users and assign SOA and weblogic roles through WLST


Oracle SOA Suite – Creating Weblogic users and assign SOA and weblogic roles through WLST:

WLST script can be use to create the required users in Weblogic and to assign the required SOA and weblogic roles to the user.
Here we will use the property file to configure the user details,the WLST script will create the users in the server based on the property file.
Weblogic roles control the access permission of weblogic server and the SOA roles control the access permission of the EM console.
Just edit the UserManagement.properties with the users and group details.

UserManagement_SOADomain.properties


admin.url=t3://xxxxxxxx:8000
admin.userName=weblogic
admin.password=xxxxxxx
total.username=7
#
create.user.name.1=adminuser
create.user.password.1=Test1234
create.user.description.1= This is a Backup Administrator User
#Comma seperated roles
create.user.groups.1=Administrators
create.user.soarole.1=SOAAdmin,SOADesigner

create.user.name.2=soaadminuser
create.user.password.2=Test1234
create.user.description.2= This is a SOA ADMIN User Two
#Comma seperated roles
create.user.groups.2=Deployers,Operators,Monitors,IntegrationDeployers
create.user.soarole.2=SOAAdmin

create.user.name.3=nfttestuser
create.user.password.3=Test1234
create.user.description.3= This is a Test User Three
#Comma seperated roles
create.user.groups.3=Monitors,IntegrationMonitors
create.user.soarole.3=SOAMonitor,SOAAuditViewer

create.user.name.4=devtestuser
create.user.password.4=Test1234
create.user.description.4= This is a DEV User Three
#Comma seperated roles
create.user.groups.4=Deployers,IntegrationDeployers,IntegrationMonitors,Monitors,Operators
create.user.soarole.4=SOADesigner,SOAMonitor

WLST Script:

The below WLST code snippet will create the required users and assign the corresponding roles to the user.

UserManagement_SOADomain.py

from java.io import FileInputStream
from java.util import *
from javax.management import *

domainName=raw_input('Please enter the weblogic domain name for the user creation: ')
print 'domainName:',domainName

propInputStream = FileInputStream("UserManagement_"+domainName+".properties")
configProps = Properties()
configProps.load(propInputStream)

adminURL=configProps.get("admin.url")
adminUserName=configProps.get("admin.userName")
adminPassword=configProps.get("admin.password")
realmName=configProps.get("security.realmName")
totalUsers_to_Create=configProps.get("total.username")

connect(adminUserName, adminPassword, adminURL)
serverConfig()
authenticatorPath= '/SecurityConfiguration/' + domainName + '/Realms/myrealm/AuthenticationProviders/DefaultAuthenticator'
print authenticatorPath

cd(authenticatorPath)

print 'Creating Users . . .'

x=1
while (x <= int(totalUsers_to_Create)):
userName = configProps.get("create.user.name."+ str(x))
userPassword = configProps.get("create.user.password."+ str(x))
userDescription = configProps.get("create.user.description."+ str(x))
try:
cmo.createUser(userName , userPassword , userDescription)
print '-----------User Created With Name : ' , userName
except Exception, e:
print e
x = x + 1

print ' '
print ' '

print 'Adding Group Membership of the Users:'
y=1
while (y <= int(totalUsers_to_Create)):
grpNames = configProps.get("create.user.groups."+ str(y)).split(",")
userName = configProps.get("create.user.name."+ str(y))
for grpName in grpNames:
if grpName=='':
print ''
else:
cmo.addMemberToGroup(grpName,userName)
print 'USER:' , userName , 'Added to GROUP: ' , grpName

y=y+1

print 'Adding SOA Roles Membership of the Users:'
y=1
while (y <= int(totalUsers_to_Create)):
roleNames = configProps.get("create.user.soarole."+ str(y)).split(",")
userName = configProps.get("create.user.name."+ str(y))
for roleName in roleNames:
if roleName=='':
print ''
else:
grantAppRole(appStripe="soa-infra", appRoleName=roleName,principalClass="weblogic.security.principal.WLSUserImpl", principalName=userName)
print 'USER:' , userName , 'Added the Role: ' , roleName
y=y+1

Execute the WLST script that will create the required users and assign the corresponding roles.
>$ORACLE_HOME/common/bin/wlst.sh UserManagement_SOADomain.py

Download: UserManagement_SOADomain.properties  UserManagement_SOADomain.py


Tuesday, October 25, 2011

Oracle SOA Suite 10g to Oracle SOA Suite 11g Migration – FlowN execution issue

Oracle SOA Suite 10g to Oracle SOA Suite 11g Migration – FlowN execution issue:


We had a flow in 10g that invokes another composite inside the FlowN activity with different data based on the index variable and it was working properly but after the migration the composite has always invoked with the payload of the first flow branch.

We did some analysis and found that 10g FlowN activity and 11g FlowN activities are working in different manner.

In 10g ,the activities in the same flow branch is executed in sequence that after completing the first branch the second branch getting executed
But in 11g, the execution of the activities are swapped between branches that the first activity in the first branch is executed then the first activity in second branch then second activity in first branch and second activity in second activity and so on.

In 10g even though we are using the global variables inside the flowN activity each flowN branch is working with different message/payload based on the Index Variable.
In 11g if we are using the global variables inside the flowN activity all the flowN branches are executed with the same message/payload of the first flow branch.
To overcome this issue we have copied the global variable data to local FlowN scope variable and used the local variable inside the FlowN.

Below is the detailed execution of activities within FlowN in 10g:-

FlowN with two branches and both the branches are working on the same global variable ‘Varaible_1’
The value of ‘Varaible_1’ has incremented to 1 in Assign_2 and to 2 in Assign_3 (Assign_2 and Assign_3 data’s are displayed together) of Flow2


The value of ‘Varaible_1’ has incremented to 3 in Assign_2 and to 4 in Assign_3 (Assign_2 and Assign_3 data’s are displayed together) of Flow1





Oracle SOA Suite 10g – Finding the Open BPEL Instances


Oracle SOA Suite 10g - Finding the Open BPEL Instances:

SQL Query:

We can use the below query to find All the Open BPEL instances(Open and Running,Open and Suspended and Open and Faulted)
select * from orabpel.cube_instance where (state=1 or state=2 or state=3) and process_id='xxxxxxxxx'

Java API:

The Oracle BPEL Process Manager Server provides a Java API’s that can be used to find the Open BPEL instances.
The BPEL process client API provides the Locator class to look up the process and find the instances.
listInstances(WhereCondition wc) method can be used to find the instances based on the where condition.
WhereCondition class can be used to create the queries.

The following code snippet will enable you to find all the open instances (Running, Suspended, and Faulted) for a particular BPEL process.

Properties props = new Properties();
props.setProperty("orabpel.platform", "ias_10g");
props.setProperty("java.naming.factory.initial","com.evermind.server.rmi.RMIInitialContextFactory");
props.setProperty("java.naming.provider.url","opmn:ormi://127.0.0.1:6003:oc4j_soa/orabpel");
props.setProperty("java.naming.security.principal", "oc4jadmin");
props.setProperty("java.naming.security.credentials","xxxxx");
props.setProperty("dedicated.rmicontext", "true");

String processId = "xxxxxxxxxxxxxx";
try
{
Locator locator;
locator = new Locator("domainname", "password", props);

//Set the processed id
WhereCondition WhereProcessId = new WhereCondition( "process_id = ?" );
WhereProcessId.setString(1,processId);

//Set the state 1 - instance Open and Running
WhereCondition WhereStateOpenAndRunning = new WhereCondition( "ci_state=?" );
WhereStateOpenAndRunning.setString(1,"1");

//Set the state 2 - instance Open and suspended
WhereCondition WhereStateOpenAndSuspended = new WhereCondition( "ci_state=?" );
WhereStateOpenAndSuspended.setString(1,"2");

//Set the state 2 - instance Open and faulted
WhereCondition WhereStateOpenAndFaulted = new WhereCondition( "ci_state=?" );
WhereStateOpenAndFaulted.setString(1,"3");

WhereProcessId.append("and").append("(").append(WhereStateOpenAndRunning).append("or").append(WhereStateOpenAndSuspended).append("or").append(WhereStateOpenAndFaulted).append(")") ;
IInstanceHandle[] instanceHandles = locator.listInstances( WhereProcessId );
setVariableData("openInstanceCount",new Integer(instanceHandles.length));
}catch(Exception e)
{
setVariableData("openInstanceCount",e.getMessage());
}

This code snippet can be modified to find only the open and running instances or open and suspended instances or open and faulted instances.
Please refer the attached sample for your reference.



Monday, October 24, 2011

Oracle SOA Suite - Finding the Composite Instances waiting for callback


Oracle SOA Suite - Finding the Composite Instances waiting for callback:-

The below query can be used to identify the Composite instances waiting for the callback.
Select * from SOA_SOAINFRA.dlv_subscription where composite_name = ‘xxxxxxxxx’ and operation_name = 'xxxxxxxxxx' and state = 0 and properties like ‘#CorrelationString’
#CorrelationString –The correlation id used for the call back. This condition can be ignored if there is no correlation used.


Oracle SOA Suite - OutOfMemoryError when deploying the Composite


OutOfMemoryError when deploying the Composite:-

OutOfMemoryError has thrown when deploying the services to Oracle SOA Suite server from UNIX using ANT.
[wldeploy]
[wldeploy]
[wldeploy] Target Assignments:
[wldeploy] + UpdateStatus SOACluster
Exception in thread "J2EE-Deployment-task-poller" java.lang.OutOfMemoryError: PermGen space
[echo] There was an error while deploying: The following error occurred while executing this line:
[echo] code/config/scripts/WebServicesBuild.xml:96: java.lang.OutOfMemoryError: PermGen space

To overcome this issue increase the client memory (ANT) by executing the below comment and try the deployment again.

In Unix:

export ANT_OPTS=”-Xms512m -Xmx1024m -XX:MaxPermSize = 512m -XX: PermSize = 512m”

In Windows:

set ANT_OPTS=”-Xms512m -Xmx1024m -XX:MaxPermSize = 512m -XX: PermSize = 512m”