Thursday, 31 March 2016

JDBC Data Source Configuration Step










Use full info about Weblogic

Use full info about Weblogic


WebLogic Server Instance
             
                A WebLogic Server instance is a Java Virtual Machine (JVM) process that runs the Java code. The instance is the actively working component, receiving client requests and sending them on to the appropriate components, and sending the processed requests back to the clients. Weblogic server instance is combination of admin server + manage server.

Administration Server

            A server is an instance of WebLogic Server that runs in its own JVM, and the Admin Server is a special instance of  WebLogic Server designed for managing the domain rather than running applications. There is a one-to-one relationship between domains and the Admin Server—an Admin Server belonging to Domain A can’t manage Domain B.
            You can deploy applications on the Admin Server, but unless you’re operating in a purely developmental environment, use the Admin Server strictly for performing management tasks, not for deploying any applications. Although you can deploy applications on the Admin Server in a development environment, it’s a best practice not to do so in a production environment

Managed Server

            Managed servers are the workhorses of WebLogic Server. Any additional servers you create after the creation of the default Admin Server are Managed Servers. The Managed Server contacts the Admin Server, only when you start it up, to get the configuration and deployment settings. For this reason, you should always start up the Admin Server before you start a Managed Server. Once a Managed Server starts running, it operates completely independent of the Admin Server.

WebLogic Server Cluster

            A WebLogic Server cluster is a group of WebLogic Server instances consisting of multiple Managed Servers that run simultaneously.

Machine
            A machine in the WebLogic Server context is the logical representation of the computer that hosts one or more WebLogic Server instances (servers).

Node Manager
            Node Managers help you remotely start, stop, suspend, and restart Managed Servers.

Services

Following are some of the main services used in a WebLogic environment:
■ JDBC (Java Database Connectivity) enables Java programs to handle database
connections established through connection pools.
JMS (Java Messaging Service) is a standard API that enables applications to communicate
through enterprise messaging systems.
JTA (Java Transaction API) specifies standard Java interfaces between transaction
managers and the parties in a distributed transaction system.


Development and Production Mode

            By default, WebLogic Server domains run in the development mode using the Sun Java Development Kit (JDK). In this mode, auto-deployment of applications is enabled and the Admin Server creates a boot.properties file automatically when you start it up. You can also use the demo certificates for Secure Sockets Layer (SSL) without any warnings from WebLogic Server. The development mode is provided to get developers up and running quickly without having to worry
about advanced deployment, configuration, or security issues.

In the production mode, WebLogic Server defaults to using JRockit as the default JDK. In addition, you can’t use the auto-deployment feature in production, and WebLogic Server issues warnings if you use the demo certificates for SSL. In the production mode, you’re also prompted for usernames and password when you start up the instances.
It’s easy to toggle between the development and production modes

EM Console or Admin Url Taking LongTime to load pages or Switch Pages

Action Plan for EM Console or Admin Url Taking LongTime to load pages or Switch Pages




Navigate to :DOMAIN_HOME/BIN

(Example:C:\Oracle\Middleware\user_projects\domains\base_domain\bin)

• Edit - for windows setDomainEnv.cmd  for linux setDomainEnv.cmd

•Search for the following string - set JAVA_OPTIONS=%JAVA_OPTIONS%
%JAVA_PROPERTIES% -Dwlw.iterativeDev=%iterativeDevFlag%
-Dwlw.testConsole=%testConsoleFlag%
-Dwlw.logErrorsToConsole=%logErrorsToConsoleFlag

• Append -DchangeSessionIdOnAuthentication=false to the string

-Dwlw.iterativeDev=%iterativeDevFlag%
-Dwlw.testConsole=%testConsoleFlag%
-Dwlw.logErrorsToConsole=%logErrorsToConsoleFlag%
-DchangeSessionIdOnAuthentication=false

• Restart all managed servers on this machine including the Admin server.

I have found an Oracle note that explain this issue.

BINDING.JCA-11622 : Remote JDBC disabled

Caused by java.lang.UnsupportedOperationException: Remote JDBC disabled



Caused by java.lang.UnsupportedOperationException: Remote JDBC disabled.
; nested exception is: BINDING.JCA-11622
Could not create/access the TopLink Session.

This session is used to connect to the datastore.


Above issue happening at OSB Calls 

Solution for this issue  is need to Enable Remote JDBC 

Shut Down OSB Managed Servers.

Please find below parameter  in setDomainEnv.sh and set it to true. It will be false by default

-Dweblogic.jdbc.remoteEnabled=true 

Merge Two Source Element based on a Common Key in XSLT

I had a requirement where I need to merge the contents of two files into a single file and there was a common key between the two schema.We start our process by polling into first file location based on follow schema,
image
Then using synchronous read I’m reading second file whose content is based on below schema,
image
Now after merging I want the content structured as below where CustomerId is common key between two files,
image
and we have to do this merge in xslt , here is the simple code to achieve this,
image
   <xsl:template match="/">
    <ns0:CustomerInfoFinal>
      <xsl:for-each select="/ns1:CustomerInfo1/ns1:Customer">
        <xsl:variable name="custID" select="ns1:CustomerId"/>
        <ns0:Customer>
          <ns0:CustomerId>
            <xsl:value-of select="ns1:CustomerId"/>
          </ns0:CustomerId>
          <ns0:Name>
            <xsl:value-of select="ns1:Name"/>
          </ns0:Name>
          <ns0:PAN>
            <xsl:value-of select="ns1:PAN"/>
          </ns0:PAN>
          <ns0:Address>
            <xsl:value-of select="$custDetails/ns2:CustomerInfo2/ns2:CustomerOtherInfo[(ns2:CustomerId = $custID)]/ns2:Address"/>
          </ns0:Address>
          <ns0:Age>
            <xsl:value-of select="$custDetails/ns2:CustomerInfo2/ns2:CustomerOtherInfo[(ns2:CustomerId = $custID)]/ns2:Age"/>
          </ns0:Age>
          <ns0:Gender>
            <xsl:value-of select="$custDetails/ns2:CustomerInfo2/ns2:CustomerOtherInfo[(ns2:CustomerId = $custID)]/ns2:Gender"/>
          </ns0:Gender>
        </ns0:Customer>
      </xsl:for-each>
    </ns0:CustomerInfoFinal>
  </xsl:template>

weblogic.ldap.EmbeddedLDAP.validateVDEDirectories

weblogic.ldap.EmbeddedLDAP.validateVDEDirectories

Error/Issue: AdminServer is shutting down with below error in log file

<Sep 9, 2014 1:14:25 AM PDT> <Critical> <WebLogicServer> <BEA-000386> <Server subsystem failed. Reason: java.lang.NumberFormatException: null
java.lang.NumberFormatException: null
        at java.lang.Integer.parseInt(Integer.java:417)
        at java.lang.Integer.parseInt(Integer.java:499)
        at weblogic.ldap.EmbeddedLDAP.validateVDEDirectories(EmbeddedLDAP.java:1104)
        at weblogic.ldap.EmbeddedLDAP.start(EmbeddedLDAP.java:242)
        at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
        Truncated. see log file for complete stacktrace
>
<Sep 9, 2014 1:14:25 AM PDT> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to FAILED>
<Sep 9, 2014 1:14:25 AM PDT> <Error> <WebLogicServer> <BEA-000383> <A critical service failed. The server will shut itself down>
<Sep 9, 2014 1:14:25 AM PDT> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to FORCE_SHUTTING_DOWN>



Solution:  Move data,cache,tmp under AdminServer directory and start AdminServer.

Or you can move ldap directory under data directory

Bottom line is LDAP was corrupted need to recreate.

class java.lang.NoClassDefFoundError : sun/awt/X11GraphicsEnvironment

"class java.lang.NoClassDefFoundError : sun/awt/X11GraphicsEnvironment"

"class java.lang.NoClassDefFoundError : sun/awt/X11GraphicsEnvironment"

While opening EM Console will see that error in AdminServer log file.

Issue: We can open EM Console but we cant expand soa_infra, not only soa_infra we cant open any thing in em console except tropology.
  

Solution:
Please include below parameter in startup parameters of adminserver.


-Djava.awt.headless=true

Wednesday, 9 March 2016

Search & Replace JDBC Data source in XSLT using ANT

Search & Replace JDBC Data source in XSLT using ANT

Hey everybody, today I come across a problem while deploying my code using ANT script.Each of my composite has its own deployment plan by which all the endpoint reference and jca properties getting changed to new environment.. but in the XSLT I’ve used couple of query database XPATH function and it use datasource as one of its input parameter.But I didn’t find any option in deployment plan to change the datasource as per my new environment.What if, we have a helper ant script that will search all the xsl files in a directory recursively and work in conjunction with main ant build script, definitely would be good. To get started I created a simple java class who will do the search and replacement job of all xslt files,
package com.shrik.utility;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class SearchAndReplaceXSLT {
    public static void main(String[] args) throws Exception {
        Properties properties=new Properties();
        properties.load(new FileInputStream("trx.properties"));
     
        File root = new File(properties.getProperty("FileRoot"));
     
        System.out.println(properties.getProperty("FileRoot"));
        String[] extensions = { properties.getProperty("FileExt") };
        boolean recursive = true;
        Collection files = FileUtils.listFiles(root, extensions, recursive);
        for (Iterator iterator = files.iterator(); iterator.hasNext(); ) {
            File file = (File)iterator.next();
            System.out.println("File = " + file.getAbsolutePath());
            SearchAndReplace(file,properties.getProperty("SearchStr"),properties.getProperty("ReplaceStr"));
        }
    }
   private static void SearchAndReplace(File file, String searchStr,
                                         String replaceStr) throws IOException {
        StringBuffer sb=new StringBuffer();
        Pattern pattern=Pattern.compile(searchStr);
        Matcher matcher=pattern.matcher(FileUtils.readFileToString(file));
        while(matcher.find()){
            matcher.appendReplacement(sb, replaceStr);
         
        }
        matcher.appendTail(sb);
        System.out.println(sb.toString());
        FileUtils.writeStringToFile(file,sb.toString() );
    }
}
and here is the corresponding trx.properties file,
FileRoot=C:/shrik/Oracle/SOAWork/composites/DeploymentFramework/test/trx
FileExt=xsl
SearchStr=DS_DEV_YYY&
ReplaceStr=DS_DEV_ZZZ&
build.dir=build
lib.dir=lib
main-class="com.shrik.utility.SearchAndReplaceXSLT"
Do fill up all the values based on your environment and root code repository directory.Just give a test run and check whether its doing your job or not.
Then create a jar file pointing your main class in manifest file.Here we have a dependency on org.apache.commons.io.FileUtils class so I created a folder lib and put the commons-io-1.3.2.jar file under that, here is my directory structure,
image
Under the build folder I created another directory jar , and under that I placed SearchAndReplaceXSLT.jar file.I created a trx folder where I copied all the xsl files, datasource need to be replaced.Now we need to refer the jar file from a ant script and for that I created build.xml file which contains,
<project name="SearchAndReplaceXSLT" basedir="." default="run">
<property file="trx.properties"/>
    <property name="jar.dir"     value="${build.dir}/jar"/>
    <property name="classes.dir" value="${build.dir}/classes"/>
     <path id="classpath">
        <fileset dir="${lib.dir}" includes="**/*.jar"/>
    </path>
 
    <target name="run" >
        <java fork="true" classname="${main-class}">
            <classpath>
                <path refid="classpath"/>
                <path location="${jar.dir}/${ant.project.name}.jar"/>
            </classpath>
        </java>
    </target>
</project>
Now just run ant and it will do the job .
So next part is how will I call this ant file from main build.xml in deployment script?
In main build.properties file I created a new property trx.amendment=true . Based on this value it will call the child script as below,
<target name="deployAll">
        <if>
          <equals arg1="${trx.amendment}" arg2="true"/>
          <then>
             <ant antfile="${env.CURRENT_FOLDER}/trx.xml" inheritAll="false" target="run"/>
          </then>
      </if>      
     
         <if>
          <equals arg1="${mds.enabled}" arg2="true"/>
          <then>
             <antcall target="deployMDS" inheritall="true"/>
          </then>
      </if>   
      <foreach list="${applications}" param="application" target="deployApplication" inheritall="true" inheritrefs="false"/>
    </target>
So with this you can easily change any data source name in sequence or database query function of your XSLT.

String to Date Conversion in XSLT

String to Date Conversion in XSLT

This blog might be handy for you for quick date conversion from string to date. Like in our source is String DD-MON-YYYY format and I want to convert it to YYYY-MM-DD for making the JCA adapter recognize the same during updation in oracle table.I didn’t find out any in built function is available so I decided to use simple sql query in xslt.
image
I just used query-database function and sql query is constructed using string concatenation.
image
and if you look at the database function ,
image
and whole sqlquery is concat("select to_char(to_date('",/ns0:arrivalDate,"','DD-MON-YYYY'),'YYYY-MM-DD') arrivalDate from dual")
handy for me as well for future reference.

Merge Two Source Element based on a Common Key in XSLT

Merge Two Source Element based on a Common Key in XSLT

I had a requirement where I need to merge the contents of two files into a single file and there was a common key between the two schema.We start our process by polling into first file location based on follow schema,
image
Then using synchronous read I’m reading second file whose content is based on below schema,
image
Now after merging I want the content structured as below where CustomerId is common key between two files,
image
and we have to do this merge in xslt , here is the simple code to achieve this,
image
   <xsl:template match="/">
    <ns0:CustomerInfoFinal>
      <xsl:for-each select="/ns1:CustomerInfo1/ns1:Customer">
        <xsl:variable name="custID" select="ns1:CustomerId"/>
        <ns0:Customer>
          <ns0:CustomerId>
            <xsl:value-of select="ns1:CustomerId"/>
          </ns0:CustomerId>
          <ns0:Name>
            <xsl:value-of select="ns1:Name"/>
          </ns0:Name>
          <ns0:PAN>
            <xsl:value-of select="ns1:PAN"/>
          </ns0:PAN>
          <ns0:Address>
            <xsl:value-of select="$custDetails/ns2:CustomerInfo2/ns2:CustomerOtherInfo[(ns2:CustomerId = $custID)]/ns2:Address"/>
          </ns0:Address>
          <ns0:Age>
            <xsl:value-of select="$custDetails/ns2:CustomerInfo2/ns2:CustomerOtherInfo[(ns2:CustomerId = $custID)]/ns2:Age"/>
          </ns0:Age>
          <ns0:Gender>
            <xsl:value-of select="$custDetails/ns2:CustomerInfo2/ns2:CustomerOtherInfo[(ns2:CustomerId = $custID)]/ns2:Gender"/>
          </ns0:Gender>
        </ns0:Customer>
      </xsl:for-each>
    </ns0:CustomerInfoFinal>
  </xsl:template>

OSB-BAM Integration Approach Part 2

OSB-BAM Integration Approach Part 2

In http://oraclesoasolution.blogspot.in/2016/03/osb-bam-integration-approach-part-1.html I explained how we can integrate BAM with OSB via BAM JCA Adapter.But there are other methods as well.In this blog I’ll explain how to leverage BAM Enterprise Message source for OSB Integration.
Before get started I’ll recommend to go through http://beatechnologies.wordpress.com/2011/05/20/integrating-oracle-bam-11g-with-bpel-jms-sensor-action/ blog which explains how to set up enterprise messaging source in BAM.I’ll extend that in my blog,so basically we need to enter data to JMS queue from OSB Business service.
Here are the steps of creating business service in OSB,
image
image
Now you have to provide endpoint URI for JMS, in my case soa.bam.cf connection factory and queue.bam.sensor queue are already created in admin server.
image
image
That’s all , we are now ready to test, just run business service,
image
Now go the metrics of messaging service,You will find 1 row committed to ADC.
image
Now you can prepare your custom report based on that data object.

OSB-BAM Integration Approach Part 1

OSB-BAM Integration Approach–Part 1

I’ll show you how to integrate Oracle BAM with Oracle service Bus in SOA 11.1.1.5.Here I’ll leverage Oracle BAM JCA adapter to create Business Service to populate data in BAM ADC table.
Here are the detailed steps to configure BAM and OSB,
You need to create one data object in BAM Architect, you can create your own table, for mine here is the screenshot,
image
Open Jdeveloper and create a BAM adapter on external reference swim lane which points to SalesOrder data object that you just created,
image
Then copy paste the following Jdeveloper artifacts to a folder of your OSB project,
image
Refresh the eclipse project and you can see all newly added components,
image
Create a business service out of .jca file, you need not to change anything there just save the generated .biz file.
image
Now create a sales order xsd file which will be input parameter of a proxy service,
<?xml version = '1.0' encoding = 'UTF-8'?>
<schema xmlns:xsd="
http://www.w3.org/2001/XMLSchema"
        xmlns:tns="http://shrikworld.blogspot.com/soa"
        xmlns="http://www.w3.org/2001/XMLSchema"
        attributeFormDefault="qualified" elementFormDefault="qualified"
        targetNamespace="
http://shrikworld.blogspot.com/soa">
  <annotation>
    <documentation>
      <info>/Order/SalesOrder</info>
    </documentation>
  </annotation>
  <element name="SalesOrderCollection">
    <complexType>
      <sequence>
        <element maxOccurs="unbounded" minOccurs="0" name="SalesOrder"
                 type="tns:SalesOrder"/>
      </sequence>
    </complexType>
  </element>
  <complexType name="SalesOrder">
    <sequence>
      <element minOccurs="0" name="OrderID">
        <annotation>
          <appinfo>
            <columnName xmlns="
http://xmlns.oracle.com/bam">SalesOrderID</columnName>
            <columnType xmlns="
http://xmlns.oracle.com/bam">string</columnType>
            <columnDescription xmlns="
http://xmlns.oracle.com/bam"/>
          </appinfo>
        </annotation>
        <simpleType>
          <restriction base="xsd:string">
            <maxLength value="100"/>
          </restriction>
        </simpleType>
      </element>
      <element minOccurs="0" name="OrderDate" type="xsd:dateTime">
        <annotation>
          <appinfo>
            <columnName xmlns="
http://xmlns.oracle.com/bam">OrderDate</columnName>
            <columnType xmlns="
http://xmlns.oracle.com/bam">datetime</columnType>
            <columnDescription xmlns="
http://xmlns.oracle.com/bam"/>
          </appinfo>
        </annotation>
      </element>
      <element minOccurs="0" name="CustomerNo">
        <annotation>
          <appinfo>
            <columnName xmlns="
http://xmlns.oracle.com/bam">CustomerID</columnName>
            <columnType xmlns="
http://xmlns.oracle.com/bam">string</columnType>
            <columnDescription xmlns="
http://xmlns.oracle.com/bam"/>
          </appinfo>
        </annotation>
        <simpleType>
          <restriction base="xsd:string">
            <maxLength value="100"/>
          </restriction>
        </simpleType>
      </element>
      <element minOccurs="0" name="Discount">
        <annotation>
          <appinfo>
            <columnName xmlns="
http://xmlns.oracle.com/bam">OrderDiscount</columnName>
            <columnType xmlns="
http://xmlns.oracle.com/bam">string</columnType>
            <columnDescription xmlns="
http://xmlns.oracle.com/bam"/>
          </appinfo>
        </annotation>
        <simpleType>
          <restriction base="xsd:string">
            <maxLength value="100"/>
          </restriction>
        </simpleType>
      </element>
      <element minOccurs="0" name="OrderTotal">
        <annotation>
          <appinfo>
            <columnName xmlns="
http://xmlns.oracle.com/bam">OrderTotal</columnName>
            <columnType xmlns="
http://xmlns.oracle.com/bam">string</columnType>
            <columnDescription xmlns="
http://xmlns.oracle.com/bam"/>
          </appinfo>
        </annotation>
        <simpleType>
          <restriction base="xsd:string">
            <maxLength value="100"/>
          </restriction>
        </simpleType>
      </element>
      <element minOccurs="0" name="OrderLines">
        <annotation>
          <appinfo>
            <columnName xmlns="
http://xmlns.oracle.com/bam">OrderLines</columnName>
            <columnType xmlns="
http://xmlns.oracle.com/bam">string</columnType>
            <columnDescription xmlns="
http://xmlns.oracle.com/bam"/>
          </appinfo>
        </annotation>
        <simpleType>
          <restriction base="xsd:string">
            <maxLength value="100"/>
          </restriction>
        </simpleType>
      </element>
      <element minOccurs="0" name="ShipDate" type="xsd:dateTime">
        <annotation>
          <appinfo>
            <columnName xmlns="
http://xmlns.oracle.com/bam">PromisedShipDate</columnName>
            <columnType xmlns="
http://xmlns.oracle.com/bam">datetime</columnType>
            <columnDescription xmlns="
http://xmlns.oracle.com/bam"/>
          </appinfo>
        </annotation>
      </element>
    </sequence>
  </complexType>
</schema>

Now create a proxy service of service type messaging service as below,In the request message type upload the sales order xml schema as created above.
image
image
Your message flow would be very simple and within the replace activity your custom sales order field will be transformed to business service specific sales order,
image
For that you need to create one xquery like
(:: pragma bea:global-element-parameter parameter="$salesOrderCollection1" element="ns1:SalesOrderCollection" location="../adapter/BAMAdapterTest/xsd/SalesOrder.xsd" ::)
(:: pragma bea:global-element-return element="ns0:_SalesOrderCollection" location="../adapter/BAMAdapterTest/xsd/SOAVMBAMConn_Order_SalesOrder.xsd" ::)

declare namespace ns1 = "http://shrikworld.blogspot.com/soa";
declare namespace ns0 = "http://xmlns.oracle.com/bam";
declare namespace xf = "http://tempuri.org/DBAdapterTest/xq/SOIn2BAM/";
declare function xf:SOIn2BAM($salesOrderCollection1 as element(ns1:SalesOrderCollection))
    as element(ns0:_SalesOrderCollection) {
        <ns0:_SalesOrderCollection>
            {
                for $SalesOrder in $salesOrderCollection1/ns1:SalesOrder
                return
                    <ns0:_SalesOrder>
                        {
                            for $OrderID in $SalesOrder/ns1:OrderID
                            return
                                <ns0:_SalesOrderID>{ data($OrderID) }</ns0:_SalesOrderID>
                        }
                        {
                            for $OrderDate in $SalesOrder/ns1:OrderDate
                            return
                                <ns0:_OrderDate>{ data($OrderDate) }</ns0:_OrderDate>
                        }
                        {
                            for $CustomerNo in $SalesOrder/ns1:CustomerNo
                            return
                                <ns0:_CustomerID>{ data($CustomerNo) }</ns0:_CustomerID>
                        }
                        {
                            for $Discount in $SalesOrder/ns1:Discount
                            return
                                <ns0:_OrderDiscount>{ data($Discount) }</ns0:_OrderDiscount>
                        }
                        {
                            for $OrderTotal in $SalesOrder/ns1:OrderTotal
                            return
                                <ns0:_OrderTotal>{ data($OrderTotal) }</ns0:_OrderTotal>
                        }
                        {
                            for $OrderLines in $SalesOrder/ns1:OrderLines
                            return
                                <ns0:_OrderLines>{ data($OrderLines) }</ns0:_OrderLines>
                        }
                        {
                            for $ShipDate in $SalesOrder/ns1:ShipDate
                            return
                                <ns0:_PromisedShipDate>{ data($ShipDate) }</ns0:_PromisedShipDate>
                        }
                    </ns0:_SalesOrder>
            }
        </ns0:_SalesOrderCollection>
};

declare variable $salesOrderCollection1 as element(ns1:SalesOrderCollection) external;
xf:SOIn2BAM($salesOrderCollection1)
Don’t worry you need not to write any code, there is a visual editor for that,
image
Design the message flow and in the replace activity add the below properties,
image
image
That’s all now we are ready to test , I assumed that you added the required value in BAM Adapter and updated the same,
image
Now run the proxy service and give some value, the data should be inserted into SalesOrder object,
image
Now create BAM report as per your need based on SalesOrder data object .So we can publish data to BAM from OSB via BAM adapter.