Monday, January 31, 2011

RCU issue on SOA 11.1.1.4 on XE

just to let you know I hit the following issue when running rcu as sys/sysdba on XE.

after running rcu, I logged into sqlplus as sys/sysdba and checked the object status with

select object_name, object_type from dba_objects where status='INVALID';

The following objects were listed -
------------------------------------------
package body mds_internal_common
package body mds_internal_shredded
package body mds_internal_utils

procedure purge_runtime_with_timeout
procedure purge_b2b_instances_down
--------------------------------------
I ran utlrp.sql to recompile and re-checked.

the 3 mds packages were still listed as INVALID.

I then logged on as DEV_MDS and re-compiled the 3 packages successfully.

The main problem was that, according to the RCU utility, everything had completed successfully. The errors were only highlighted when I attempted to start wls.

However, after fixing the DB issues, I could re-start wls successfully.

Naturally I didn't read the note on the otn download page -

If you want to use XE you can set the RCU_JDBC_TRIM_BLOCKS environment variable to TRUE *prior* to running RCU. As a reminder as to support level, when running RCU against XE you will receive a warning stating that the database version is not supported by Oracle.

Wednesday, January 26, 2011

SOA Suite 11.1.1.4 - soa composer not active by default

I did a developer install of SOA Suite 11.1.1.4.
Everything is up and running on the AdminServer.

I then test /soa/composer and see that it doesn't work ootb.

I check in the wls console and see that the composer app has been installed but is
not active.

So just, target it to the AdminServer and start it.

Tuesday, January 25, 2011

Setting up shared folders on Oracle SOA Virtual Box

Greetings from South Africa!


Scenario:

I'm using VirtualBox 4.x with the SOA image created with a 3.x version.
Shared folders don't work ootb.
Essentially you have to re-install the "new" version of VirtualBox Additions -

Thanks to the colleagues here in my workshop for the support!

Steps
I set up a shared folder as follows –



I install Guest Additions



You might get a pop-up prompting you to do a Force Unmount - so do it!

Open a Terminal window in /media

You should see a directory VBoxAdditions...



do an su root (password -oracle)



Now we need to add the user oracle to the group vboxsf

System --> Administration --> Users and Groups





Re-start the image

Open a Terminal window in /media



Yet another way - from my colleague Lawrence -

From the Oracle VM VirtualBox select the VM and go to Settings>Shared Folders
Add a share folder with a logical name like Share -> C:\VM\Share
Boot up the VM
As root
mkdir /mnt/share (share can be anything you want)
mount -t vboxsf Share /mnt/share

Note that the "Share" is from the is the logical name, and "share" is the directory that you are mounting. After this you can access everything in the /mnt/share directory. The mount command must be repeated when you want to use it.

Monday, January 24, 2011

Localhost --> Virtualbox SOA image communication

Scenario:

I have installed the SOA Virtual Box image and now want to be able to access it from my host (winxp) machine, as follows -

- using IE
- from JDeveloper

Step 1: Localhost setup
- VirtualBox 4.x installed
- MSFT Loopback Adapter installed and running on 1.1.1.1
- \etc\hosts entries
1.1.1.1 yourHostName
1.1.1.2 soabpm-vm

Step 2: VirtualBox configuration
- Start VirtualBox
- Delete the host-only network entry



- Start the image

Step 3: Image Network configuration

- Click on Devices --> Network Adapters...



- Check for eth0 connection
- If not found, create one.
- System --> Administration --> Network (password –oracle)
- Set ip address to 1.1.1.2



- Re-start the image
- Once restarted, check that eth0 is active.
-- System --> Administration --> network
--- If not, activate
--- Start & Test SOA WLS
---- Once running, test from browser on localhost –




Step 4: Create a new app server connection in JDev




- Test


Monday, January 17, 2011

SOA Suite 11g 11.1.1.4.0 (PS3) ready for download

Check out http://www.oracle.com/technetwork/middleware/soasuite/downloads/index.html

New features detailed at http://www.oracle.com/technetwork/middleware/soasuite/documentation/soa-11gr1-ps3-new-features-258135.html

Wednesday, January 12, 2011

SOA Composite instances --> When to purge?

Leading on from the last couple of posts -

In my simple scenario a customer ordered some goods, a composite instance was initiated to do the work. In the meantime the customer cancels the order, we react by purging the instance.

Bad business of course, usually we would want to capture the business condition - order cancelled. A simple solution, in my scenario, would be to have 3 outcomes from the human workflow --> Approve, Reject, Cancel. The order could then be cancelled via the worklist app or via th api. Control is returned to the BPEL process which could then do what has to be done - e.g. compensation, update customer profile etc.

Tuesday, January 11, 2011

Creating a generic BPEL process to purge instances

The final piece of the puzzle...

I create a composite -






I created the following process variables



and added the following connection properties to composite.xml



I added the following embedded Java to the BPEL process.



----------------------------------------------------------

Hashtable jndiProps = new Hashtable();

String PROVIDER_URL = (String)getVariableData("v_PROVIDER_URL");
String INITIAL_CONTEXT_FACTORY = (String)getVariableData("v_INITIAL_CONTEXT_FACTORY");
String SECURITY_PRINCIPAL = (String)getVariableData("v_SECURITY_PRINCIPAL");
String SECURITY_CREDENTIALS = (String)getVariableData("v_SECURITY_CREDENTIALS");

jndiProps.put(javax.naming.Context.PROVIDER_URL,PROVIDER_URL);
jndiProps.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,INITIAL_CONTEXT_FACTORY);
jndiProps.put(javax.naming.Context.SECURITY_PRINCIPAL, SECURITY_PRINCIPAL);
jndiProps.put(javax.naming.Context.SECURITY_CREDENTIALS, SECURITY_CREDENTIALS);

jndiProps.put("dedicated.connection", "true");
System.out.println("*** Purge composite instance... ");
Locator locator = null;
System.out.println("*** Purge composite instance - about to get id ");

String compositeID = (String)getVariableData("v_compositeID");
System.out.println("*** Purge composite instance - got id " + compositeID);
try {
LocatorFactory.createLocator(jndiProps);
locator = LocatorFactory.createLocator(jndiProps);
CompositeInstanceFilter coif = new CompositeInstanceFilter();
coif.setId(compositeID);
List list = locator.getCompositeInstances(coif);
System.out.println("*** Composite Instance " + compositeID + " about to be deleted...");

for(int i = 0 ; i < list.size() ; i ++){
CompositeInstance coi = (CompositeInstance)list.get(i);
System.out.println("*** Composite Instance State = " +coi.getState());
System.out.println("*** Composite Instance " + compositeID + " about to be deleted...");
// locator.purgeInstance(coif);
}
}
catch (Exception e) {

e.printStackTrace();
}
locator.close();

----------------------------------------------------------



Now kick off the cancel process –


Monday, January 10, 2011

Canceling a running composite instance - example

Firstly I wish all of you - Health, Wealth and Happiness for 2011 and beyond!

Now it's back to work...

Scenario
File Adapter(read) --> Mediator --> BPEL --> human workflow --> DB
Adapter(write).

Step 1 - create the composite
- I started with a simple Mediator, to begin with.




- Here is the XSD I used



- As you can see, I created a composite sensor on the OrderNr.



Ok, let’s add the BPEL & Human Workflow components to the composite



- Define the Human Workflow ( I simply assign the approval task to jcooper)
- Autogenerate task form etc.


Deploy and Test
- Here is my test input XML.




- Login to sqlplus as dev_soainfra
- execute the following
-- select substr(composite_instance_id,1,15),
substr( component_instance_id,1,20),
substr( component_name, 1,20),
substr(sensor_name,1,20),
substr( string_value,1,20)
from composite_sensor_value
/



- So the composite instance id = 180001

- I can now use this value to execute the following query
-- select substr(composite_dn,1,25), state, live_instances from composite_instance where id = 180001
/



- The STATE = 0 which indicates that the instances is open and running.
- Other state values are -->



- We can now access the cube_instance table to get the details of the running bpel instance –

-- Select cikey, state from cube_instance where cmpst_id = 180001;



- State = 1 means bpel instance is open and running –
- Other state values are -->



- Now I check the Human Workflow tables
-- select
substr( title, 1,20),
tasknumber,
taskid,
substr(state,1,10),
substr(assignees,1,20)
from wftask
where compositeinstanceid = 180001;



-- The taskid = 44b2adae-c347-48c4-b5d9-0b76ba722c1d
-- The task number = 200180

Step 2 - Leveraging the Java API to find a particular human task

- To begin with, let's get all the tasks for jcooper -
-- Method getAllTasks()



The task 200180 is the last one in the list.

- Then I look for a specific task - getSpecificTask()



-------------------------------------------------------------------

package processmyorderapi;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;

import java.util.Map;

import oracle.bpel.services.workflow.client.IWorkflowServiceClient;
import oracle.bpel.services.workflow.client.IWorkflowServiceClientConstants;
import oracle.bpel.services.workflow.client.WorkflowServiceClientFactory;
import oracle.bpel.services.workflow.query.ITaskQueryService;

import oracle.bpel.services.workflow.repos.TableConstants;
import oracle.bpel.services.workflow.task.ITaskService;
import oracle.bpel.services.workflow.task.model.Task;
import oracle.bpel.services.workflow.verification.IWorkflowContext;

import oracle.bpel.services.workflow.repos.Predicate;

public class HwTask {

public HwTask() {
super();
}

public String getAllTasks(String user){

Map properties = new HashMap();
properties.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_PROVIDER_URL, "t3://localhost:8001");
properties.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_SECURITY_CREDENTIALS, "welcome1");
properties.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_SECURITY_PRINCIPAL, "weblogic");

try
{
//Create JAVA WorkflowServiceClient
IWorkflowServiceClient wfSvcClient =
WorkflowServiceClientFactory.getWorkflowServiceClient(WorkflowServiceClientFactory.REMOTE_CLIENT, properties, null);

//Get the task query service
ITaskQueryService querySvc = wfSvcClient.getTaskQueryService();
//Login as jcooper
IWorkflowContext ctx = querySvc.authenticate("jcooper","welcome1".toCharArray(),null);
//Set up list of columns to query
List queryColumns = new ArrayList();
queryColumns.add("TASKID");
queryColumns.add("TASKNUMBER");
queryColumns.add("TITLE");
queryColumns.add("OUTCOME");
//Query a list of tasks assigned to jcooper
List tasks = querySvc.queryTasks(ctx,
queryColumns,
null, //Do not query additional info
ITaskQueryService.AssignmentFilter.MY,
null, //No keywords
null, //No custom predicate
null, //No special ordering
0, //Do not page the query result
0);

//Get the task service
ITaskService taskSvc = wfSvcClient.getTaskService();
//Loop over the tasks, outputting task information,

for(int i = 0 ; i < tasks.size() ; i ++)
{

Task task = (Task)tasks.get(i);
int taskNumber = task.getSystemAttributes().getTaskNumber();
String title = task.getTitle();
String taskId = task.getSystemAttributes().getTaskId();
String outcome = task.getSystemAttributes().getOutcome();
/* now we could auto-approve tasks, if required!
/* if(outcome == null)
{
outcome = "APPROVED";
taskSvc.updateTaskOutcome(ctx,taskId,outcome);
}*/

System.out.println("Task ID#"+ taskId + "Task Nr#" + taskNumber+" ("+title+") is "+outcome);
}
}
catch (Exception e)
{
//Handle any exceptions raised here...
System.out.println("Caught workflow exception: "+e.getMessage());
}

return "done";
}

public String getSpecificTask(String taskid){
System.out.println("*** getSpecificTask() looking for taskId " + taskid);
Map properties = new HashMap();
properties.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_PROVIDER_URL, "t3://localhost:8001");
properties.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_SECURITY_CREDENTIALS, "welcome1");
properties.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_SECURITY_PRINCIPAL, "weblogic");

try
{
//Create JAVA WorflowServiceClient
IWorkflowServiceClient wfSvcClient =
WorkflowServiceClientFactory.getWorkflowServiceClient(WorkflowServiceClientFactory.REMOTE_CLIENT, properties, null);

//Get the task query service
ITaskQueryService querySvc = wfSvcClient.getTaskQueryService();
//Login as jcooper
IWorkflowContext ctx = querySvc.authenticate("jcooper","welcome1".toCharArray(),null);
//Set up list of columns to query
List queryColumns = new ArrayList();
queryColumns.add("TASKID");
queryColumns.add("TASKNUMBER");
queryColumns.add("TITLE");
queryColumns.add("OUTCOME");

// add predicate for particular taskid

Predicate predicate = new Predicate(TableConstants.WFTASK_TASKID_COLUMN,
Predicate.OP_EQ,
taskid);
System.out.println("*** getSpecificTask() Predicate added for taskId " + taskid);

//Query a list of tasks assigned to jcooper
List tasklist = querySvc.queryTasks(ctx,
queryColumns,
null, //Do not query additional info
ITaskQueryService.AssignmentFilter.MY,
null, //No keywords
predicate, //add custom predicate
null, //No special ordering
0, //Do not page the query result
0);

if (tasklist != null) { // There are tasks
System.out.println("Total number of tasks: " + tasklist.size());
System.out.println("Tasks List: ");
Task task = null;
for (int i = 0; i < tasklist.size(); i++) {
task = (Task) tasklist.get(i);
System.out.println("Task Number: " + task.getSystemAttributes().getTaskNumber());
System.out.println("Task Id: " + task.getSystemAttributes().getTaskId());
System.out.println("Title: " + task.getTitle());
System.out.println("Priority: " + task.getPriority());
System.out.println("State: " + task.getSystemAttributes().getState());
System.out.println();
// Retrive any Optional Info specified
// Use task service, to perform operations on the task
}
}
}
catch (Exception e)
{
//Handle any exceptions raised here...
System.out.println("Caught workflow exception: "+e.getMessage());
}

return "done";
}


}

------------------

Step 2 - Leveraging the Java API to find and purge composite instances

- see method - findComposite()
-- here we call locator.purgeInstance() to purge the instance
--------------------------------------------

package compositeapi;

import java.util.Hashtable;
import java.util.List;
import javax.naming.Context;

import oracle.soa.management.facade.ComponentInstance;
import oracle.soa.management.facade.Composite;
import oracle.soa.management.facade.CompositeInstance;
import oracle.soa.management.facade.Locator;
import oracle.soa.management.facade.LocatorFactory;
import oracle.soa.management.facade.ServiceEngine;
import oracle.soa.management.facade.bpel.BPELServiceEngine;
import oracle.soa.management.util.ComponentInstanceFilter;
import oracle.soa.management.util.CompositeInstanceFilter;


public class CompositeAPI {

private Locator locator = null;

public CompositeAPI() {
super();
}

public void findComposite(){

java.util.Hashtable props = new java.util.Hashtable();
props.put(javax.naming.Context.PROVIDER_URL, "t3://localhost:8001/soa-infra");
props.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
props.put(javax.naming.Context.SECURITY_PRINCIPAL, "weblogic");
props.put(javax.naming.Context.SECURITY_CREDENTIALS, "welcome1");
props.put("dedicated.connection", "true");

try{
locator = LocatorFactory.createLocator(props);
CompositeInstanceFilter coif = new CompositeInstanceFilter();
coif.setId("180001");
List list = locator.getCompositeInstances(coif);
System.out.println("Nr. of Composites found = " + list.size());

for(int i = 0 ; i < list.size() ; i ++){
CompositeInstance coi = (CompositeInstance)list.get(i);
System.out.println("Composite Instance Domain Name = " +coi.getCompositeDN());
System.out.println("Composite Instance State = " +coi.getState());
System.out.println("Composite Instance Status = " +coi.getStatus());

locator.purgeInstance(coif);

}


// Component Instance Filter usage

ComponentInstanceFilter cif = new ComponentInstanceFilter();
cif.setCompositeInstanceId("180001");
List l = locator.getComponentInstances(cif);

System.out.println("Instance found = " + l.size());

for(int i = 0 ; i < l.size() ; i ++){
ComponentInstance ci = (ComponentInstance)l.get(i);
System.out.println("Component Instance ID = " +ci.getCompositeInstanceId());
ServiceEngine se = ci.getServiceEngine();
System.out.println("*** Engine Type " + se.getEngineType());
System.out.println("DN = " + ci.getCompositeDN());
}

String compositeDN = "default/ProcessMyOrder!1.0";
Composite composite = locator.lookupComposite(compositeDN);
System.out.println("*** got composite "+ composite.toString());

// Purge

}
catch(Exception e){
e.printStackTrace();
}

}
}

-------------------------------------------------------------------------------

Step 3 - Check the DB

I run the selects again -