Wednesday, May 18, 2016

SOA DBAdapter error Cannot call Connection.commit in distributed transaction

Error message could look like
Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'EbsCreateAccountProcedureDb' failed due to: DBWriteInteractionSpec Execute Failed Exception.
unknown failed. Descriptor name: [unknown].
Caused by java.sql.SQLException: Cannot call Connection.commit in distributed transaction.  Transaction Manager will commit the resource manager when the distributed transaction is committed..
Please see the logs for the full DBAdapter logging output prior to this exception.  This exception is considered retriable, likely due to a communication failure.  To classify it as non-retriable instead add property nonRetriableErrorCodes with value "0" to your deployment descriptor (i.e. weblogic-ra.xml).  To auto retry a retriable fault set these composite.xml properties for this invoke: jca.retry.interval, jca.retry.count, and jca.retry.backoff.  All properties are integers.
".
The invoked JCA adapter raised a resource exception.

Please examine the above error message carefully to determine a resolution.

The Solution could be, your Datasource might have been configured to support global transactions.  Uncheck the "Support Global Transactions" check box in your data source connection pool.

Note: After doing the modification, server need to be bounced.

Wednesday, May 11, 2016

ORA-01861: literal does not match format string (SOA Date time formatting error)

Error:
Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'ReadQuotesFromStagingDbSelect' failed due to: DBReadInteractionSpec Execute Failed Exception. Query name: [ReadQuotesFromStagingDbSelect], Descriptor name: [ReadQuotesFromStagingDb.XxlscQuoteIntHeaderTbl]. Caused by java.sql.SQLDataException: ORA-01861: literal does not match format string . See root exception for the specific exception. This exception is considered not retriable, likely due to a modelling mistake. To classify it as retriable instead add property nonRetriableErrorCodes with value "-1861" to your deployment descriptor (i.e. weblogic-ra.xml). To auto retry a retriable fault set these composite.xml properties for this invoke: jca.retry.interval, jca.retry.count, and jca.retry.backoff. All properties are integers. ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution.

Use Case:
If we want to get the latest records that are updated recently, we use the condition that the LASTUPDATED_DATE greater than or equal to the input date time parameter say afterDate.

Now the afterDate field is added as the input parameter to the DB adapter call, and the afterDate is always a String.  

If we are not passing the input date time in the default format (say DD-MON-YYYY), then we get the above mentioned biding error of ORA-01861: literal does not match format string

Solution:  The solution is to send the input dateTime in a proper format and then use the same format in the DB Adapter Query.  Means converting string to oracle date format.

1. Take a  dateTime type field as input parameter in the BPEL process.

2. Use the format  "[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01]"  in the XSLT  and convert to a      formatted string.    
Ex:     

3. User the TO_DATE function in the query that is called from the DBAdapter and user the format  string as   'YYYY-MM-DD"T"HH24:MI:SS'

                                Ex:   TO_DATE('2011-07-28T23:54:14', 'YYYY-MM-DD"T"HH24:MI:SS')


Wednesday, April 13, 2016

ORABPEL-05250 Error - Few possible solutions

If you see the below error while deploying the SOA composite into the SOA11g server

Deploying on partition "default" of "/Farm_soa_prod/soa_prod/soa_server1" ...
Deploying on "/Farm_soa_prod/soa_prod/soa_server1" failed!
There was an error deploying the composite on soa_server1: Deployment Failed: Error occurred during deployment of component: GTM_CLM_Process_ScreeningResults to service engine: implementation.bpel for composite: GTM_CLM_Process_ScreeningResults: ORABPEL-05250

Error deploying BPEL suitcase.
error while attempting to deploy the BPEL component file "/netapp01/fmwprodbin/Oracle/Middleware/user_projects/domains/soa_prod/servers/soa_server1/dc/soa_dbc0254e-8aa1-4d20-9cef-457b9f5fa15c"; the exception reported is: java.lang.Exception: BPEL 1.1 compilation failed

This error contained an exception thrown by the underlying deployment module.
Verify the exception trace in the log (with logging level set to debug mode).

There might be few reasons, but look at the last changes you made and try to think.

Here are few what we have faced and found the resolutions. It may help you as well.

Resolution1:  This issue is coming while using the cloud service.  Need to find solution.   The reason is, one of the custom field is not available in the targeted (here OSC service for us) web service WSDL, so while compiling with configuration file it used to fail.


Resolution2:  Using Java Embedded Activity is causing the error with java classed used.  For example the Class name using directly as  InetAddress   without using the package name.  So the solution was to use the complete package name as  java.net.InetAddress;

Friday, April 1, 2016

How to get SOA host server DVM file path to refer dynamically from that SOA server MDS

When we develop a BPEL process, most of the time it will connect different external (target) systems.  Some times we need to use the DVMs for getting the values dynamically.  So we create a DVM in the SOA server and load the DVM values file into the MDS database.  Now the BPEL process has to use the SOA host dynamically to identify the DVM file path from the MDS.

So to identify the SOA server host name dynamically we can follow the below steps.


1. Create a DVM  TestDVM.dvm with two columns, OrganizationId, OrganizationIdValue.

TestDVM.dvm
=============
OrganizationId    |    OrganizationIdValue
---------------------------------------------------
host1                              abc123
host2                              def234

2. Create a string variable HostName in BPEL process
3. Inside the BPEL process use a Java Embedding activity and write the below code init.

                   String HostName = null;  
                    try{                                                                        
                          InetAddress addr = InetAddress.getLocalHost();  
                          HostName = addr.getHostName();  
                          addAuditTrailEntry("Host name is " + HostName);  
                          setVariableData("HostName",HostName);  
                    } catch (Exception ex) {                                                                  
                          ex.printStackTrace();  
                        addAuditTrailEntry(ex.getMessage());  
                    }

Now the value is available in the BPEL string variable.

4. If we need to use this value in the XSL files then pass the BPEL variable as input element to the XSL file.

Inside the XSL file use the DVM function to get the value.
dvm:lookupValue("TestDVM.dvm","OrganizationId",$HostName,"OrganizationIdValue",$HostName).


Tuesday, March 8, 2016

Calling HTTPS REST API from JAVA using HTTPClient and Jersey

Apache HTTP Client
==================
import java.io.File;

import java.net.URI;

import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.auth.BasicScheme;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.EntityUtils;


public class JavaHttpsRestCall {
  public static void main(String[] args) throws Exception {
    //Optional if the certificate is in the right truststore
    String keystorePath = "lib/DevDemoTrust.jks";
    File keyStoreFile = new File(keystorePath);
    System.setProperty("javax.net.ssl.trustStore",    keyStoreFile.getAbsolutePath());

    CredentialsProvider provider = new BasicCredentialsProvider();
    UsernamePasswordCredentials credentials =   new UsernamePasswordCredentials("khaleel", "pwd123");
 
    CloseableHttpClient httpclient = HttpClients.createDefault();
 
    try {
          URI uri =  new URIBuilder().setScheme("https").setHost("devlattice.bigmachines.com")
              .setPath("/rest/v1/commerceDocumentsOraclecpqoTransaction")
              .setParameter("q","{'lastPricedDate_t': {$gt: '2015-10-27T12:30:00'}}")
              .setParameter("expand","transactionLine")
              .setParameter("limit","5")
              .setParameter("offset","0")
              .setParameter("totalResults","true").build();
     
        HttpGet httpget = new HttpGet(uri);
          httpget.addHeader(new BasicScheme().authenticate(credentials, httpget, null));
          //httpget.addHeader("accept", "application/json");
          //httpget.addHeader("Content-Type", "application/json");
     
      System.out.println("Executing request " + httpget.getRequestLine());
      CloseableHttpResponse response = httpclient.execute(httpget);
      try {
        System.out.println("----------------------------------------");
        System.out.println(response.getStatusLine());
        System.out.println(EntityUtils.toString(response.getEntity()));
        System.out.println("----------------------------------------");
      } finally {
        response.close();
      }
    } finally {
      httpclient.close();
    }

  }
}

Apache Jersey
=================
import sun.misc.BASE64Encoder;

import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import org.apache.http.client.utils.URIBuilder;

import java.io.File;

import java.net.URI;

import org.apache.http.client.utils.URIBuilder;

public class JerseyClient {

  public static void main(String[] a) throws Exception {

    String keystorePath = "lib/DevDemoTrust.jks";
    File keyStoreFile = new File(keystorePath);
    System.setProperty("javax.net.ssl.trustStore",
                       keyStoreFile.getAbsolutePath());
   
    String url =     "https://devkk.bigmachines.com/rest/v1/commerceDocumentsOraclecpqoTransaction?expand=transactionLine&q=%7B+%27lastPricedDate_t%27%3A+%7B%24gt%3A+%272015-10-27T12%3A30%3A00%27%7D%7D&limit=10&offset=0&totalResults=true";

    URI uri =  new URIBuilder().setScheme("https").setHost("devlattice.bigmachines.com")
      .setPath("/rest/v1/commerceDocumentsOraclecpqoTransaction")
      .setParameter("q","{'lastPricedDate_t': {$gt: '2015-10-27T12:30:00'}}")
      .setParameter("expand","transactionLine")
      .setParameter("limit","100")
      .setParameter("offset","0")
      .setParameter("totalResults","true").build();

    String name = "kshaik";
    String password = "pwd123";
    String authString = name + ":" + password;
    String authStringEnc = new BASE64Encoder().encode(authString.getBytes());
    System.out.println("Base64 encoded auth string: " + authStringEnc);
    Client restClient = Client.create();
    WebResource webResource = restClient.resource(url);
    ClientResponse resp =
      webResource.accept("application/json").header("Authorization",
                                                    "Basic " + authStringEnc).get(ClientResponse.class);
    if (resp.getStatus() != 200) {
      System.err.println("Unable to connect to the server");
    }
    String output = resp.getEntity(String.class);
    System.out.println("response: " + output);
  }
}