Friday, December 17, 2010

SAP Adapter : Configuring Database Repository

SAP Adapter(JCA config) supports both file based as well as database based repository. I have had some bad experiences with file based repository where maintaining the repository.xml has been more or less a nightmare. I have covered some of these errors in earlier posts.

targets-for-mysap-no-targets-configured.html

We sometimes end up with duplicate repository.xml files or 0kb repository.xml files after server restarts. This causes most BPEL processes to fail with Adapter exceptions. So I finally decided to migrate all file based repositories to DB repositories (Not sure why I didn't do this earlier :-( ). Now Oracle doesn't provide any migration tools as such. But this isn't a huge effort and we just need to create the targets/channels afresh and it is a one-time task.

Anyways below mentioned is the list of steps to be followed to configure DB repository for SAP adapter.

1. Create a new schema user on database where you want the repository to reside. (Eg: saprepo_user/xxxxx)

2. Execute the iwse.ora SQL script on the machine where the database is installed. The iwse.ora SQL script is located in the following directory:
$MW_HOME\Oracle_SOA1\soa\thirdparty\ApplicationAdapters\etc

This script creates the required tables that are used to store the adapterconfiguration information in the database. These tables are used by Application Explorer and by adapters during design time and runtime. It is recommended that you use the same credentials to create the database repository and also in the ra.xml file for database user credentials.

3. Create the jcatransport.properties file and save it in the following directory:
$MW_HOME\Oracle_SOA1\soa\thirdparty\ApplicationAdapters\config\Config_Name

4. Enter values for iwafjca.repo.url, iwafjca.repo.user and iwafjca.repo.password fields in the newly created jcatransport.properties file, as shown in the following example:

iwafjca.repo.url=jdbc:oracle:thin:@dbhostname:port:sid
iwafjca.repo.user=saprepo_user
iwafjca.repo.password=xxxx

5. Navigate to the following directory:
$MW_HOME\Oracle_SOA1\soa\thirdparty\ApplicationAdapters\iwafjca.rar\META-INF

6. Open the ra.xml file and provide the JDBC connection information: (Same values as step3)
IWAYRepo_URL property.
IWAYRepo_User property.
IWAYRepo_Password property.

Save your changes to the ra.xml file.

7. Copy the ojdbc14.jar file to the directory $MW_HOME\Oracle_SOA1\soa\thirdparty\ApplicationAdapters\lib

8. Redeploy the iwafjca rar file from Admin console->deployments section and Restart Weblogic server.

9. Now open Application Explorer and create the SAP target again with similar details as before. You can then connect to the DB repository and check the af_config table to find your details stored there.

NOTE:
The above steps are for SOA 11g. For SOA 10g the directory structures will be different.
* jcatransport.properties file in following directory \adapters\application\config\
* copy ojdbc14.jar to \adapters\application\lib\
* Update oc4j-ra.xml (\j2ee\oc4j_soa\application-deployments\default\jca-app-adapter)

I haven't faced any issues so far after migrating from File to DB repository. Will definitely post if I find any discrepancies. Till then some relief :-)

Tuesday, December 14, 2010

Custom XSLT Function in SOA 11g

Its been a while since I blogged and has been busy few months. I recently got a requirement to strip all special characters from an input string in XSLT. Tried checking the list of pre-defined XSLT functions in Jdeveloper 11g to see if we had something similar. Though we have few string functions to normalize whitespaces and others which match against regex patterns. But none which replaced/stripped special characters/regex patterns from a string. So decided to write some custom XSLT function which could do this.

First we create the java class which implements the logic

package customxslt;
import java.io.PrintStream;
public class AdditionalStringFunctions
{
  public static String replaceChars(String input, String regex, String replaceWith)
  {
    String output = input.replaceAll(regex, replaceWith);
    return output;
  }
  public static void main(String[] args)
  {
    AdditionalStringFunctions aSF = new AdditionalStringFunctions();
    String input = "(+91)80-55555555";
    System.out.println(replaceChars(input, "[^0-9]", ""));
  }
}

All the above code does is, check for input string and any characters apart from 0-9 is stripped.

Next create a configuration file.Name the file as ext-mapper-xpath-functions-config.xml. Sample file is provided below

<soa-xpath-functions version="11.1.1"
                     xmlns="http://xmlns.oracle.com/soa/config/xpath"                 xmlns:regex="http://www.oracle.com/XSL/Transform/java/customxslt.AdditionalStringFunctions">
   <function name="regex:replaceChars">
    <classname>customxslt.AdditionalStringFunctions</className>
    <return type="string"/>
    <params>
      <param name="input" type="string"/>
      <param name="regex" type="string"/>
      <param name="replaceWith" type="string"/>
    </params>
    <desc/>
    <detail>
      <![CDATA[This function returns the value after stripping special characters.]]>
    </detail>
  </function>
 </soa-xpath-functions>

Create a folder called META-INF under the JDeveloper\mywork\Regex\TestRegex\classes directory and place the configuration file there.

Now create a jar file and make sure the class file and the ext-mapper-xpath-functions-config.xml are included in it.

Next register the JAR file in Jdeveloper designtime
This can be done via "Tools > Preferences… > SOA" add the JAR file and restart JDeveloper.


The newly created extension function will be available in the component palette under user defined functions page. You can make use it from there in your XSL code.


To make this function available at SOA runtime put the jar file under MW_Home/user_projects/domains/domain_name/lib

Restart the server and test your code.

Thursday, October 28, 2010

SAP JCO Connectivity Test

This will be a small post on testing SAP JCO connection. Usually for connecting to SAP systems from Oracle SOA suite, we make use of the SAP adapter and create a SAP target from Application Explorer(AE). After entering the basic credentials like username,password, clientid, system number and application server we can try connecting to SAP system from AE itself. This internally calls the SAP JCO classes to establish the connection.

We can also directly test the connection outside of AE by using the SAP JCO classes. Below sample code can be used for testing the SAP JCO connectivity.

package JCOConnectionTest;
import com.sap.mw.jco.*;
public class JCOConnector {
  public JCOConnector() {
    super();
  }
  JCO.Client mConnection;
  public void Connect1() {
  try {
  // Change the logon information to your own system/user
          mConnection =
             JCO.createClient("010", // SAP client
               "SAP_USER", // userid
               "sap_pswd", // password
               null, // language
               "sap_server", // application server host name
               "00"); // system number
          mConnection.connect();
          System.out.println(mConnection.getAttributes());
          mConnection.disconnect();
       }
       catch (Exception ex) {
         ex.printStackTrace();
         System.exit(1);
       }
  }
      public static void main (String args[]) {
       JCOConnector app = new JCOConnector();
       app.Connect1();
      }
}  

Make sure the sapjco.jar file is present in your classpath(add to project classpath if you are running this from Jdeveloper.) On successful connection you are shown the details of the server with an exit code of 0 and incase of failure you are shown some RFC errors like RFC_LOGON_FAILURE etc.

Tuesday, October 26, 2010

XSLT 2.0 Grouping & Sorting in 11g BPEL

I had a requirement recently where I had to split my incoming XML file(read from a database) based on a particular field and send the split sections to another BPEL process for further processing.

Here is how the Input xml looked like


 
  arr1
  ...
  ...
  
  
  arr2
  ...
  ...
  
  
  arr1
  ...
  ...
  
  
  arr2
  ...
  ...
  


Desired Output looks like this.



  
  arr1
  ...
  ...
  
  
  arr1
  ...
  ...
  


  
  arr2
  ...
  ...
  
  
  arr2
  ...
  ...
  



As can be seen above, the idea was to split the Input xml based on arr_id field into different collections and each collection having data for a particular arr_id. Once this is done, all I had to do is run a loop in my BPEL and for each collection send the data to the 2nd BPEL process.

I decided to use XSLT Grouping and Sorting feature to accomplish this task. If we are using XSLT 1.0 there is a particular way to do this using xsl:key which has been explained well in http://www.jenitennison.com/xslt/grouping/muenchian.html . However this can be done easily in XSLT 2.0 using xsl:for-each-group.

Below is the XSL file which does this task for us,

<xsl:stylesheet version="2.0" xmlns:ns1="http://xmlns.oracle.com/pcbpel/adapter/db/Select_Arrid" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:template match="/">
  <ns1:root>
    <xsl:for-each-group select="*/ns1:Select_Arrid" group-by="ns1:Arr_id">
        <xsl:sort select="current-grouping-key()">
        <ns1:select_arrid_collection>
           <xsl:copy-of select="current-group()">
                <xsl:apply-templates/>
          </xsl:copy-of> 
        </ns1:select_arrid_collection>
      </xsl:sort>
    </xsl:for-each-group>
   </ns1:root>
 </xsl:template>
</xsl:stylesheet>

Make sure the version of XSL is 2.0 for using the xsl:for-each-group construct. Now the xsl can be used in any transform activity and will give us the desired output. Hope this helps someone having similar XSLT grouping requirement in BPEL.

Monday, October 18, 2010

AIA Error Handling : Error Notifications/Emails

In continuation with my earlier posts on AIA Error handling, I will cover the steps required to enable/send error notifications in this post. AIA Error handling framework has out-of-the-box error email functionality. Incase of partner link errors like remote/binding faults the fault-policy.xml file should take care of sending the error notification/email. Incase of non-partner link error the AIAAsyncErrorHandlingBPEL process is called from catch-all block which inturn sends out the error email.

A sample fault-policy.xml file is shown below


















3
2






























In above file, the oracle.apps.aia.core.eh.CompositeJavaAction class file gets invoked when remote/binding fault occurs and takes care of sending the error notification to AIAIntegrationAdmin user.

A sample code for populating EBM Header in catch-all block is shown below

1. First create a variable named EBM_HEADER
<variable name="EBM_HEADER" element="ns3:EBMHeader"/>

ns3 here refers to corecom namespace.

2. Make sure your ABM_to_EBM.xsl or EBM_to_ABM.xsl are populating the EBM header section correctly (eg. EBMID, EBOName etc...)

3. In catch-all block make sure you are populating the EBM_HEADER before invoking the AIAAsyncErrorHandlingBPELProcess
<assign name="Assign_Fault">
           <copy>
            <from expression="ora:processXSLT('xsl/EBM_to_Fault.xsl',bpws:getVariableData('EBM_HEADER'))"/>
            <to variable="Invoke_AIAAsyncErrorHandlingBPELProcess_initiate_InputVariable"
                part="FaultMessage" query="/ns3:Fault"/>
          </copy>
          <copy>
            <from expression="ora:getFaultAsString()"/>
            <to variable="Invoke_AIAAsyncErrorHandlingBPELProcess_initiate_InputVariable"
                part="FaultMessage" query="/ns3:Fault/ns3:FaultNotification/ns3:FaultMessage/ns3:Text"/>
          </copy>
          <copy>
            <from expression="xpath20:current-dateTime()"/>
            <to variable="Invoke_AIAAsyncErrorHandlingBPELProcess_initiate_InputVariable"
                part="FaultMessage" query="/ns3:Fault/ns3:FaultNotification/ns3:ReportingDateTime"/>
          </copy>
          <copy>
            <from expression="ora:getProcessId()"/>
            <to variable="Invoke_AIAAsyncErrorHandlingBPELProcess_initiate_InputVariable"
                part="FaultMessage" query="/ns3:Fault/ns3:FaultNotification/ns3:FaultingService/ns3:ID"/>
          </copy>
          <copy>
            <from expression="'BPEL'"/>
            <to variable="Invoke_AIAAsyncErrorHandlingBPELProcess_initiate_InputVariable"
                part="FaultMessage" query="/ns3:Fault/ns3:FaultNotification/ns3:FaultingService/ns3:ImplementationCode"/>
          </copy>
          <copy>
            <from expression="ora:getInstanceId()"/>
            <to variable="Invoke_AIAAsyncErrorHandlingBPELProcess_initiate_InputVariable"
                part="FaultMessage" query="/ns3:Fault/ns3:FaultNotification/ns3:FaultingService/ns3:InstanceID"/>
          </copy>
          <copy>
            <from expression="ora:getECID()"/>
            <to variable="Invoke_AIAAsyncErrorHandlingBPELProcess_initiate_InputVariable"
                part="FaultMessage" query="/ns3:Fault/ns3:FaultNotification/ns3:FaultingService/ns3:ExecutionContextID"/>
          </copy>
        </assign>
      <invoke name="Invoke_AIAAsyncErrorHandlingBPELProcess" inputVariable="Invoke_AIAAsyncErrorHandlingBPELProcess_initiate_InputVariable"
              partnerLink="AIAAsyncErrorHandlingBPELProcess"
              portType="ns10:AIAAsyncErrorHandlingBPELProcess"
              operation="initiate"/>

Apart from this there are certain configurations which need to be done for successfully sending error emails.

1. Set the email driver properties from EM Console :

OutgoingMailServer :
OutgoingMailServerPort :
OutgoingMailServerSecurity :
OutgoingDefaultFromAddress:

2. In AIA_HOME/aia_instances/Instance_name/AIAMetaData/config/AIAConfigurationProperties.xml file , below properties should be set
<Property name="EH.INVOKE.NOTIFY">true</Property>
<Property name="FROM.EMAIL.ID">Email:AiaAdmin@oracle.com</Property>
<Property name="EH.DEFAULT.ACTOR.ROLE">AIAIntegrationAdmin</Property>

3. In User Messaging Preferences console (http://:/sdpmessaging/userprefs-ui) add email Id for user AIAIntegrationAdmin. Login to this console with AIAIntegrationAdmin/welcome1.

NOTE: Message channels are meant to be a single email address or phone number etc.But you can refer to an email distribution list if you want to send these emails to multiple persons.

4. Upload the AIAConfigurationProperties.xml file to MDS and Reload the configuration from AIA Console setup page.Make sure when you update UpdateMetaDataDP.xml for loading the AIAConfigurationProperties.xml into MDS it should look something like below:
<fileset dir="${AIA_HOME}/aia_instances/instance_name/AIAMetaData">
<include name="config/AIAConfigurationProperties.xml" />
</fileset>

Also if the Go buttons are not enabled on AIA Console Setup page, make sure the weblogic user has the role AIAApplicationUser associated with it. You can associate roles on the Weblogic Admin Console under Security Realms.

5. Also set Notification mode to 'Email' from 'SOA Administration' -> 'Workflow Notification Properties' in EM Console.

Wednesday, October 6, 2010

Error Handling in SAP Adapter

I have come across a couple of scenarios where even though data gets posted successfully to SAP via BAPIs, but the adapter still throws an error message. At the BPEL layer the adapter throws a generic error like  "Error in Processing Input Document"

Something similar to below is shown in JCA log files:

<RETURN>
      <item>
         <TYPE>S</TYPE>
         <ID>RW</ID>
         <NUMBER>605</NUMBER>
         <MESSAGE>Document posted successfully: 060014911815002010 PRDCLNT500</MESSAGE>
         <LOG_NO/>
         <LOG_MSG_NO>000000</LOG_MSG_NO>
         <MESSAGE_V1></MESSAGE_V1>
         <MESSAGE_V2>060014911815002010</MESSAGE_V2>
         <MESSAGE_V3>PRDCLNT500</MESSAGE_V3>
         <MESSAGE_V4/>
         <PARAMETER/>
         <ROW>0</ROW>
         <FIELD/>
         <SYSTEM>PRDCLNT500</SYSTEM>
      </item>
      <item>
        <TYPE>W</TYPE>
         <ID>KI</ID>
         <NUMBER>155</NUMBER>
         <MESSAGE>Profitability segment is derived as new</MESSAGE>
         <LOG_NO/>
         <LOG_MSG_NO>000000</LOG_MSG_NO>
         <MESSAGE_V1/>
         <MESSAGE_V2></MESSAGE_V2>
        <MESSAGE_V3/>
         <MESSAGE_V4></MESSAGE_V4>
         <PARAMETER/>
         <ROW>0</ROW>
         <FIELD/>
         <SYSTEM>PRDCLNT500</SYSTEM>
      </item>
   </RETURN>

MySAP response error: BapiWarning: Profitability segment is derived as new

IWAFManagedConnectionFactory com.ibi.sap.SapConnection rollback(266) Call BAPI_TRANSACTION_ROLLBACK

IWAFManagedConnectionFactory com.ibi.sap.SapAdapter20 inProcess(397) java.lang.Exception: BapiWarning: Profitability segment is derived as new
at com.ibi.sap.DocumentRunner.processIfrDocument(DocumentRunner.java:274)
at com.ibi.sap.SapAdapter20.inProcess(SapAdapter20.java:369
…
…

This ultimately rolls back to the error "Error in Processing Input Document" at BPEL layer.

To overcome this situation SAP adapter provides an option for error handling . From Application explorer if you edit the SAP target then there are 2 choices under Advanced tab : Throws Exception and Creates Error Document.


If you set it to "creates error document" and restart the server, the BAPI invocations should work correctly and above RETURN section should be shown in the BPEL layer as well.

Saturday, October 2, 2010

BPEL Console fails with "ORA-28001: the password has expired"

I recently came across an issue while accessing BPEL console, and was shown a SQL Exception "ORA-28001: the password has expired" on the BPEL console page. On checking the Oc4j_soa log files found the same error:

java.sql.SQLException: ORA-28001: the password has expired
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:138)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:316)
...
...

On debugging further found that the orabpel and oraesb account passwords had EXPIRED on the Fusion DB. That was by design and implementation of the Oracle DEFAULT profile to which the users belonged. So to fix the issue the user accounts had to be unlocked/unexpired so that status showed as OPEN.

You can also check with your DBA team to see if the DEFAULT profile can be changed to allow unlimited days for a password and unlimited attempts at logging in (before account is locked).

Thursday, September 9, 2010

AIA 3.0 : Service Constructor support for DB adapter and JCA adapters.

As per the AIA developer's guide
"Currently the Service Constructor supports only services that have an exposed interface and cannot yet directly invoke JCA adapters such as the File or DB adapter."

Incase you want to invoke DB adapter in your ProviderABCS or receiving DB records in your RequestorABCS, the Oracle recommended way is to create the adapter as a separate composite and use the same in your AIA Service Constructor.

I came across a similar situation where my RequestorABCS had to be kicked off when SAP sends an idoc (via SAP Channel) or if I had to poll records from a DB table. In both cases I had to create the SAP adapter/DB adapter as a separate composite and invoke the RequestorABCS wsdl from there.
This approach also ensures reusability of the adapter composite code incase other ABCS want to use it.

Friday, September 3, 2010

Targets for MySAP : No targets configured for this adapter.

This is a common error when configuring/working with SAP adapter. The error is seen while running composite BPEL processes which try to connect to SAP or from the iwafjca page.
http://hostname:port/iwafjca/service.jsp

Targets for MySAP
No targets configured for this adapter.

If you have SAP Channels configured for inbound events from SAP to BPEL then you may see errors like below :

SEVERE IWAFManagedConnectionFactory com.iwaysoftware.afjca15.AbstractResourceAdapter endpointActivation(194) An Exception was caught while activating the endpoint
java.lang.IllegalArgumentException: Channel 'SalesOrder_Channel' not available for adapter 'MySAP'.
at com.iwaysoftware.af.container.ChannelManager.checkConfig(ChannelManager.java:421)
...
...
Make sure your ra.xml file under SOA_HOME/soa/thirdparty/ApplicationAdapters/iwafjca.rar/META-INF directory has config properties IWayHome and IWayConfig set correctly. The above errors indicate that the adapter is not able to read the information in repository (file/db).

Check in your configuration folder SOA_HOME/soa/thirdparty/ApplicationAdapters/config/YourConfigName/ if there are multiple files like repository.xml1, repository.xml2 etc in addition to repository.xml. Similarly check if there are multiple st_repository files like st_repository.xml1, st_repository.xml2 in addition to st_repository.xml.

In that case, you might have done some CRUD operation when the iwafjca.rar is deployed and running. When ever you are doing CRUD operations in iwae, please make sure the iwafjca.rar is not deployed or is in inactive mode especially when you are using file repository.

To fix the errors :

1. Make sure your repository.xml contains correct target information.
2. Then redeploy the iwafjca.rar from admin console
3. Restart the managed server. It should work now !

Wednesday, September 1, 2010

AIA Error Handling: Trace Logging feature

Trace logging in AIA is enabled via configurations in the AIAConfigurationProperties.xml file located in <AIA_HOME>/aia_instances/$INSTANCE_NAME/AIAMetaData/config directory.

Logging can be set at the system or service level. The logging property set at the service level overrides the property set at the system level. To enable trace logging for the entire system follow below steps:

1. Access the AIAConfigurationProperties.xml file.
2. Set the TRACE.LOG.ENABLED property at the system level to true.
3. Update the file back to MDS
4. Reload updates to AIAConfigurationProperties.xml from configuration page of AIA Console.

In the BPEL code, trace logging is added by inserting Java Embedding activities. These activities basically call the AIA trace logging functions : isTraceLoggingEnabled and logTraceMessage. If you are using AIA Service constructor for ABCS development, this piece of code is auto-generated for you.

The Oracle AIA trace and error log files can be accessed from EM Console or directly from file system:
$MW_HOME/user_projects/<domain_name>/servers/soa_server1/logs/aia-error.log
$MW_HOME/user_projects/<domain_name>/servers/soa_server1/logs/aia-trace.log

The logging level like logLevel Severe, Warning, Info, Fine, Finest etc. can also be configured from EM Console.

AIA Error Handling : WSDL messageType "{http://schemas.oracle.com/bpel/extension}RuntimeFaultMessage" is not defined

In my next couple of posts I will be covering AIA Error handling and trace logging features. Below screenshot depicts how a typical AIA fault handler section looks in ABCS(BPEL). We have catch blocks for handling partner link errors like remote/binding fault and we have a catch-all block which deals with non-partner link errors.

Now remote/binding faults are fault-policy driven. These fault policy files have specific actions defined like ora-retry and ora-java-action which take care of retrying the error and sending error emails. (More details in my next post) During an invoke activity, when a binding/remote fault occurs , the underlying fault management framework of the Oracle SOA catches the fault and performs actions as defined in the associated fault policy and then rethrows the fault back to the catch blocks. Now, the catch activity in the BPEL should process the fault and as part of fault processing it has to rethrow the fault back inside the catch block,so that transaction roll back happens correctly and instance appears as faulted in console.

A common error seen while trying to compile ABCS code after adding fault handlers is :

Error(90): unresolved messageType
WSDL messageType "{http://schemas.oracle.com/bpel/extension}RuntimeFaultMessage" of variable "SystemFaultVar" is not defined in any of the WSDL files. Make sure the WSDL messageType "{http://schemas.oracle.com/bpel/extension}RuntimeFaultMessage" is defined in one of the WSDLs referenced by the deployment descriptor

To get rid of above error follow below steps:

1. import oramds:/soa/shared/bpel/RuntimeFault.wsdl into your process.wsdl
<wsdl: import namespace="http://schemas.oracle.com/bpel/extension" location="oramds:/soa/shared/bpel/RuntimeFault.wsdl"/>
2. Create a variable(SystemFaultVar) based upon the messagetype RuntimeFaultMessage in this wsdl.
<variables>
<variable name="SystemFaultVar" messageType="bpelx:RuntimeFaultMessage"/>
</variables>
3. In the catch branch use the RuntimeFaultMessage as the Fault Variable
<faultHandlers>
<catch faultName="bpelx:bindingFault" faultVariable="SystemFaultVar">
...
4. Also make sure in your composite.xml, you import the RuntimeFault.wsdl before importing the process.wsdl

Try compiling and deploying the process. It should work fine now !

Tuesday, August 31, 2010

Date formats in SAP and Inverted date format

People doing integrations with SAP R/3 system must be aware that SAP R/3 takes in/out date fields with format of YYYYMMDD (This is their internal date format). However there is a special date format called Inverted date which is used to store some date fields in SAP tables.

If you work on Currency Exchange Conversions (TCURR table) the Date Field (GDATU) stores date in Inverted date format. So what exactly is this Inverted date format and how can you convert it to normal date format of YYYYMMDD which can be later used in your integration.

Inverted date is nothing but the 9's complement of the real date. In other words the conversion logic will be something as shown below

99999999 – (GDATU) = actual date in yyyymmdd format
Example: 99999999 – 79899168 = 20100831

There are conversion exits in ABAP which does this date conversion like CONVERSION_EXIT_INVDT_OUTPUT -- Conversion exit routine for inverted date (OUTPUT)

However if your SAP BAPI gives you data in inverted date format you can use the logic mentioned above in your BPEL/XSL at Fusion layer to convert it into actual date format.

Monday, August 30, 2010

SOA 11g : EM Console fails with HTTP 404 error ; JspServlet error

After restarting servers (admin and managed) found that EM console isn't coming up and it shows below error either on browser or Admin server log files:
"JspServlet error: Servlet unable to dispatch to the following requested page: java.io.FileNotFoundException: /targetauth/asLogin.jspx"

On further checking the directory targetauth was missing from <MW_HOME>/user_projects/domains/<domain_name>/servers/AdminServer/tmp/_WL_user/emcore/28c293 location. This directory has the asLogin.jspx file.

You can copy this directory from a different domain but that would still give errors like 
"JspServlet error: Servlet unable to dispatch to the following requested page: java.io.FileNotFoundException: MDS-00013: no metadata found for metadata object "/targetauth/asLogin.jspx" 

Solution :
1. Stop the Admin server
2. Rename <MW_HOME>/user_projects/domains/<domain_name>/servers/AdminServer/tmp/ directory to tmp-old
3. Restart the Admin server. The tmp directory will be recreated again.

Open EM Console.It should work now !

Monday, August 23, 2010

Dependent SCA composites fail with "503: Service Unavailable for url" after server restart

We often design composite applications that invoke other composite applications. A typical use case would be AIA artifacts where RequestorABCS calls EBS which in turn calls ProviderABCS.

If these are not configured correctly then after restarting SOA server the one having dependency does not work any more. Basically issue is with the order in which SOA server re-deploys these composites. You may see the below error message in EM console

The composite SalesOrderRequestorABCS (1.0) is not available. This could happen because either the composite has been undeployed or soa-infra has not yet loaded this composite.
[JCABinding] [SalesOrderRequestorABCS/1.0]Unable to complete load due to: Error in getting XML input stream: http://hostname:port/soa-infra/services/default/SalesOrderEBS/SalesOrderEBS_ep?WSDL: Response: '503: Service Unavailable' for url


The recommendations to avoid dependencies between composites are :

1. In the composite.xml of the calling composite have the import refer to an abstract wsdl and
not a concrete one to avoid loading issues.
2. Make sure you refer to the MDS location for common XSDs, WSDLs and deployed composites.

For example in case of RequestorABCS if you are having references to end point URL of EBS(obtained from EM console after deployment of EBS) then make sure you change that to oramds location for abstract WSDL.

FROM
<import namespace="http://xmlns.oracle.com/EnterpriseServices/Core/SalesOrder/V2" location="http://hostname:port/soa-infra/services/default/SalesOrderEBS/SalesOrderEBS_ep?WSDL" importType="wsdl"/>
<reference name="SalesOrderEBS" ui:wsdlLocation="http://hostname:port/soa-infra/services/default/SalesOrderEBS/SalesOrderEBS_ep?WSDL">
<interface.wsdl interface="http://xmlns.oracle.com/EnterpriseServices/Core/SalesOrder/V2#wsdl.interface(SalesOrderEBS)"/>
<binding.ws port="http://xmlns.oracle.com/EnterpriseServices/Core/SalesOrder/V2#wsdl.endpoint(SalesOrderEBS_ep/SalesOrderEBS_pt)" location="http://hostname:port/soa-infra/services/default/SalesOrderEBS/SalesOrderEBS_ep?WSDL"/>
</reference>

TO

<import namespace="http://xmlns.oracle.com/EnterpriseServices/Core/SalesOrder/V2" location="oramds:/apps/AIAMetaData/AIAComponents/EnterpriseBusinessServiceLibrary/Core/EBO/SalesOrder/V2/SalesOrderEBSV2.wsdl" importType="wsdl"/>
<reference name="SalesOrderEBS" ui:wsdlLocation="oramds:/apps/AIAMetaData/AIAComponents/EnterpriseBusinessServiceLibrary/Core/EBO/SalesOrder/V2/SalesOrderEBSV2.wsdl">
<interface.wsdl interface="http://xmlns.oracle.com/EnterpriseServices/Core/SalesOrder/V2#wsdl.interface(SalesOrderEBS)"/>
<binding.ws port="http://xmlns.oracle.com/EnterpriseServices/Core/SalesOrder/V2#wsdl.endpoint(SalesOrderEBS_ep/SalesOrderEBS_pt)" location="http://hostname:port/soa-infra/services/default/SalesOrderEBS/SalesOrderEBS_ep?WSDL"/>
</reference>

Similarily if you are referring to ProviderABCS from EBS composite.xml of EBS will look something as below

<reference name="SalesOrderProviderABCS" ui:wsdlLocation="oramds:/deployed-composites/SalesOrderProviderABCS_rev1.0/SalesOrderProvABCSImpl.wsdl">
..
..

Saturday, August 21, 2010

HTTP Binding Adapter in SOA 11g

With the release of SOA Suite 11gR1 Patch Set 2 (PS2)! Oracle has added support for HTTP binding (helpful when we want to do away with SOAP and looking for simple GET and POST). 
I had a requirement recently where I had to integrate with an external vendor which supported HTTP(s) posting of files. So I started looking at ways to post a XML file to the HTTP(s) location. Luckily with Jdeveloper 11g (11.1.1.3) version we have a HTTP binding adapter available which can be made use of.


You can drag the HTTP binding from component palette into your composite and configure it to post XML data to a HTTP(s) endpoint. Incase you are using HTTPS you would require the certificates to be installed on the SOA server if it is server authentication and your certificates need to be installed on vendor side if its mutual authentication. Apart from that it should be similar to HTTP.


For more details on how to configure the HTTP binding adapter wizard please follow the below blogpost from Edwin Biemond where he has illustrated this with screenshots.
Http Binding Adapter Configuration In Soa Suite 11g

Friday, August 20, 2010

Unit testing Oracle SCA Composites

With Oracle SOA 11g we have a unit testing framework available for testing the individual components. This enables us to test the components in isolation without any external dependencies like availability of target services. This in turn helps during integration testing as we already have well tested low level components.

The framework allows :
1. Definition of Tests, assertions and emulations via Jdeveloper
2. Deployment of test cases along with deployment of SCA composite
3. Execution of test cases from EM console.

A typical testcase may contain an initiated message, an emulation which defines message/error
returned by an external reference/service and/or an assertion which is primarily used for comparison against expected results.

Below I have shown an example where I tested a component (AIA RequestorABCS) which had a DB adapter as initiator of process and called an external target service like SAP R/3. Now for unit testing this piece I used an initiator message in my test suite and an emulator to define a response message from SAP R/3. This way I don't have to depend on availability of actual target system at time of unit testing my ABCS code.

The test suite can be created from Jdeveloper :







It creates a copy of the composite.xml as shown below.














Once completed, deploy the test suite along with normal SCA deployment from Jdev/ant scripts and execute it from EM Console as shown below.

Count(bpws:getVariableData(....)) results in SelectionFailure in SOA 11g

This perhaps will be a short post about a known issue on SOA 11g. I was trying to use count XPATH function on getVariableData to find count of dataarea in EBM. This worked fine in SOA 10g but in 11g it failed with SelectionFailure.

Found that this is a known issue in SOA 11g.
Oracle Release Notes for 11g

16.1.8 getVariableData Function Throws a selectionFailure if the Result Node Set is of a Size Other Than One During Execution

According to the Business Process Execution Language for Web Services Specification, if the the locationPath argument of the bpws:getVariableData() function selects a node set of a size other than one during execution, the standard fault bpws:selectionFailure must be thrown by a compliant implementation.


To get around this issue simply use ora:getNodes() which acts as an alternate to getVariableData to obtain the same functionality. getVariableData is striclty for one node result, where as getNodes would return a nodeset.

Wednesday, August 18, 2010

BPEL Scheduling: Quartz and Database

A common requirement in many SOA projects is to schedule BPEL processes to run at specific time. Now there are various scheduling mechanisms which can be used for doing this. In this post I will be discussing about 2 approaches which I have used :
1. Using Open source Quartz scheduler.
2. Scheduling your process from Database using dbms_scheduler apis.

In Oracle BPEL open source job scheduler, Quartz is implemented as part of java class called DefaultSchedulerCalloutImpl. Incase your BPEL process is triggered by a file/ftp adapter you can modify the bpel.xml file to make use of the quartz scheduler.

<activationAgents>
<activationAgent className="oracle.tip.adapter.fw.agent.jca.JCAActivationAgent"
partnerLink="ReadFile" heartBeatInterval="10">
<property name="portType">Read_ptt</property>
<property name="schedulerCallout">DefaultSchedulerCalloutImpl</property>
<property name="endpointScheduleOn">0 0 8 * * ?</property>
<property name="endpointScheduleOff">0 0 10 * * ?</property>
</activationAgent>
</activationAgents>

The above piece of code is direction to the activation agent to activate the BPEL process between 8 and 10 am everyday and heartbeat interval of 10 seconds indicates how frequently the process is active for polling.

The 2nd approach is a simple solution based on Oracle dbms_scheduler api. Basically you need to have your BPEL process read from a DB table which gets populated by the DBMS job at a particular frequency. I am sharing some sample code below which can be reused after making modifications.

Create table bpelschedulertable (process_name varchar2(20));

Script to create the scheduler job.

/* Drop Jobs if they exist */
BEGIN
DBMS_SCHEDULER.DROP_JOB(JOB_NAME => 'BpelScheduledJob');
END;
/

/* Create Scheduled Job */
BEGIN
 DBMS_SCHEDULER.CREATE_JOB(
 JOB_NAME => 'BpelScheduledJob',
 JOB_TYPE => 'PLSQL_BLOCK',
 JOB_ACTION => 'BEGIN INSERT INTO bpelschedulertable (PROCESS_NAME) VALUES (''samplebpel'');COMMIT;END;',
 START_DATE => TO_DATE('2010-08-18 12:00:00','YYYY-MM-DD HH24:MI:SS'),
 REPEAT_INTERVAL => 'FREQ=MINUTELY;INTERVAL=15',
 COMMENTS => 'Scheduled for every 15 minutes');
 DBMS_SCHEDULER.ENABLE(NAME => 'BpelScheduledJob');
 END;
/

That's it ! Your BPEL process(samplebpel) should trigger every 15 minutues now.

Scripts to monitor/manage the scheduled job.

select * from dba_scheduler_jobs ;

/*Command to enable job*/
Begin    
dbms_scheduler.enable('BpelScheduledJob');  
end;

/*Command to disable job*/
Begin
Dbms_scheduler.Disable('BpelScheduledJob');
end;

/*Command to change the repeat interval of the job*/
Begin
Dbms_scheduler.set_attribute(name=>'BpelScheduledJob',attribute=> 'REPEAT_INTERVAL', value=> 'FREQ=HOURLY;INTERVAL=1');
end;

Friday, August 6, 2010

Common SOA composite deployment errors from Jdeveloper

In this post I would like to share few deployment errors I faced with SOA composites from Jdeveloper and their resolutions. This will be helpful to people starting work on SOA 11g.

Error 1 :

Preparing to send HTTP request for deployment
Creating HTTP connection to host:xxxx, port:yyyy
Sending internal deployment descriptor
Sending archive - sca_HelloWorld_rev1.0.jar
Received HTTP response from the server, response code=500
Error deploying archive sca_HelloWorld_rev1.0.jar to soa_server1 [xxxx:yyyy]  
HTTP error code returned [500]
Error message from server: 
Unknown Host
Description: Unable to locate the server named "xxxx" --- the server does not have a DNS entry.  Perhaps there is a misspelling in the server name, or the server no longer exists.  Double-check the name and try again.

OR

Error 2 :

Problem in sending HTTP request to the server. Check standard 
HTTP response code for 502
No error message is returned from the server.
#### Deployment incomplete. ####
Error deploying archive file:/C:/JDeveloper/mywork/Sample/HelloWorld/deploy/sca_HelloWorld_rev1.0.jar
 (oracle.tip.tools.ide.fabric.deploy.common.SOARemoteDeployer)


Solution :

1. Go to weblogic console. Server->click on managed Server and select configuration->General tab
    There in listen address provide the listen address to the ip address and restart the server.

2. Go to jdeveloper 11g and disable the proxy settings there.
    Go to tools->Preferences->Web Browser and proxy and disable the use proxy http server

3. Exit and start the jdeveloper once again.


Error 3 :

Received HTTP response from the server, response code=500
Error deploying archive sca_HelloWorld_rev1.0.jar to soa_server1 [xxxx:yyyy]  
HTTP error code returned [500]
 Error message from server:


javax.servlet.ServletException: java.lang.OutOfMemoryError: Java heap space
 at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:333)
 at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
 at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
 at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:94)
 at java.security.AccessController.doPrivileged(Native Method)
 at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
 at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
 at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:138)
 at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:70)
 at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
 at oracle.dms.wls.DMSServletFilter.doFilter(DMSServletFilter.java:326)
 at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
 at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3592)
 at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
 at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
 at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2202)
 at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2108)
 at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1432)
 at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
 at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Caused by: java.lang.OutOfMemoryError: Java heap space


Solution :

The JVM Memory arguments are in the file " setDomainEnv.sh " in the folder $MW_HOME/user_projects/domains/<domain_name>/bin

You can open the file in any Text Editor and add the below line :-
     USER_MEM_ARGS="-Xms512m -Xmx1024m" (alter as per need)


Error 4 :

Preparing to send HTTP request for deployment
Creating HTTP connection to host:xxxx, port:yyyy
Sending internal deployment descriptor
Sending archive - sca_HelloWorld_rev1.0.jar
Received HTTP response from the server, response code=401
Problem in sending HTTP request to the server. Check standard HTTP response code for 401
Error deploying archive sca_HelloWorld_rev1.0.jar to soa_server1 [xxxx:yyyy]  
HTTP error code returned [401]
No error message is returned from the server.
####  Deployment incomplete.  ####
Error deploying archive file:/C:/JDeveloper/mywork/Sample/HelloWorld/deploy/sca_HelloWorld_rev1.0.jar 
 (oracle.tip.tools.ide.fabric.deploy.common.SOARemoteDeployer)

Solution :


HTTP 401 Unauthorized is similar to 403 Forbidden, but specifically for use when authentication is possible but has failed or not yet been provided. Double-check the weblogic username/password prompted during deployment from Jdeveloper.

Oracle Application Explorer : Could not initialize JCA Container

While trying to connect to the JCA config on application explorer you may hit the below error message

Error stack is as mentioned below :

com.iwaysoftware.iwrepository.RepositoryException
        at com.iwaysoftware.iwrepository.xml.XMLRepository.end(XMLRepository.java:272)
        at com.iwaysoftware.iwrepository.xml.file.FileRepository.end(FileRepository.java:436)
        at com.iwaysoftware.iwrepository.xml.XMLQuery.executeQuery(XMLQuery.java:863)
        at com.iwaysoftware.af.container.IWAFRepositoryOP.getConfigs(IWAFRepositoryOP.java:167)
       ....
       ....
To fix this error go to $SOA_HOME/soa/thirdparty/ApplicationAdapters/config/<config_name> , Take a backup of the st_repository.xml file and delete it. Now restart Application explorer and try connecting. The error should be gone .....

Tuesday, August 3, 2010

VisualGC: Performance Monitoring tool for Oracle SOA Suite

Oracle Fusion Middleware supports various performance monitoring tools for helping us debug performance issues with SOA Suite. Performance bottlenecks can happen at many places in an integration solution. It can either take place at DB level, or the BPEL/ESB code level or the JVM/Middleware level. Identifying these bottlenecks is a daunting task and often requires analysis from multiple aspects. 

VisualGC tool from Sun which comes with jvmstat 3.0 (for JDK 1.5.0 and higher) is an excellent tool for monitoring JVM memory usage. This tool helps in investigating issues where the applications tends to slow down after a while/sees degraded performance over a period of time.

Links for downloading and using this tool on Linux environments is provided below:

VisualGC download link
Description of the tool 
Installation instructions on Linux/Solaris

Once the tool has been installed you can use the below commands to run it and monitor the performance:

I have unzipped the jvmstat3.0 zip file at /opt/apps/Java/ on my linux server and using JDK6.

$ export JVMSTAT_HOME=/opt/apps/Java/jvmstat 
$ export JAVA_HOME=/opt/apps/Java/jdk1.6.0_18 
$ export PATH=$JVMSTAT_HOME/bin:$JAVA_HOME/bin:$PATH 

$ jps 
5755 Server 
2885 Jps 
5930 Server 

jps command gives you the JVM ids which are required as input parameter for the visualgc command.

$ visualgc 5755
As can be seen from the adjacent image, the memory usage of different parts of the JVM are shown graphically. The PermGen, OldGen and YoungGen (Eden Space, Survivor0 and Survivor1) usage can be monitored. When you observe a flat line in the Eden Space (right hand graph window) then its a cause of concern and indicates memory leaks/deadlock scenarios and requires immediate investigation.





There are other performance monitoring tools which can be used with Oracle SOA Suite. The EM Console in SOA 11G has a nice Summary screen which shows several important performance tracking statistics. For details on few of these tools please check the below link.
Overview of Performance Tuning Tools in Oracle Fusion Middleware

Weblogic domain creation error "Unable to invoke parse in InvokeStaticMethodTask"

While creating weblogic domain on linux server below error is encountered.

Steps:
export WLS_HOME=/opt/apps/Oracle/Middleware
export WLS_SERVER=/opt/apps/Oracle/Middleware/wlserver_10.3
export ORACLE_HOME=/opt/apps/Oracle/Middleware/Oracle_SOA1
export JAVA_HOME=/opt/apps/Java6/jdk1.6.0_20
export WLS_DOMAIN=/opt/apps/Oracle/Middleware/user_projects/domains
cd $ORACLE_HOME/common/bin
./config.sh




Here is the full stack trace of the error.

2010-08-02 09:56:28,142 ERROR [invokeStaticMethod] com.bea.plateng.wizard.silent.tasks.InvokeStaticMethodTask - Unable to invoke parse on class com.bea.plateng.plugin.PlugInExecutionPlanParser>
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.bea.plateng.wizard.silent.tasks.InvokeStaticMethodTask.execute(InvokeStaticMethodTask.java:304)
at com.bea.plateng.wizard.silent.tasks.AbstractSilentTask.run(AbstractSilentTask.java:28)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NullPointerException
at java.io.FileInputStream.<init>(FileInputStream.java:103)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at com.bea.plateng.plugin.PlugInExecutionPlanParser.parse(PlugInExecutionPlanParser.java:111)
at com.bea.plateng.plugin.PlugInExecutionPlanParser.parse(PlugInExecutionPlanParser.java:90)
... 7 more
2010-08-02 09:56:28,145 ERROR [invokeStaticMethod] com.bea.plateng.wizard.silent.tasks.InvokeStaticMethodTask - parameterValue 0 = <null>

The problem is the classpath for launching the configuration wizard.

/opt/apps/Oracle/Middleware/patch_wls1032/profiles/default/sys_manifest_classpat
h/weblogic_patch.jar:/opt/apps/Java6/jdk1.6.0_20/lib/tools.jar:/opt/apps/Oracle/
Middleware/utils/config/10.3.1.0/config-launch.jar
:.......

The source of this classpath entry is from $WLS_HOME/common/bin/commEnv.sh
The highlighted entry is invalid. It should point to 10.3 and not 10.3.1.0. Once this is changed the Configuration Wizard can be launched successfully for domain creation

Sunday, August 1, 2010

New updates to Oracle E-Business Suite Integrated SOA Gateway(ISG) with R12.1 ATG RUP3

Oracle has recently released the R12.1 ATG RUP3 patch which brings along with it many new features to the Integrated SOA Gateway(ISG) product. I had talked about ISG in one of my earlier posts soa-integrations-with-oracle-ebusiness. Its a nice product which allows system integrators to design solutions surrounding integrations with Oracle Ebusiness Suite using out-of-the-box features. Most of the updates coming along with this patch have been around enhanced administration capabilities for the product.


More details about the new added features can be found from below links:
New features overview
Enhanced logging in ISG
Enhanced Service Monitoring 
Securing WebServices with ISG

Wednesday, July 28, 2010

Dynamic PartnerLinks in BPEL

I recently came across a requirement where I had to integrate the SAP R/3 system with a 3rd party vendor using SOA 11g. The requirement simple...
  1. Schedule the BPEL to call the SAP BAPI
  2. Transform the results from BAPI and call the vendor web service. We do not have the target web service yet !

Wait...did it mention "do not have the target web service yet". My experience so far in BPEL was with static partner links where I was aware of the target WSDL location which I could use for the configuration. But here I didn't have that information available. Fortunately I was also provided another vital piece of information : an XML Schema (.xsd) which was the data model for the vendor WSDL. That helped me to go ahead and complete the integration.

I am sure many developers have come across similar scenarios where the end service(WSDL) we are going to call is unknown during design/development phase. So it becomes a challenge to provide an endpoint to the BPEL process or configure the partner links. And this is where dynamic partnerlinks come in handy. They use WS-Addressing feature of BPEL PM and enable us to pass values to the dynamic end points at runtime.


A very good example of this has been provided in the BPEL Cookbook on OTN ,where they have explained Dynamic PartnerLink usage in the Sample Loan Approval BPEL flow.


In this post I would like to highlight some key points while configuring dynamic partnerlinks in BPEL. The most important point to be remembered when using dynamic partnerlinks is that you need to ensure each process that you wish to call has to be based on exactly the same WSDL. The message types, namespaces, port types, bindings etc...everything have to be same just the endpoint url will be different.

If the above is taken care of then configuration wise things are simple :

a. First create the patnerlink with a template WSDL file.

b. Then add the following namespace to your bpel process
xmlns:wsa="http://schemas.xmlsoap.org/ws/2003/03/addressing"

c. Import the schema from above namespace URL to your project.

d. Based on this namespace, create an “EndpointReference” variable.

<variable name="partnerReference" element="wsa:EndpointReference"/>

e.Initialize the endpoint-reference by copying the following xml-fragment to the endpoint reference.

<EndpointReference xmlns="http://schemas.xmlsoap.org/ws/2003/03/addressing">
<Address/>
</EndpointReference>

f. You can use a bpel preference to store the end point URL so that at runtime this can be changed easily. Copy the determined endpoint url into the address node of the EndpointReference variable.

<copy>
<from expression='ora:getPreference("EndPointURL")'/>
<to variable="partnerReference" query="/wsa:EndpointReference/wsa:Address"/>
</copy>

g. Finally before invoking the partnerlink copy the Endpoint Reference to the partnerlink

<copy>
<from variable="partnerReference" query="/wsa:EndpointReference"/>
<to partnerLink="DummyService"/>
</copy>

Saturday, July 24, 2010

Oracle SOA Suite integration with Siebel

I will be shortly starting work on SOA Suite 11G integration with Siebel and was doing some initial study on the various ways to integrate with Siebel system.

  • For inbound integrations, Siebel CRM does support native webservices and exposes a number of functions as webservice end points (also know as Application Service Interfaces or ASIs). It provides tool for generating these WSDLs which can be consumed by SOA Suite components like BPEL.
  • For outbound integrations, we can use JMS and Oracle AQs. Basically Siebel publishes the message to JMS queue and a consumer picks up the message to process it onwards.

A couple of good reference posts from OTN are:

Will be sharing more details about Integration with Siebel systems in coming weeks...stay tuned.

Wednesday, July 21, 2010

SAP Adapter : JCO_ERROR_RESOURCE Connection pool is exhausted

I came across an interesting issue recently faced by one of my colleagues. He was trying to integrate between MSSQL server and SAP R/3 system using SOA 11G. He used to get a batch of order data from MSSQL server and had to post these to SAP BAPI and receive order number in response. Things were working fine as long as the batch size was small. But when he started getting batch size >1000, the SAP adapter started throwing errors.

Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation failed due to: JCA Binding Component connection issue. JCA Binding Component is unable to create an outbound JCA (CCI) connection. The JCA Binding Component was unable to establish an outbound JCA CCI connection due to the following issue: java.lang.IllegalStateException: Problem activating adapter. (java.lang.IllegalArgumentException: com.ibi.sap.SapAdapterException: com.sap.mw.jco.JCO$Exception: (106) JCO_ERROR_RESOURCE: Connection pool c22bbdb28dd27119d92c36c8ce75ad9e_p1 is exhausted. The current pool size limit (max connections) is 10 connections.). Check logs for more information ".

The default connection pool size for SAP adapter is 2 and this can be changed from the Application explorer. As can be seen above the connection pool size was increased to 10 but still this had failed. Basically when 10 concurrent threads are running and 11th thread tries to fetch the connection and unable to get it, that particular instance of BPEL fails with above error.

We tried a couple of things:

1. Tried controlling the number of records being polled from SQL server using distributed polling feature and controlling the number of records read per transaction. However incase of high load there were some BPEL instances which were still failing.

2. Second option tried was instead of directly connecting to the SAP R/3 system we tried connecting to a Load balancer infront of the SAP servers. This helped in distributing the load across SAP servers. For doing this configure the SAP target as shown below:



Fill the fields marked with *. Message Server is the load balancer name. Also note you need to edit the /etc/services file using root user and add below entry.
sapms<R/3 name> <port>/tcp

This ensured that the message server will share the load across SAP servers at runtime.








3. Incase the requirement is to control the concurrency on SAP side and allow only a single connection i.e prevent   parallel BPEL instances submitting concurrent requests to SAP R/3 we can create a Singleton BPEL process. More details on how to do this is well explained in Matt's Blog