Showing posts with label sca-deploy. Show all posts
Showing posts with label sca-deploy. Show all posts

Monday, 13 November 2017

SOA 12c : Deployment Error MDS-00039: error while attempting to parse the document .diagram.xml

If you are trying to deploy a recently changed service composite to Enterprise Manager and getting the below error:

Deploying on "/Domain/soa_domain/soa_server1" failed!
There was an error deploying the composite on soa_server1: oracle.mds.transfer.TransferException:
MDS-00001: exception in Metadata Services layer
oracle.mds.exception.MDSRuntimeException: MDS-00039: error while attempting to parse the document /deployed-composites/Test/TestBPEL_rev1.0/SCA-INF/TestBPEL.diagram.xml using SAX.
oracle.xml.parser.v2.XMLParseException; lineNumber: 1; columnNumber: 1; Start of root element expected.
MDS-00001: exception in Metadata Services layer:

Reason: The SCA-INF folder contents are stale.

Here is what you should do.

1. In JDeveloper navigate to your project, select it.
2. Under tab Build (Alt + B), select Clean project.jpr
3. Re-build your project/sar and deploy.

Helpful? Please Comment.

Happy Learning!!

Tuesday, 3 October 2017

ANT : java.lang.NoSuchMethodError: org/apache/xerces/impl/xpath/regex/RegularExpression.(Ljava/lang/String;Ljava/lang/String;Ljava/util/Locale;)V


This is what you should do if you are trying to deploy SOA code using ANT and facing the below issue:


[wldeploy] java.lang.NoSuchMethodError: org/apache/xerces/impl/xpath/regex/RegularExpression.<init>(Ljava/lang/String;Ljava/lang/String;Ljava/util/Locale;)V
[wldeploy]     at org.apache.xerces.impl.dv.xs.XSSimpleTypeDecl.applyFacets(Unknown Source)
[wldeploy]     at org.apache.xerces.impl.dv.xs.XSSimpleTypeDecl.applyFacets1(Unknown Source)
[wldeploy]     at org.apache.xerces.impl.dv.xs.BaseSchemaDVFactory.createBuiltInTypes(Unknown Source)
[wldeploy]     at org.apache.xerces.impl.dv.xs.SchemaDVFactoryImpl.createBuiltInTypes(Unknown Source)
[wldeploy]     at org.apache.xerces.impl.dv.xs.SchemaDVFactoryImpl.<clinit>(Unknown Source)


Solution-
Check your ANT jars are imported correctly and the ANT_HOME is set and retry.

Helpful? Please comment.

Happy Learning!!

Monday, 2 October 2017

ANT : Common adf-config.xml to deploy SOA composites to different environments.

When you are using ANT for SOA deployment, It will look for the .adf defined in the scac.application.home location that you have passed to the ant-sca-package file.
By default for ANT it is the \SCA-INF\classes folder under each project.

However, the common adf-config.xml file can be used to deploy all the composites instead of using the adf-config file from the individual composite applications.

By below approach, we can reduce the maintenance of individual adf-config files also by using the same adf-config file the composites can be deployed to different environments.

Steps:

1. Copy.adf folder from any of the composite application to the common location.
2. Change the contents of the adf-config.xml like below (change the file according to your requirement.)

<?xml version="1.0" encoding="windows-1252" ?>
<adf-config xmlns="http://xmlns.oracle.com/adf/config" xmlns:adf="http://xmlns.oracle.com/adf/config/properties"
            xmlns:sec="http://xmlns.oracle.com/adf/security/config">
  <sec:adf-security-child xmlns="http://xmlns.oracle.com/adf/security/config">
    <CredentialStoreContext credentialStoreClass="oracle.adf.share.security.providers.jps.CSFCredentialStore"
                            credentialStoreLocation="../../src/META-INF/jps-config.xml"/>
  </sec:adf-security-child>
  <adf-mds-config xmlns="http://xmlns.oracle.com/adf/mds/config">
    <mds-config xmlns="http://xmlns.oracle.com/mds/config">
      <persistence-config>
        <metadata-namespaces>
          <namespace path="/apps" metadata-store-usage="mstore-usage_1"/>
          <namespace path="/soa/shared" metadata-store-usage="mstore-usage_2"/>
        </metadata-namespaces>
        <metadata-store-usages>
          <metadata-store-usage id="mstore-usage_1">
           <metadata-store class-name="oracle.mds.persistence.stores.db.DBMetadataStore">
            <property
name="jdbc-userid" value="DEV_MDS"/>
            <property
name="jdbc-password" value="devmds"/>
            <property
name="jdbc-url" value="jdbc:oracle:thin:@//localhost:1521/XE"/>
            <property
name="partition-name" value="soa-infra"/>
           </metadata-store>
            </metadata-store-usage>
            <metadata-store-usage id="mstore-usage_2">
           <metadata-store class-name="oracle.mds.persistence.stores.db.DBMetadataStore">
            <property
name="jdbc-userid" value="DEV_MDS"/>
            <property
name="jdbc-password" value="devmds"/>
            <property
name="jdbc-url" value="jdbc:oracle:thin:@//localhost:1521/XE"/>
            <property name="partition-name"
value="soa-infra"/>
           </metadata-store>
          </metadata-store-usage>
        </metadata-store-usages>
      </persistence-config>
    </mds-config>
  </adf-mds-config>
</adf-config>



3. Set the scac.application.home to the common location in step1 path during the deployment of the composites.The common adf-config.xml file will be used to deploy all the composites.

We are using DB-based MDS here.
You can also use the File-based connection, but make sure to change the metadata-path to the physical path of the MDS folder.

Example:
<metadata-store-usage id="mstore-usage_2">
      <metadata-store class-name="oracle.mds.persistence.stores.file.FileMetadataStore">
      <property name="partition-name" value="seed"/>
      <property
name="metadata-path" value="E:/Oracle/Middleware/Oracle_Home/soa/integration"/>
      </metadata-store

</metadata-store-usage>


Helpful? Please Comment.

Happy Learning!!

Sunday, 1 October 2017

ANT : Building and Deploying SOA Composite Applications 11g/12c

Steps to setup and deploy SOA code to server using ANT.

Script Scope:
a. Deploys code to soa server [standalone/cluster]
b. Can be used for both 11g and 12c version of code.
c. Uses soa-config plan for deployment [please comment related code snippet if plan not required].
d. Creates a log file on date basis for basic logging.

Prerequisites:

a. Create folder ANT.
b. Inside create folders; config, lib, deploy, logs.

Steps:
1. Create file soa-build.properties like below [update paths as per your machine]

#Global
wls.bea.home=E:/Oracle/Middleware/Oracle_Home
wl_home=${wls.bea.home}/wlserver
oracle.home=${wls.bea.home}/jdeveloper
java.passed.home=C:/Program Files/Java/jdk1.8.0_131

#Temp
tmp.output.dir=deploy

#Delete the temp folder after the build
DeleteTemp=true

#Composite Setting
composite.enable=true

2. Create file soa-environment.properties like below [update values as per your server]

#Deployment server weblogic
dev.user=weblogic
dev.password=welcome1
dev.serverURL=http://localhost:7004
dev.server=localhost\
dev.port=7004
dev.overwrite=true
dev.forceDefault=true

3. Create file soa-project.properties like below [update values as per your requirement]

HelloWorldSOAApp.projects=HelloWorldProject1, HelloWorldProject2
HelloWorldSOAApp.src=E:/Code/HelloWorld
HelloWorldSOAApp.partition=default
HelloWorldProject1.version=1.0
HelloWorldProject1.deploy=true
HelloWorldProject2.version=1.0
HelloWorldProject2.deploy=true

4. Place all 3 property files inside config folder.

5. Copy your .adf folder from your project META-INF folder and paste inside config folder

Edit your adf-config.xml file. You can do either of 2 things:

a. Add a connection using DB-based MDS
b. Edit the File-based MDS variable to physical path where you MDS is located for apps and seed

6. Download ant-contrib-1.0b3.jar and place inside lib folder.
 
7. Create file build.xml like below

<?xml version="1.0" encoding="iso-8859-1"?>
<project name="soaDeployAll" default="help">
    <!--Global Default Task-->
    <echo>basedir ${basedir}</echo>
    <property name="application" value="${appName}"/>
   
    <!-- Antcontrib path -->
    <path id="antcontrib.path">
      <pathelement path="lib/ant-contrib-1.0b3.jar" />
    </path>
    <taskdef classpathref="antcontrib.path" resource="net/sf/antcontrib/antcontrib.properties"/>
    <taskdef classpathref="antcontrib.path" resource="net/sf/antcontrib/antlib.xml"/>


    <!-- help -->
    <target name="help">
    <echo>
    ##########################CreatedByNadimWarsi#######################
    ------------------------------------------------------
    |   Usable targets are:                             |
    ------------------------------------------------------   
    help                         - This help
    deployAll                - Packages and deploys all applications and their listed projects
    deployApp              - Packages and deploys one application and its listed projects
    deployAppProject   - Packages and deploys one project
   
    ------------------------------------------------------
    |   Usage example:                                  |
    ------------------------------------------------------
    echo $ANT_HOME
    echo $JAVA_HOME
   
    export ANT_HOME=/apps/FMW/oracle_common/modules/org.apache.ant_1.9.2
    export JAVA_HOME=/apps/java/jdk/jdk1.8.0_131
    
    ant -f help -Dtargetenv=dev
    ant -f deployAll -Dtargetenv=dev
    ant -f deployApp -Dtargetenv=dev -DappName=HelloWorldSOAApp
    ant -f deployAppProject -Dtargetenv=dev -DappName=HelloWorldSOAApp -Dprojects=HelloWorld1

   ############################################################

    </echo>
    </target>

    <!-- Check for an load property files -->
    <fail message="ERROR: Parameter 'targetenv' missing.">
        <condition>
          <not>
            <isset property="targetenv" />
          </not>
        </condition>
    </fail>
   
    <available file="config/soa-build.properties" property="file.exists" value="true" />
    <fail unless="file.exists" message="ERROR: Filename 'config/soa-build.properties' does not exist." />
    <property file="config/soa-build.properties"/>

    <available file="config/soa-project.properties" property="file.exists" value="true" />
    <fail unless="file.exists" message="ERROR: Filename 'config/soa-project.properties' does not exist." />
    <property file="config/soa-project.properties"/> 
   
    <available file="config/soa-environment.properties" property="file.exists" value="true" />
    <fail unless="file.exists" message="ERROR: Filename 'config/soa-environment.properties' does not exist." />
    <property file="config/soa-environment.properties"/> 


    <tstamp>
        <format property="log.date" pattern="ddMMyyy"/>
        <format property="log.time" pattern="dd-MM-yyy HH:mm:ss"/>
    </tstamp>    
    <echo file="logs/instance-${log.date}.log" append="true" message="${line.separator}${log.time}${line.separator}" level="info"/>


    <!-- Target Deployment -->
    <target name="deployAll">
        <echo file="logs/instance-${log.date}.log" append="true" message="Command: ant -f deployAll -Dtargetenv=${targetenv}${line.separator}" level="info"/>
        <antcall target="build.HelloWorldSOAApp"/>

    <echo file="logs/instance-${log.date}.log" append="true" message="##########################################################${line.separator}" level="info"/>
    </target>


    <!--Individual Targets for each SOA application-->
    <target name="build.HelloWorldSOAApp">
        <antcall target="deployAppProject">
            <param name="application" value="HelloWorldSOAApp"/>
            <param name="projects" value="${HelloWorldSOAApp.projects}"/>
        </antcall>
    </target>


    <!--Application Deployment-->
    <target name="deployApp">
    <echo file="logs/instance-${log.date}.log" append="true" message="Command: ant -f deployApp -Dtargetenv=${targetenv} -DappName=${application}${line.separator}" level="info"/>
    <propertycopy name="projects" from="${application}.projects"/>
        <antcall target="deployAppProject">
            <param name="application" value="${application}"/>
            <param name="projects" value="${projects}"/>
        </antcall>
    <echo file="logs/instance-${log.date}.log" append="true" message="##########################################################${line.separator}" level="info"/>
    </target>


    <!--Application Project Deployment-->
    <target name="deployAppProject">
    <echo file="logs/instance-${log.date}.log" append="true" message="Command: ant -f deployAppProject -Dtargetenv=${targetenv} -DappName=${application} -Dprojects=${projects}${line.separator}" level="info"/>
        <echo>Deploy application ${application}</echo>
        <echo>Project(s): ${projects}</echo>

        <foreach list="${projects}" param="project" target="deployProject" inheritall="true" inheritrefs="false"/>
    <echo file="logs/instance-${log.date}.log" append="true" message="##########################################################${line.separator}" level="info"/>
    </target>


    <!--Project Deployment-->
    <target name="deployProject">
         <trycatch property="tryName" reference="exception_ref">
          <try>
        <property name="proj.compositeName" value="${project}"/>
        <propertycopy name="proj.deploy" from="${proj.compositeName}.deploy"/>
        <if>
            <matches pattern="true|True|TRUE" string="${proj.deploy}"/>
                <then>
                        <echo>Deploying ${project}</echo>
                        <tstamp>
                            <format property="current.time" pattern="yyyyMMdd_HHmmss"/>
                            <format property="build.date" pattern="dd-MM-yyyy"/>
                        </tstamp>                       
                        <propertycopy name="src" from="${application}.src"/>
                        <echo>Copying application folder '${src}/${application}' to temp folder '${tmp.output.dir}/${application}/${current.time}'</echo>
                        <copy todir="${tmp.output.dir}/${application}/${current.time}">
                            <fileset dir="${src}/${application}"></fileset>
                        </copy>
                        <property name="proj.compositeDir" value="${tmp.output.dir}/${application}/${current.time}"/>
                        <propertycopy name="proj.revision" from="${proj.compositeName}.version"/>
                        <property name="proj.enabled" value="${enabled}"/>
                        <echo>Deploying compositeDir: ${proj.compositeDir}</echo>
                        <echo>Deploying compositeName: ${proj.compositeName}</echo>
                        <echo>Deploying version: ${proj.revision}</echo>
                        <echo>Environment: ${targetenv}</echo>
                        <echo>Build Date:  ${build.date}</echo>                       
                        <!--Checking if 11g or 12c code structure-->
                        <if>
                            <available file="${proj.compositeDir}/${proj.compositeName}/SOA" type="dir"/>
                            <then>

                                <property name="project.soa.dir" value="${proj.compositeDir}/${proj.compositeName}/SOA"/>
                            </then>
                            <else>
                                <property name="project.soa.dir" value="${proj.compositeDir}/${proj.compositeName}"/>
                            </else>
                        </if>

      <!--Loading common .adf config file for targetenv MDS in META-INF-->
                        <property name="adfdir" value="${basedir}/config"/>

                        <ant antfile="${oracle.home}/../soa/bin/ant-sca-package.xml" inheritAll="false" target="package">
                            <property name="compositeDir" value="${basedir}/${project.soa.dir}"/>
                            <property name="compositeName" value="${proj.compositeName}"/>
                            <property name="revision" value="${proj.revision}"/>
                            <property name="oracle.home" value="${oracle.home}"/>
                            <property name="java.passed.home" value="${java.passed.home}"/>
                            <property name="wl_home" value="${wl_home}"/>
                            <property name="sca.application.home" value="${basedir}/${proj.compositeDir}"/>
                            <property name="scac.application.home" value="${
adfdir}"/>
                            <property name="scac.input" value="${project.soa.dir}/composite.xml"/>
                            <property name="scac.output" value="${tmp.output.dir}/${proj.compositeName}.xml"/>
                            <property name="scac.error" value="${tmp.output.dir}/${proj.compositeName}.err"/>
                            <property name="scac.displayLevel" value="3"/>               
                        </ant>
                        <path id="cfgpln-file">
                            <fileset dir="${project.soa.dir}">
                                <include name="
${proj.compositeName}_cfgplan_${targetenv}.xml"/>
                            </fileset>
                        </path>
                        <property name="deploy.configplan" refid="cfgpln-file"/>
                        <property name="deploy.sarLocation" value="${project.soa.dir}/deploy/sca_${proj.compositeName}_rev${proj.revision}.jar"/>
                        <property name="deploy.sarLocation" value="${project.soa.dir}/deploy/sca_${proj.compositeName}_rev${proj.revision}.jar"/>
                        <propertycopy name="deploy.overwrite" from="${targetenv}.overwrite"/>
                        <propertycopy name="deploy.user" from="${targetenv}.user"/>
                        <propertycopy name="deploy.password" from="${targetenv}.password"/>
                        <propertycopy name="deploy.forceDefault" from="${targetenv}.forceDefault"/>
                        <propertycopy name="deploy.server" from="${targetenv}.server"/>
                        <propertycopy name="deploy.port" from="${targetenv}.port"/>
                        <propertycopy name="deploy.serverURL" from="${targetenv}.serverURL"/>
                        <propertycopy name="deploy.partition" from="${application}.partition"/>
                        <echo>Deploying to ${deploy.serverURL} with user ${deploy.user}</echo>
                        <echo>sarFile: ${deploy.sarLocation}</echo>
                        <echo>Deploying with configPlan is ${deploy.configplan}</echo>
                        <echo>Server: ${deploy.server}</echo>
                        <echo>Port: ${deploy.port}</echo>
                        <echo>Partition/Folder: ${deploy.partition}</echo>                   

                    <echo file="logs/instance-${log.date}.log" append="true" message="CompositeName: ${proj.compositeName}${line.separator}" level="info"/>
                    <echo file="logs/instance-${log.date}.log" append="true" message="Revision: ${proj.revision}${line.separator}" level="info"/>
                    <echo file="logs/instance-${log.date}.log" append="true" message="Partition: ${deploy.partition}${line.separator}" level="info"/>
                    <echo file="logs/instance-${log.date}.log" append="true" message="Deploy to ${deploy.serverURL} with user ${deploy.user}${line.separator}" level="info"/>
                    <echo file="logs/instance-${log.date}.log" append="true" message="Overwrite: ${deploy.overwrite}${line.separator}" level="info"/>
                    <echo file="logs/instance-${log.date}.log" append="true" message="forceDefault: ${deploy.forceDefault}${line.separator}" level="info"/>
                       
                        <ant antfile="${oracle.home}/../soa/bin/ant-sca-deploy.xml" inheritAll="false" target="deploy">
                            <property name="wl_home" value="${wl_home}"/>
                            <property
name="oracle.home" value="${oracle.home}"/>
                            <property
name="serverURL" value="${deploy.serverURL}"/>
                            <property
name="user" value="${deploy.user}"/>
                            <property
name="password" value="${deploy.password}"/>
                            <property
name="overwrite" value="${deploy.overwrite}"/>
                            <property
name="forceDefault" value="${deploy.forceDefault}"/>
                            <property
name="sarLocation" value="${deploy.sarLocation}"/>
                            <property
name="partition" value="${deploy.partition}"/>
                            <property
name="configplan" value="${deploy.configplan}"/>
                        </ant>
                        <echo>Disable or Enable composite set to: ${composite.enable}</echo>
                        <echo file="logs/instance-${log.date}.log" append="true" message="Composite enabled: ${composite.enable}${line.separator}" level="info"/>
                                <if>
                                    <equals arg1="${composite.enabled}" arg2="false"/>
                                    <then>
                                        <ant antfile="${oracle.home}/../soa/bin/ant-sca-mgmt.xml" inheritAll="false" target="stopComposite">
                                            <property name="host"
value="${deploy.server}"/>
                                            <property
name="port" value="${deploy.port}"/>
                                            <property
name="user" value="${deploy.user}"/>
                                            <property
name="password" value="${deploy.password}"/>
                                            <property
name="compositeName" value="${proj.compositeName}"/>
                                            <property
name="revision" value="${proj.revision}"/>
                                        </ant>
                                    </then>
                                </if>
                                <if>
                                    <equals arg1="${composite.enabled}" arg2="true"/>
                                    <then>
                                        <ant antfile="${oracle.home}/../soa/bin/ant-sca-mgmt.xml" inheritAll="false" target="activateComposite">
                                            <property
name="host" value="${deploy.server}"/>
                                            <property
name="port" value="${deploy.port}"/>
                                            <property
name="user" value="${deploy.user}"/>
                                            <property
name="password" value="${deploy.password}"/>
                                            <property
name="compositeName" value="${proj.compositeName}"/>
                                            <property
name="revision" value="${proj.revision}"/>
                                        </ant>
                                        <echo>Unit Test project ${proj.compositeName}</echo>
                                    </then>
                                </if>
                        <echo>${proj.compositeName}${proj.revision} deployment is complete.</echo>
                        <echo file="logs/instance-${log.date}.log" append="true" message="Command Execution Status: SUCCESSFUL${line.separator}${line.separator}" level="info"/>
                        <if>
                            <matches pattern="true" string="${DeleteTemp}"/>
                            <then>
                                <echo>Cleaning temp folder: ./${tmp.output.dir}</echo>
                                <delete includeemptydirs="true">
                                    <fileset dir="${tmp.output.dir}" includes="**/*"/>
                                </delete>
                            </then>
                        </if>               
                </then>
                <else>
                    <echo>${proj.compositeName} deployment is skipping, check the property ${proj.compositeName}.deploy is set to false.</echo>
                </else>
        </if>
    </try>
      <catch>
        <property name="exception" refid="exception_ref" />
        <property name="message" value="ERROR IN TRYCATCH BLOCK:${exception}" />
        <echo></echo>
        <echo>${message}</echo>
        <echo file="logs/instance-${log.date}.log" append="true" message="Command Execution Status: FAILED${line.separator}" level="info"/>
        <echo file="logs/instance-${log.date}.log" append="true" message="Error message: ${message}${line.separator}${line.separator}" level="info"/>
      </catch>
    </trycatch>
</target>   
</project>


8. Save All.
9. Open cmd/putty, and set ANT_HOME.
10. Execute command like ant -f deployAll -Dtargetenv=dev

Note:

a. Verify your path for all the ant sca xmls are correct.
b. Verify your adf-config.xml is correct.


Helpful? Please Comment.

Happy Learning!!




OSB 12c : Dynamic Routing to Business/Proxy Service

Dynamic routing is a kind of  Content-based Routing pattern, which is used when the BusinessService/ProxyService path is required to be de...