Saturday, June 1, 2013

Runnable ADF Projects in JDeveloper Integrated WLS within BPM Application

(JDeveloper 11.1.1.7, WLS 10.3.6, SOA/BPM 11.1.1.7)


In my previous blog, I created a separate ADF project in the BPM Application for showing the custom database related UI.
We can imagine a scenario where I have to develop only the ADF page, and it might take a couple of trials until I get the UI right.
So each time I modify the ADF code, if I have to deploy the whole BPM application to the Weblogic server and test it from the BPM workspace, it is a time consuming process.

Instead, I should be able to run only the ADF code (not the Task Forms created from the Human Task definitions, but the ADF pages/taskflows created based on custom DB) in the JDeveloper Integrated Weblogic server and test it.

By default, if we try to run the ADF pages inside the BPM application we might get errors.
(The error is shown at the end of this blog)
Integrated Weblogic server starts complaining about the SOA libraries coming from the project and the page will not be runnable.


To make the ADF code runnable in Integrated Weblogic server, we have to do a couple of settings in JDeveloper and modify some project code as follows.

1. Use Current Working Set


2. Uncheck BPM/SOA related projects in Manage Working Sets


3. Comment the adf-mds-config tag in the adf-config.xml



4. Comment the BPEL and SOA libraries in the weblogic-application.xml



5.  Create a test page in the common UI project and reuse the bounded taskflows.


6. Pass parameters as required to the taskflows


The pages will be running in the JDeveloper Integrated Weblogic Server.



The error we might get will be as follows.

[Running application EmplyeeBookRequests on Server Instance IntegratedWebLogicServer...] 
[10:20:27 PM] ----  Deployment started.  ----
[10:20:27 PM] Target platform is  (Weblogic 10.3).
[10:20:31 PM] Retrieving existing application information
[10:20:31 PM] Running dependency analysis...
[10:20:31 PM] Deploying 2 profiles...
[10:20:31 PM] Wrote Web Application Module to C:\Users\Sameer\AppData\Roaming\JDeveloper\system11.1.1.7.40.64.93\o.j2ee\drs\EmplyeeBookRequests\EmployeeBookRequestCommonUIWebApp.war
[10:20:31 PM] Wrote Enterprise Application Module to C:\Users\Sameer\AppData\Roaming\JDeveloper\system11.1.1.7.40.64.93\o.j2ee\drs\EmplyeeBookRequests
[10:20:31 PM] Redeploying Application...
<Jun 1, 2013 10:20:32 PM EDT> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID '1370139631714' for task '0'. Error is: 'weblogic.management.DeploymentException: [J2EE:160149]Error while processing library references. Unresolved application library references, defined in weblogic-application.xml: [Extension-Name: oracle.soa.workflow.wc, exact-match: false].'
weblogic.management.DeploymentException: [J2EE:160149]Error while processing library references. Unresolved application library references, defined in weblogic-application.xml: [Extension-Name: oracle.soa.workflow.wc, exact-match: false].
at weblogic.application.internal.flow.CheckLibraryReferenceFlow.prepare(CheckLibraryReferenceFlow.java:26)
at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:613)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:184)
at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:58)
Truncated. see log file for complete stacktrace
<Jun 1, 2013 10:20:32 PM EDT> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating deploy task for application 'EmplyeeBookRequests'.> 
<Jun 1, 2013 10:20:32 PM EDT> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
weblogic.management.DeploymentException: [J2EE:160149]Error while processing library references. Unresolved application library references, defined in weblogic-application.xml: [Extension-Name: oracle.soa.workflow.wc, exact-match: false].
at weblogic.application.internal.flow.CheckLibraryReferenceFlow.prepare(CheckLibraryReferenceFlow.java:26)
at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:613)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:184)
at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:58)
Truncated. see log file for complete stacktrace
[10:20:32 PM] ####  Deployment incomplete.  ####
[10:20:32 PM] Remote deployment failed
#### Cannot run application EmplyeeBookRequests due to error deploying to IntegratedWebLogicServer.
[Application EmplyeeBookRequests stopped and undeployed from Server Instance IntegratedWebLogicServer]


Payload Or Database ?



(JDeveloper 11.1.1.7, WLS 10.3.6, SOA/BPM 11.1.1.7)

Not all data can be stored, or is recommended to be stored in the Payload. Especially the Transactional or Relational data. They are as usual should be stored in the Database.

So let us assume that we keep the Transactional and Relational data in the Database.
We still need to keep some data in the Payload for the process to function properly.
We keep only that data in the Payload that will affect the flow in the Process.
During the progress of the Process we might have to change some Payload values which will affect the flow of the process.

BPM might not know about the data we store in the Database. Most of the cases it will be Custom data. So it is our responsibility to maintain an association between the Process and the custom data in the database.

In this post, I would like to show a logic which can maintain a relation between the custom data and the process.

Either the unique process instance id can be stored in our database table (most cases it will be the main entity of the application), or put the main entity's primary key in the Payload.
I would recommend the first option, put the process instance id in the main entity database table.


The use case I assumed for this is a BPM process of book requests for employees.
Following is the database table I created for holding the book requests information.




Created a simple process as follows for the book request



Created a UI project for BPM Human Tasks as follows


Create another ADF Model Project in the same application and create the necessary BC4J objects based on the UI requirements.




Create another ADF View Controller project in the same application and create a bounded task flow in the common UI project





Create a task flow parameter for the bounded task flow to get the bpm process instance Id.




Create the Book Request form from the data controls in the page




Add a View Criteria to the VO as follows




Add a method to the AM as follows 




And Create a client interface for that method


Add the method to the task flow as follows by passing the parameter from the page flow scope and make it the default activity.



Open the common UI project deployment profile and create an ADF Library JAR file


Create the jar library file


Create a new file system connection to the deploy folder of the common UI project



Select the BPM UI project and add the library to the project



It should show like below if it is added successfully


Create a binding on the BookRequest page for process instance id from the data control for RequestBook task as follows. You can hide this if you want. It is not necessary to show it to the user.


Drag and drop the taskflow from library as region to the BookRequest page in the BPM UI project as follows



Pass the instance id from the page binding as follows as parameter to the taskflow region



Do the same for ReviewBook and ResponseBook pages

Also, we have to add Commit binding to all the 3 pages. This should be called programmatically on Submit button. (Not shown in this post)



Deploy the application and test.

Login as Employee and create a book request and Submit. (We have to save manually here first. – Should actually call the commit binding on Submit button code)


The Manager will get a task for reviewing the book request.

Here the book request region is same from the library and is fetching the data from the database using the bpm process instance id.



Please look at my previous post for detail steps to create a BPM process.