Wednesday, April 30, 2014

Error creating instance for target process in Oracle BPMN

I created a simple BPMN process and deployed it to BPMN server.

After deployment i went to bpm workspace page and i clicked on the instance but i got below error message.



Again i checked in server logs and got lot of error messages

]]
[2014-04-30T15:43:24.850+05:30] [soa_server1] [WARNING] [] [oracle.bpm.common] [tid: [ACTIVE].ExecuteThread: '6' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: jcooper] [ecid: 895f3834fb0d8c6d:-67de5b31:145b1d66aa1:-8000-0000000000002c5d,0] [APP: OracleBPMWorkspace] Error creating instance for target process default/BRTest!1.0*/BRProcess.[[
oracle.bpm.web.exception.WapiOperationException: Error creating instance for target process default/BRTest!1.0*/BRProcess.
at oracle.bpm.workspace.model.common.ExecutionBean.handleExternalInstanceExecution(ExecutionBean.java:188)
at oracle.bpm.workspace.model.application.ApplicationBean.execute(ApplicationBean.java:169)

... 101 more
Caused by: BPM-70204

Exception
exception.70204.type: error
exception.70204.severity: 2
exception.70204.name: Error creating process instance.
exception.70204.description: Error creating instance for target process default/BRTest!1.0*/BRProcess.
exception.70204.fix: Verify server log to find the problem cause.





Cause - This is a known issue in the product and a patch is provided by oracle to resolve this issue.

Reason- The reason for this issue is that when a business object is create in BPMN it does't get copied to the xsd folder in your composite.

Resolution-

In order to resolve this issue do the following

Copy the schema file created in your business catalog to the xsd folder manually.




Monday, April 28, 2014

Business Rules in BPMN

This exercise again will be a sequence of previous exercise. We will see how we can incorporate business rules in BPMN.

Create a new project for business rules



Create two data object and then create two business object based on the data object



Create a default human task and create data association to map the input data for the workflow argument



Create a file adapter(based on response schema) to write data into a file location in your local machine.

Drag and drop a service task and point it to the file adapter you have just created.

Finally go to data association and map the data accordingly



Drag and drop a business rule and place it between the user task and the service. create input and output variable for Business rules



Create data association for business rule and assign the data .



Go to your business rule and create a rule condition as per your business requirement.



Deploy the process and test it.



Go to instance details and validate whether the process completed successfully

Thursday, April 24, 2014

Working with Multiple roles -Exclusive gateway

We will proceed with our last exercise and will try to enhance the same.

Drag and drop an exclusive gateway in your process after the user task.

We are using exclusive gateway as it allows to split your path in more than one path.

YOu need to specify one default path and you can also assign the order in which you want the process to follow the path.



now right click on the line joining the gateway and the fileWrite service

Go to properties

Select type as condition and then select and xpath expression

In my case i have selected the condition as order number should be greater than 500



Say ok and you will find an error in the gateway, This is because there is not default path for exclusive gateway and as per definition of it there must be a default path



Copy and past the End activity in the lower pane to the upper pane.

It will show an error message as currently it is not linked.

Right click on your exclusive gateway and say Add default sequence flow.

add the flow to the new end activity that you have added in the upper pane.



Once you will add that all the errors will be gone.

You can also notice that the default path has a cut which identifies it as a default path.

One can add as many condition path as required in exclusive gateway and decide on the order of the processing.



You can double click on the gateway to decide the order if there are multiple paths



Initialize the record once with order number less than 500 and once with greater than 500



For order number less than 500 the flow completed without calling the fileWrite



for order number greater than 500 the flow completes with FileWrite





So now we are able to route the process based on some condition this can be done in a much better way by integrating with business rules that we will later in incoming posts.

for now we will try to modify the existing code and see how we can ensure that after initiating the request the request goes to the next approver.

Now go to your BPMN process and drag and drop a User task in the lower pane name it as approver, Create a human task for that and create data association for the same.



AFter completing the wizard the process should look like this



Go ahead and redeploy your process to the server.

Now log in to BPM workspace as jcooper user and test your process



Submit an order



Once you submit an order go to em console to check it status

you will find it is stuck in next level for approval




Log in again to bpm workspace this time with jstein user



Go to process tracking select the task and approve it



Once the task is approved go back to your em console and validate the instance and you can find that the process is completed now



there is one problem only with this that we are not able to see the payload which is passed by initiator in the reviewers page.

This is because we have not yet created a page for the approver human task.

Go to the .task file of approver and auto generate the jsp task form



Now initiate one more process and login to bpm workspace with jstein user and you can now see the payload passed by jcooper

Working with Multiple Roles in BPMN- Reassign roles

We have seen example earlier of an end to end flow in BPMN , we have seen a single role but in this exercise we will try to see use of multiple roles and how it can used in BPMN. We will be using the very first sample that we have developed in first exercise and extend it work with multiple roles

Go to your BPMN process right click on the HelloWorldProcess pane and add role



In the opened window press new and create a new role -->give it a logical name and complete the wizard



Once you will complete the wizard you can see a new role in the page



Now just drag the Writefile and end activity on the Approver role



Now go to your application navigator

Right click on Organization and say open

Once it comes up select the approver role and assign a user to it from your realm



Save all the changes and redeploy your project to the server.


Log in to your BPM workflow page with jcooper as user

Go to your application and initiate your process with some sample input and reassign it to Jstein user



this process will be now waiting for the Jstein user to complete the process.

Now log in to the console with jstein user and you will find the process initiated by jcooper in the list



Review the order and submit it to complete the process flow



finally go to em console and validate if the instance completed successfully



You can validate the human task flow



So this is how different roles work in BPMN.

The important point here is that there was absolutely no use of adding an additional role in the BPMN page but we have done it intentionally for our next exercise.

In this exercise we were manually assigning the task to jstein but in our next exercise we will see how the same process can be manipulated to assign the task to jstein user dynamically.

File to DB in BPMN

If you have already completed the previous exercise now you are ready to go ahead do some more experiment on the BPMN.

In this exercise we will try to read a data from a file and will write the data in to a table in db.

Create a new Project



select manual process



Once process is created delete the user task so that now the process looks like this




Right click on reference and create a file adapter service to poll record from a location in your local machine

You can point it to following schema

<?xml version= '1.0' encoding= 'UTF-8' ?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://xmlns.oracle.com/purchase/order"
xmlns:xsd="http://xmlns.oracle.com/purchase/order"
elementFormDefault="qualified">
<element name="PORequest" type="xsd:PORequestType"/>
<complexType name="PORequestType">
<sequence>
<element name="OrderNumber" type="string" minOccurs="1"/>
<element name="ProductName" type="string" minOccurs="0"/>
<element name="ProductDescription" type="string" minOccurs="0"/>
</sequence>
</complexType>
</schema>


Complete the file adapter wizard and you should be able to see that in the reference

Create a table in your db

create table PO_DETAILS (order_number varchar2(50),OrderDetails varchar2(50),orderCode varchar2(50));

And go to Services tab in Business catalog and create a db adapter service and point it to insert data in the db table you have created.

After creating both the adapters it should be visible in your Business catalog



Now go to your BPMN process

Right click on start and go to implementation

Choose type as Use Interface and select the File Adapter that you have created to read the file from a location in your local machine.



Drag and drop a SErvice task and insert it between the start and stop activity.

Go to implementation table select type as Service call

and select the db adapter service that you have created to insert data in to the table in the database.



Create a module "DataModule" for business object.

Create two business Object for File input and DB input based on the schema for file and db adapter schema.

Once business object is created create two PRocess data object based on the business object.



Now go back to your bpmn process

Go to Data Association and map the data from filein to dbIN



Go ahead and deploy your project.

Once process is deployed place the file in the location from where file adapter is polling.

As soon as the file is polled go to the em console

http://host:port/em

and check for the instance.

Checked the instance and found that the process is currently in suspended state




further dwelling in to the error go the following error message



auditQueryPayload auditId="2028" ciKey="30004">
<dataState>
<dataObject name="FaultMessage" isBusinessIndicator="false">
<value>
oracle.bpm.bpmn.engine.model.runtime.microinstructions.TrappableException: faultName: {{http://schemas.xmlsoap.org/ws/2003/03/business-process/}selectionFailure} messageType: {{http://schemas.oracle.com/bpel/extension}RuntimeFaultMessage} cause: {faultName: {{http://schemas.xmlsoap.org/ws/2003/03/business-process/}selectionFailure} messageType: {{http://schemas.oracle.com/bpel/extension}RuntimeFaultMessage} parts: {{ summary=
<summary>empty expression result. The expression bpmn:getDataObject('fileIn')/ns:ProductDescription is empty. An attempt to read or copy data referenced or computed by the XPath expression either had invalid data, according to the XML schema, or did not contain certain optional data. Ensure that the variable or expression result named in the error message is not empty. Enable XML schema validation of related data elements to ensure the run-time data is valid. </summary>
} }
</value>
</dataObject>
</dataState>
</auditQueryPayload>

The reason for the issue is that we have mapped the data from fileIn but there is no data in fileIN dataobject

We are receiving data in the argument of input activity so we need one more assignment from input argument to the fileIN data object that can be done in the start activity.

Go to the start activity.

Double click on it and go to implementation tab

Go to data association and map data from input argument to the fileIN as shown

Redeploy the process and test it.



Place one more file in the input directory and validate if the process is completed successfully



finally validate the database table if you can see the record