Showing posts with label OSB. Show all posts
Showing posts with label OSB. Show all posts

Sunday, August 7, 2016

Oracle SOA 12c: Error while deploying soa composite using maven : error: javax/el/ELContext

Today I was working on the Build automation for Oracle SOA 12c and configure the maven and Hudson tool for Continuous Integration. After configuring the maven on my local machine , I tried to compile the soa project but I was getting the following error:

"you may getting el context error while building soa project"
i.e. java.lang.NoClassDefFoundError: javax/el/ELContext

Solution

This problem can be solved by adding EL context dependency in maven plugin

Go to oracle maven home repository folder i.e.

$M2_HOME/repository/com/oracle/soa/plugin/oracle-soa-plugin/12.2.1-0-0 

open the oracle-soa-plugin-12.2.1-0-0.pom in any editor and add the following dependency


<dependency>
    <groupId>javax.el</groupId>
    <artifactId>javax.el-api</artifactId>
    <version>3.0.0</version>
  </dependency>

save the file and try to compile the soa project again.

Wednesday, June 8, 2016

Weblogic 12c: start and stop script for starting weblogic admin and managed server

As in my previous blog post I share the concept of starting and stopping nodemanager. In this blog post I am going to show you how you can start and stop weblogic admin server and managed server using admin server connection.

Start scripts for admin server and managed server

Well the basic logic to start admin and managed server is as:

  • Start the admin server using ./startWeblogic.sh script stored at the domain directory.
  • check for the admin server status is running or not by using same way as did for nodemanager in this post. But here we check for the string "RUNNING"
  • After admin started we invoke to start all the managed server cluster (all the server in a cluster will automatically start).
Here is the script:


rm -rf  *_Server.out AdminServer.out

tfile="AdminServer.out"

cd $DOMAIN_HOME
nohup ./startWebLogic.sh > AdminServer.out &

AdminStatus="STOP"

while [ "$AdminStatus" = "STOP" ]; do
                echo $tfile

                count=$(cat $tfile | grep "RUNNING" | wc -l)

echo "The value of count is ${count}"

                if [[ "$count" -gt 0 ]]; then
                        echo "AdminServer Started..."
AdminStatus="RUNNING"
nohup $WEBLOGIC_HOME/common/bin/wlst.sh startOSB.sh > OSB_Server.out &
                        nohup $WEBLOGIC_HOME/common/bin/wlst.sh startSOA.sh > SOA_Server.out &
                        nohup $WEBLOGIC_HOME/common/bin/wlst.sh startWSM.sh > WSM_Server.out &

                        rm -f $tfile
                        exit 0
                else
                    echo "Waiting For AdminServer To Start..."
                        
                fi
        sleep 5s
        done


echo "Please check ${tfile} log file for more issues"
exit 1 

In the above scripts I am calling three more scripts which are used to start the managed server cluster.

startOSB.sh

Content of the script is as follow:

connect('weblogic', 'welcome1', 't3://adminhostname:port')

start('bpm_osb_cluster','Cluster')

disconnect()

startSOA.sh

Content of the script is as follow:

connect('weblogic', 'Oracle123', 't3://adminhostname:port')

start('bpm_soa_cluster','Cluster')

disconnect()

startWSM.sh

Content of the script is as follow:

connect('weblogic', 'Oracle123', 't3://adminhostname:port')

start('bpm_wsm_cluster','Cluster')

disconnect()

Note: you can start the server instead of start cluster, refer this documentation 

Stop scripts for admin and managed server

For stopping managed server scripts first connect to the nodemanager and use the nmkill() method to kill the managed server

nmConnect('weblogic', 'Oracle123', 'prdbpmn01.ebsafrica.com', '5556', 'BPMDomain', '/u02/oracle/config/domains/BPMDomain','ssl')

nmKill('wls_wsm1')
nmKill('wls_osb1')
nmKill('wls_soa1')

nmDisconnect()

exit()

so you have to kill each server because there is no such method available to stop the cluster.

After that stop the admin server using this script.

nohup sh /u01/oracle/config/domains/BPMDomain/bin/stopWebLogic.sh &

Weblogic 12c: start and stop script for nodemanager

Recently I was working on the automated script to start and stop the nodemanager, AdminServer and all managed server (ESS, SOA, OSB, WSM) in a domain. So in this post I am going to share my work, it may be possible that these scripts may not be suited for your environment but yes It must give you a basic idea of how to start and stop nodemanager automatically.

Start scripts for nodemanager

Well the basic logic that I used to start the nodemanager is

  • check if nodemanager is running or not
  • start the nodemanager and take the output in a temporary file.
  • while the nodemanager is starting keep looking for the string "socket listener started on port" in a temporary file. 
  • if the matching string is found that means node manager is started and exit().
rm -rf nodemanage.*

tfile="nodemanage.$$.out"
status= ps -eaf | grep "weblogic.NodeManager" | grep -v grep| wc -l
date=date
echo $status
echo "Node Manager Directory: " $1

if [[ "$status" -eq 0 ]]; then
echo  $date " :Starting Weblogic NodeManager..."
echo $1
nohup $1 > $tfile 2>&1 &

else
echo  $date " :NodeManager is already RUNNING.."
fi

if [ "$?" != 0 ]; then
echo "Command Failed To Execute Properly"
exit 1;
fi

export a=0;
while [ $a -lt 10 ]; do
echo $tfile

count=$(cat $tfile | grep "socket listener started on port" | wc -l)

echo "The value of count is ${count}"                 

if [[ "$count" -gt 0 ]]; then
echo "NodeManager Started..."
rm -f $tfile
exit 0
else
echo "Waiting For NodeManager To Start..."
echo $a
((a++))
fi
sleep 5s
done
echo "Please check ${tfile} log file for more issues"
exit 1

Save the above script in .sh file e.g. startNode.sh. Now to run this script you have to pass the location of the nodemanager i.e.

nohup ./StartNode.sh $DOMAIN_HOME/bin/startNodeManager.sh > nodemanage.out &


Stop script for nodemanager

To stop the nodemanager find the process id of nodemanager instance and kill that process id, here is the script below:

node1=$(ps -ef | grep weblogic.nodemanager | grep config=/u01 | awk '{printf $2}')

kill -9 $node1

Save the above code in the .sh file e.g. stopNode.sh and execute the script as below:

nohup sh StopNode.sh &


In the next post I am going to share the start and stop script for weblogic AdminServer and Managed server.

Friday, January 29, 2016

java.lang.Error: Critical Error. Failed to write transaction file /osb/configfwk/core_wls_osb1/_xact_ctrl.ih

Sometimes when you deployed the osb project using /sbconsole you will get the following exception while activating the project i.e.


Cause: 

The possible reason for this exception is the disk is full

Solution:

Check the disk space using the follwoing command

df -h

if the disk is full, then empty the space by deleting the logs file.

Tuesday, June 23, 2015

Oracle SOA: How to surround data around fields in file adapter

I was working on one of the usecase in which we need to surround single quote(') around the fields in output file during write operation in file adapter. For example:

Input:

<QuoteFileInput>
    <QuoteFile>
        <F1>A<F1>
        <F2>B<F2>
        <F3>C<F3>
        <F4>D<F4>
    <QuoteFile>
<QuoteFile>
        <F1>E<F1>
        <F2>F<F2>
        <F3>G<F3>
        <F4>H<F4>
    <QuoteFile>

<QuoteFileInput>

Output:








Well the main logic for this is in the nxsd schema file that file adapter creates. I created a simple soa application, and the composite and bpel looks like below




In the transformation, I simply mapped the input parameter of request to file adapter input parameter.

here is my nxsd schema file:





you can download the soa project from here click here

Friday, June 19, 2015

Oracle OSB 12c: For each loop in oracle osb

Today I was working on one of the usecase in which I required to loop incoming records and pass each record to a service callout and send back response for each request as a collection. Well using foreach in OSB is not a big deal but yes due to lack of information sometimes you can stuck and take hours or day to resolve the issue. In this post I will explain a simple example in which I am passing the collection of names (FirstName and SecondName) and send back response after concatenate first name and second name as a full name. eg.

Inputs:

               <v1:Request xmlns:v1="http://xmlns.codeconfuse.com/XSD/foreach/V1">
<!--Zero or more repetitions:-->
<v1:PersonList>
<v1:FirstName>Anshul</v1:FirstName>
<v1:LastName>Mittal</v1:LastName>
</v1:PersonList>
<v1:PersonList>
<v1:FirstName>code</v1:FirstName>
<v1:LastName>confuse</v1:LastName>
</v1:PersonList>
</v1:Request>

Outputs:

              <tns:Response xmlns:tns="http://xmlns.codeconfuse.com/XSD/foreach/V1">
<Output>Anshul Mittal</Output>
<Output>code confuse</Output>
</tns:Response>


I have created two pipelines i.e. ContactPP and ForeachPP.

ContactPP

Below picture is the ContactPP pipeline

 Here in the Response Pipeline, inside replace activity used transformation to concat the Incoming payload (FirsName and SecondName) to outgoing payload(FullName).





Below is the snapshot of source of xslt:


<xsl:template match="/">
    <ns0:OutputResponse>
      <ns0:FullName>
        <xsl:value-of select='concat (/ns0:InputRequest/ns0:FirstName, " ", ns0:InputRequest/ns0:SecondName )'/>
      </ns0:FullName>
    </ns0:OutputResponse>
  </xsl:template>

ForeachPP

Below picture shows the ForeachPP pipeline:



Inside Request Pipeline, drag and drop the For Each activity and also drag and drop assign activity to set the value of Input parameter of service callout and output parameter as shown below:


For Each Activity

Configure for each activity as shown below:


Configure Service Callout as shown below:


Now set the input parameter ContactReq inside the assign activity as below:



Now transform the output of this service callout and save it to $TmpVar. This is similar to following

$TmpVar = $TmpVar + $ContactResp



Now we have the response of service callout in $TmpVar, and we need to transform into actual service output. This we can do it in Response Pipeline

Now in the first assign transform the data as shown below:


And save it to $TmpVar again. And in the next assign add the soap envelope to the out payload as below:

done, deploy and test.

Test Result




Download the project --> com.codeconfuse.foreach.zip

I hope this post helps you in understanding for each concept in OSB. There must be some other easy ways to do it, well I tried to keep it simple but if you have much better and easy way then please share it.

Saturday, February 7, 2015

Oracle OSB: error: cos-nonambig: Content model violates the unique particle attribution rule.

My team was building schema for the OSB service and SOA-BPM processes and they all are parallely working on the schemas. After completing the schemas we start testing in osb service and process, but in the osb we are getting the following exception:

servicebus:BusinessObjects/Payment/Payment/V1/xsds/PaymentBO.xsd:157:5: error: cos-nonambig: Content model violates the unique particle attribution rule.


So this error occurs at line 157, when I checked the this line I found this:

 <xsd:complexType name="PaymentAuthMod_Type"> -------- line 157
    <xsd:sequence>
      <xsd:element ref="RqUID" minOccurs="0"/>
      <xsd:element ref="AsyncRqUID" minOccurs="0"/>
      <xsd:element ref="CustId" minOccurs="0"/>
      <xsd:element ref="Status" minOccurs="0"/>
      <xsd:element ref="EMVData" minOccurs="0"/>
      <xsd:element ref="NetworkTrnInfo" minOccurs="0"/>
      <xsd:element ref="POSData" minOccurs="0"/>
      <xsd:element ref="PmtAuthRec" minOccurs="0"/>
      <xsd:element ref="PmtAuthId" minOccurs="0" maxOccurs="unbounded"/>
      <xsd:element ref="PmtAuthRec" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:sequence>
  </xsd:complexType>

Solution:

I have gone through some documentation of UPA Rule i.e. Unique Partition Attribution rule which says same element can not have more than one meaning e.g.

<xsd:sequence>
    <xsd:element name="abc" type="xsd:integer" minOccurs="0"/>
    <xsd:any minOccurs="0" maxOccurs="unbounded" />
  </xsd:sequence>

Here, there is one possibility that  xsd:any can be as a element "abc".

OR

<xsd:sequence>
    <xsd:element name="abc" type="xsd:integer" minOccurs="0"/>
    <xsd:element name="abc" minOccurs="0" maxOccurs="unbounded" />
  </xsd:sequence>


So line 157 in my schema there is one element which is repeating with different meaning i.e.

    <xsd:element ref="PmtAuthRec" " minOccurs="0"/>
    <xsd:element ref="PmtAuthRec" minOccurs="0" maxOccurs="unbounded" />


So finally I removed one of the element and it worked.

References

  • http://www.w3.org/TR/xmlschema-1/#non-ambig
  • http://en.wikipedia.org/wiki/Unique_Particle_Attribution

Wednesday, February 4, 2015

Oracle OSB 12c: ORABPEL-15235, "Failed to translate JSON to XML" when processing a JSON Message

As we know in Oracle OSB 12c we got a new rest adapter to build and expose rest service from osb. So I was working on Rest adapter in osb and expose one of the rest service which is accepting the request in JSON format and sending the response in the same format. In rest service there are many parameters to be passed as request. So while testing this service from the osb console I am getting the following exception:

Translation Failure.
Failed to translate JSON to XML. 
The incoming data does not conform to the NXSD schema. Please correct the problem.

 ORABPEL-15235

Caused by: java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at de.odysseus.staxon.base.AbstractXMLStreamReader.getTextCharacters(AbstractXMLStreamReader.java:529)
at oracle.tip.pc.services.translation.xlators.json.JsonSaxEventsGenerator.generateEvents(JsonSaxEventsGenerator.java:241)
at oracle.tip.pc.services.translation.xlators.json.JsonTranslator.translateFromNative(JsonTranslator.java:139)

Solution:

Well for this error I have found a document in oracle support which says that this is the bug in Oracle OSB 12.1.3.0 that when processing the JSON message if the size of the request is greater than 4096 then this error is thrown.
So oracle support has issued a patch to resolve this issue. Patch number is 18692809 and for more information on this please follow the Document ID 1948201.1 on Oracle Support.

Sunday, October 12, 2014

Oracle OSB 12c: Pipeline templates in Oracle Service Bus 12c

One of the best thing for any developer is to write a code which can be used as many times in an enterprise application. Pipeline templates is one of such capability in Oracle Service Bus in which developer create a prototype of a  pipeline called as pipeline template and include all the component which can be use across the enterprise services. One such example can be a Error handler.

Here in this post I will try to explain and give an idea of how one can use the pipeline templates in its Oracle Service Bus application. I am going to create template in which I will include these components:

  • Validation
  • Error Handler
  • Logging
  • Alerts
  • Reports
As you can see these are the common components which can be used across all the Services in OSB.
Let me start with the basic.

Pipeline:

Pipeline component in OSB provides message processing capability i.e. defines logic for routing, validation, manipulation of messages (transformation) or error handling etc.
Primary elements for Pipeline are:
  • Start Node: It is a by default node define automatically when you connect to proxy service.
  • Pipeline Pair: node for request & response pair processing.
  • Branch Node: node to route the message based on condition either on type of operation or values.
  • Route Node: this node set the destination of message otherwise by default echo the request i.e. request is passed to the response.
  • Error Handler: handle errors either on stage or node.

Note: Minimum start node and route node required for pipeline.

Pipeline Template:

A template in pipeline is a prototype of message flow for proxy services. It defines the reusable activities that are common across the business process for example validations on business messages, error handling, transformation of request and response messages etc.

How to create pipeline templates in Jdeveloper

1.       Right click on the projectà NewàPipeline_Template
2.       Template wizard appears, Enter all the information.
3.       Click Next to select service type.
4.       Finish.
5.       Now in the pipeline template add the route node, error handler or any logic which is common across the service. (follow the example)

Note: you cannot create pipeline templates in OSB console.

Pipeline Template Example

Code Structure
  • Two projects i.e. SharedSB and ConsumeTemplate.
  • SharedSB is project in which we store all the common resources that can be used in all the service bus application and In ConsumeTemplate I will create a pipeline on the basis of pipeline template.

Create Pipeline Template (CommonComponent.ptx)
  1. Create pipeline template CommonComponent.ptx

  2. Drag and drop all the components that you think can be re-used in many services. In this case I am using Validity, Error handler, reports, logging, Alerts.
  3. After configuring all the activities, you can lock the activities so that the same configuration can be used in all the concrete pipeline i.e. in the pipeline where you are importing the pipleline template.

Creating concrete pipeline using template
  1. Create proxy service.
  2. Create pipleline using the template and use same signature as of your proxy service.
  3. After importing template, implement message flow logic if required.
  4. Save and deploy both the projects SharedSB and ConsumeTemplate on Oracle Service Bus server.
  5. Test your application.
References:

  • http://docs.oracle.com/middleware/1213/osb/develop/title.htm#BEGIN

Oracle OSB 12c: Break the pipeline template link from the concrete pipeline

In Oracle Service Bus if template that you use to create a concrete pipeline is no longer required than there is an option to break the link between the template and concrete pipeline. But remember this is a irreversible action so you can't go back and link again the template and concrete pipeline.

Here are the steps:

  1. Open the configuration of concrete pipeline.
  2. In the configuration of template, click on the break button as shown below.
  3. Click yes.
  4. Now concrete pipeline is converted into regular pipeline.
Note: As this is an irreversible action so please think before doing it whether it is required or not.