03 May 2010

Reading a properties file in BPEL

To read a properties file from BPEL, we can use Java Embedding.
In the java activity, we can read the property and assign the values to BPEL variables using 'setVariableData' function.

Lets have a simple POC to do the same :
1. Create a properties file say "TestProp.properties" and add some properties.


2. Create a simple composite with Async BPEL process and add a Java-embedding activity after Receive activity.

3. Open the Java embedding activity and add following code :



Note that the location for file is set in the first line.

4. Save and close the activity. Open the BPEL source and go to line where the Java embedding is present.
Add following Java import statements  before the code for java embedding activity.


<bpelx:exec import="java.io.*"/>
<bpelx:exec import="java.util.*"/>


After adding this , the code snippet looks like this :






5. Save, Deploy, Test.
Make sure that properties file is present and it actually contains the property 'myName'
Otherwise one needs to change the code a bit  to handle these scenarios. (Simply add a check to see if value is null)

Sample code for this POC can be downloaded from here .

2 comments:

Dev said...

Hi,
I tried to run this SOA project using Jdeveloper 11.1.1.5,but i am getting following error:
oracle.jrf.UnknownPlatformException: JRF is unable to determine the current application server platform.
at oracle.jrf.ServerPlatformSupportFactory.getInstance(ServerPlatformSupportFactory.java:79)
at oracle.integration.platform.blocks.WLSPlatformConfigurationProvider.(WLSPlatformConfigurationProvider.java:44)
at oracle.integration.platform.blocks.FabricConfigManager.(FabricConfigManager.java:155)
at oracle.integration.platform.blocks.xpath.FabricXPathFunctionResolver.loadXpathFunctions(FabricXPathFunctionResolver.java:271)
at oracle.integration.platform.blocks.xpath.FabricXPathFunctionResolver.loadXPathConfigFile(FabricXPathFunctionResolver.java:153)
at oracle.integration.platform.blocks.xpath.FabricXPathFunctionResolver.init(FabricXPathFunctionResolver.java:51)
at com.collaxa.cube.xml.xpath.BPELXPathFunctionNameResolver.loadFabricXpathFunctions(BPELXPathFunctionNameResolver.java:57)
at com.collaxa.cube.xml.xpath.BPELXPathFunctionNameResolver.(BPELXPathFunctionNameResolver.java:48)
at com.collaxa.cube.xml.xpath.BPELXPathFunctionNameResolver.(BPELXPathFunctionNameResolver.java:44)
at com.collaxa.cube.lang.compiler.bpel.XPathExprValidatorVisitor.(XPathExprValidatorVisitor.java:122)
at com.collaxa.cube.lang.compiler.bpel.AssignValidator.(AssignValidator.java:89)
at com.collaxa.cube.lang.compiler.bpel.BpelParser.(BpelParser.java:452)
at com.collaxa.cube.lang.compiler.bpel.BPELValidator.validate(BPELValidator.java:60)
at com.collaxa.cube.lang.compiler.BPEL1Processor.validate(BPEL1Processor.java:329)
at com.collaxa.cube.lang.compiler.BPEL1Processor.process(BPEL1Processor.java:153)
at com.collaxa.cube.lang.compiler.CubeParserHelper.compile(CubeParserHelper.java:47)
at oracle.fabric.bpel.bpelc.BPELComponentValidator.validate(BPELComponentValidator.java:40)
at oracle.soa.scac.ValidateComposite.validateComponentTypeServicesReferences(ValidateComposite.java:1117)
at oracle.soa.scac.ValidateComposite.doValidation(ValidateComposite.java:500)
at oracle.soa.scac.ValidateComposite.run(ValidateComposite.java:150)
at oracle.soa.scac.ValidateComposite.main(ValidateComposite.java:135)


Error: SCAC-50012


Please suggest something to resolve this.


Regards,
Deb

Unknown said...

HI...

I am also getting the same error.. any fix?