Thursday, December 11, 2014

Reference does not exist as wire target

This error normally comes when we try to comment out some existing references from composite.xml

Normally to disable a particular invocation we comment out the respective reference section in the composite.xml

But at the sametime we need to ensure that

In the composite.xml we comment out the import statement for that reference

Open the .componentType file and comment out the corresponding reference section there as well.

If there is a mismatch between composite.xml and .componentType file, the above error occurs

Monday, December 8, 2014

could not resolve xpath function "getServiceProperty", because missing xpath function meta-data


getServiceProperty method is one of the xpath functions available in aia.jar

If you are getting the above error during project compilation , it means the aia.jar is not attached to your project.

You may get the AIAServiceConstructor using the jdev updates and restart jdev  or explicitly attach aia,jar using the project preferences as shown below


Friday, December 5, 2014

Dynamic PartnerLink in BPEL 2.0

Often we may want to call the target endpoints dynamically. In such cases WS Addressing comes for our help.

In BPEL 1.1 we can assign the following snippet to the partner link and it will try to hit the endpoint mentioned in the snippet.

<wsa:EndpointReference xmlns:wsa="http://schemas.xmlsoap.org/ws/2003/03/addressing">
    <wsa:Address>http://localhost:8001/soa-infra/services/default/TargetService</wsa:Address>
</wsa:EndpointReference>

But in BPEL 2.0 the above approach was not working for me.

I have achieved the dynamic partner link requirement achieved in BPEL 2.0 as follows

Download the ws-bpel_serviceref.xsd  and add it to your project

Create a variable of element type service-ref , which is defined in the above xsd

<variable name="partnerlink-reference" element="sref:service-ref"/>






For the example purpose I am storing my target endpoint in a variable. (You may use DVM or AIAServiceConfigurationProperty file to store your target endpoint at real time.)

<copy>
        <from>'http://localhost:8001/soa-infra/services/default/TargetService'</from>
        <to>$TargetService</to>
      </copy>


Using append xml fragment option the following xml snippet to the above variable  partnerlink-reference

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

Now enrich the   partnerlink-reference xml with the actual endpoint you need
     <copy>
        <from>$TargetService</from>
        <to>$partnerlink-reference/wsa:EndpointReference/wsa:Address</to>
      </copy>

Finally copy partnerlink-reference variable  to the target partner link

 <copy>
        <from>$partnerlink-reference</from>
        <to partnerLink="TargetServicePartnerLink"/>
      </copy>

The entire Assign activity will look like as follows

<assign name="Assign1">
      <copy>
        <from>'http://localhost:8001/soa-infra/services/default/TargetService'</from>
        <to>$TargetService</to>
      </copy>
      <extensionAssignOperation>
        <bpelx:append>
          <bpelx:from><bpelx:literal><wsa:EndpointReference xmlns:wsa="http://schemas.xmlsoap.org/ws/2003/03/addressing">
    <wsa:Address/>
</wsa:EndpointReference></bpelx:literal></bpelx:from>
          <bpelx:to>$partnerlink-reference</bpelx:to>
        </bpelx:append>
      </extensionAssignOperation>
      <copy>
        <from>$TargetService</from>
        <to>$partnerlink-reference/wsa:EndpointReference/wsa:Address</to>
      </copy>
      <copy>
        <from>$partnerlink-reference</from>
        <to partnerLink="TargetServicePartnerLink"/>
      </copy>
    </assign>



Save and deploy your project. Test your flow, you can see your partnerlink's target address is changed to the one you updated from your BPELprocess



Tuesday, December 2, 2014

WS Security Error while trying to invoke a BPEL Component

In case of any WS Security error while trying to invoke a BPEL service, verify whether any security policies are attached to that service.

To override the security requirement you can attach the no-authentication policy to the reference exposed to the client . i.e client_ep



This can be done either from emconsole after deployment of the service or in jdev before deploying

Monday, November 24, 2014

Please make sure that the port attribute for the binding defined in the composite file is correct by checking the namespace service name and port name

There was an error deploying the composite Deployment Failed: Unable to find a WSDL that has a definition for service . Please make sure that the port attribute for the binding defined in the composite file is correct by checking the namespace service name and port name. In addition check that the WSDL associated with the binding namespace is imported and currently reachable (check the import nodes at the top of the composite file). Finally validate the HTTP proxy settings for the server..

This is a common error while deploying the composite from JDEV

One of the major reason for this error is due to invalid imports. Sometimes local MDS reference might have used during development time, but at deployment time it will be referring the target environment's MDS. In such cases ensure that your local MDS and target MDS are in sync.

Check all the import statements in the composite.xml. Ensure that each and every import statement is valid and the corresponding target resource is available.

Try to open the composite.xml in design view to see any wsdl loading errors happening.

Other reason could be because of the wrong config plan file used or
Wrong values for binding.ws port attribute in the composite.xml or
Wrong value for interface.wsdl interface in the composite.xml


If  there is a change in the reference/service/import sections in the composite.xml ensure you regenerate the config plan file.

Checking binding.ws port attribute in composite.xml
===============================
Follow the below rule to verify the correctness of binding.ws port attribute

<NAME_SPACE>#wsdl.endpoint(<SERVICE>/<PORT>)

For e.g

  <binding.ws port="http://xmlns.oracle.com/POCApplication/ApprovalService/ApprovalProcess#wsdl.endpoint(approvalprocess_client_ep/ApprovalProcess_pt)"/>

Where
Namespace is  - http://xmlns.oracle.com/POCApplication/ApprovalService/ApprovalProcess
Service is -  approvalprocess_client_ep
Port is -  ApprovalProcess_pt

Checking  interface.wsdl interface attribute in composite.xml
===============================
Follow the below rule to verify the correctness of  interface.wsdl interface port attribute

<NAME_SPACE>#wsdl.interface(<COMPONENTNAME>)

For e.g

http://xmlns.oracle.com/POCApplication/ApprovalService/ApprovalProcess#wsdl.interface(ApprovalProcess)

Where
namespace is - http://xmlns.oracle.com/POCApplication/ApprovalService/ApprovalProcess
component name is  - ApprovalProcess

Saturday, November 22, 2014

The process domain is encountering the following errors while loading the process : Validation of BPEL2.0 process failed.. This error contained an exception thrown by the underlying process loader module.


The process domain is encountering the following errors while loading the process : Validation of BPEL2.0 process failed..
This error contained an exception thrown by the underlying process loader module.
Check the exception trace in the log (with logging level set to debug mode). If there is a patch installed on the server, verify that the bpelcClasspath domain property includes the patch classes.

Even though our BPEL project is compiled in jdev, during deployment it can throw the above error.

From the error message we cant make out anything.


But one of the reasons for this compilation failure could be the java embedding used inside the BPEL process. If the java code refers some external classes and if that jar files are not set in the project in the SCA/lib folder this error can happen


To resolve the error at run time the same custom jar files must be made avaiable to the BPEL Process Manager at run time .

This can be achieved by following the below process

Navigate to Oracle_Home\soa\soa\modules\oracle.soa.ext_11.1.1 directory.

Copy your custom jar files under the classes directory

Open the command prompt and navigate to \Oracle_Home\soa\soa\modules\oracle.soa.ext_11.1.1

Run the ant command


\Oracle_Home\soa\soa\modules\oracle.soa.ext_11.1.1>ant
Buildfile: C:\installed\Oracle\Middleware12C\Oracle_Home\soa\soa\modules\oracle.
soa.ext_11.1.1\build.xml
  [taskdef] Could not load definitions from resource net/sf/antcontrib/antlib.xm
l. It could not be found.

create-manifest-jar:
   [delete] Deleting: \Oracle_Home\soa\soa\modu
les\oracle.soa.ext_11.1.1\oracle.soa.ext.jar
      [jar] Building MANIFEST-only jar: \Oracle
_Home\soa\soa\modules\oracle.soa.ext_11.1.1\oracle.soa.ext.jar

BUILD SUCCESSFUL
Total time: 0 seconds

Restart the Server

Importantly ensure that your .BPEL file uses the import statements for such referred classes

e.g

     <import location="oracle.xml.parser.v2.XMLElement" importType="http://schemas.oracle.com/bpel/extension/java"/>
  <import location="java.io.BufferedReader" importType="http://schemas.oracle.com/bpel/extension/java"/>
  <import location="java.io.ByteArrayOutputStream" importType="http://schemas.oracle.com/bpel/extension/java"/>
  <import location="java.io.InputStream" importType="http://schemas.oracle.com/bpel/extension/java"/>
  <import location="java.io.InputStreamReader" importType="http://schemas.oracle.com/bpel/extension/java"/>

After adding all  the  required import statements , redeploy the process

Wednesday, November 19, 2014

BINDING.JCA-11975 AQ_INVALID_QUEUE Unable to obtain queue table name


The invocation resulted in an error: Invoke JCA outbound service failed with connection error, exception: com.bea.wli.sb.transports.jca.JCATransportException: oracle.tip.adapter.sa.api.JCABindingException: oracle.tip.adapter.sa.impl.fw.ext.org.collaxa.thirdparty.apache.wsif.WSIFException: WSIF JCA Execute of operation 'Enqueue' failed due to: AQ_INVALID_QUEUE.
Unable to obtain queue table name.
Queue does not exist or not defined correctly.
; nested exception is:
BINDING.JCA-11975
AQ_INVALID_QUEUE.
Unable to obtain queue table name.
Queue does not exist or not defined correctly.
Drop and re-create queue.



This issue normally happens when the underlying schema changes.

For eg. while migrating AQAdapter from one ENV to another ENV normally only the following parameters might need to change

database name
hostname
port
service/sid

Usually we change these values in the datasource configuration in weblogic console

But in some situations if the target schema name is different than the one configured in the .jca file, this issue could happen

In such cases you may need to verify your .jca file and see the following property value reflect the correct schema name

<property name="DatabaseSchema" value="AQ_USER"/>

Redeploy the service after updating the jca file


How to rollback a patch for oracle soa suite

The simplest way of roll back a patch is :

opatch rollback -id <patch_number> 

Tuesday, November 11, 2014

Passing Custom Header from BPEL to OSB and vice versa

Sometimes we might have a requirement to pass some information via Header between BPEL and OSB.

In this post I am trying to explain one of the approaches possible to achieve that requirement

BPEL side
=========================

As a first step, create an xsd as shown below


=============Header.xsd==========================

<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns="http://xmlns.oracle.com/Custom/Header"
            targetNamespace="http://xmlns.oracle.com/Custom/Header"
            elementFormDefault="qualified">
  <xsd:element name="SessionHeader" type="SessionHeaderType"/>
  <xsd:complexType name="SessionHeaderType">
        <xsd:sequence>
            <xsd:element name="sessionToken" type="xsd:string"/>
            <xsd:element name="type" type="xsd:string"/>
        </xsd:sequence>
  </xsd:complexType>
</xsd:schema>

===================================================

Create two variables of type SessionHeader in the BPEL Process.

customHeader is to pass header values to the target service.

customHeaderIn is to receive the header values from a response received from target service.









On the invoke activity configure the input and output Header variables as follows


  <invoke name="InvokeTokenProcess" partnerLink="TokenProcess"
            portType="ns1:EmployeePortType" operation="GetEmployeeByEmpId" inputVariable="TokenProcess_IV"
            outputVariable="TokenProcess_OV" bpelx:invokeAsDetail="no" bpelx:inputHeaderVariable="customHeader" bpelx:outputHeaderVariable="customHeaderIn"/>


Use an assign activity before the invoke activity to set the required values in the customHeader variables

After invoke activity use another assign activity to retrieve the passed header- from target service on the customHeaderIn variable




OSB Side
=====================

 The passed custom Header can be retrieved in OSB pipeline as given below




 To send a custom header from OSB use the insert activity as given below



================
Deploy both BPEL and OSB service and do a test to see the header being passed correctly



Thursday, November 6, 2014

weblogic.jndi.internal.AdminModeAccessException

This issue happens mostly while doing lookup for ConnectionFactory,Queues,Topics etc

 One of the reason for this exception is that the managed servers stays at ADMIN mode rather than RUNNING mode.

In such cases ensure that the server state is RUNNING by debugging the issues seen on the logs while startup

Monday, November 3, 2014

Creating JMS Resources iteratively using Maven and WLST script in 12c

In the previous post we have seen how to create a JMSSserver and JMSModule using WLST.

To extent this script further, with multiple sets of JMSServer and JMSModules we can follow the below approach


Create jms.properties file for each set of configuration.

Please note use the convention as jms1, jms2,jms3 for the properties files

===========jms1.properties=================
domain.name=DefaultDomain
admin.url=t3://localhost:7101
admin.userName=weblogic
admin.password=weblogic1

jms.jmsserver=TEST_JMSSerer1
jms.jmssystemresource=TEST_JMSSystemResource1
jms.subdeployment=TEST_JMSSubdeployment1
jms.queue=TEST_JMSQUEUE1
jms.queue.jndi=jms/TEST_JMSQUEUE1
jms.topic=TEST_JMSTOPIC1
jms.topic.jndi=jms/TEST_JMSTOPIC1
jms.targetserver=DefaultServer

============end of properties================



===========jms2.properties=================

domain.name=DefaultDomain
admin.url=t3://localhost:7101
admin.userName=weblogic
admin.password=weblogic1

jms.jmsserver=TEST_JMSSerer2
jms.jmssystemresource=TEST_JMSSystemResource2
jms.subdeployment=TEST_JMSSubdeployment2
jms.queue=TEST_JMSQUEUE2
jms.queue.jndi=jms/TEST_JMSQUEUE2
jms.topic=TEST_JMSTOPIC2
jms.topic.jndi=jms/TEST_JMSTOPIC2
jms.targetserver=DefaultServer




============end of properties================

Save the following python script as jmsobjects.py

================start of python script============

 from java.io import FileInputStream

for i in 1,2:

  
    propInputStream = FileInputStream("path\\to\\jms"+str(i)+".properties")
    configProps = Properties()
    configProps.load(propInputStream)

    domainName=configProps.get("domain.name")
  
    adminURL=configProps.get("admin.url")
    adminUserName=configProps.get("admin.userName")
    adminPassword=configProps.get("admin.password")

    jms_server=configProps.get("jms.jmsserver")
    print 'jms_server : '+jms_server
    jms_systemResource=configProps.get("jms.jmssystemresource")
    print 'jms_systemResource : '+jms_systemResource
    jms_queue=configProps.get("jms.queue")
    print 'jms_queue : '+jms_queue
    jms_queue_jndi=configProps.get("jms.queue.jndi")
    print 'jms_queue_jndi : '+jms_queue_jndi
    jms_subdeployment=configProps.get("jms.subdeployment")
    print 'jms_subdeployment : '+jms_subdeployment
    jms_topic=configProps.get("jms.topic")
    print 'jms_topic : '+jms_topic
    jms_topic_jndi=configProps.get("jms.topic.jndi")
    print 'jms_topic_jndi :'+jms_topic_jndi
    jms_targetserver=configProps.get("jms.targetserver")
    print 'jms_targetserver : '+jms_targetserver


    #connect('weblogic','weblogic1', 't3://localhost:7101')
    connect(adminUserName, adminPassword, adminURL)

    # Creating a JMS Server

    edit()
    startEdit()
    cd('/')
    print 'Creating JMS Server.'
    cmo.createJMSServer(jms_server)
    cd('/JMSServers/'+jms_server)
    cmo.addTarget(getMBean('/Servers/'+jms_targetserver))
    activate()

    # Creating a Module

    startEdit()
    cd('/')
    cmo.createJMSSystemResource(jms_systemResource)
    cd('/JMSSystemResources/'+jms_systemResource)
    cmo.addTarget(getMBean('/Servers/'+jms_targetserver))
    cmo.createSubDeployment(jms_subdeployment)
    activate()

    # Creating Queue

    startEdit()
    print 'Creating Queue & Topic '
    cd('/')
    cd('/JMSSystemResources/'+jms_systemResource+'/JMSResource/'+jms_systemResource)
    cmo.createQueue(jms_queue)
    cd('/JMSSystemResources/'+jms_systemResource+'/JMSResource/'+jms_systemResource+'/Queues/'+jms_queue)
    set('JNDIName',jms_queue_jndi)
    set('SubDeploymentName',jms_subdeployment)
    cd('/JMSSystemResources/'+jms_systemResource+'/SubDeployments/'+jms_subdeployment)
    cmo.addTarget(getMBean('/JMSServers/'+jms_server))
    activate()

    # Creating Topic

    startEdit()
    cd('/')
    cd('/JMSSystemResources/'+jms_systemResource+'/JMSResource/'+jms_systemResource)
    cmo.createTopic(jms_topic)
    cd('/JMSSystemResources/'+jms_systemResource+'/JMSResource/'+jms_systemResource+'/Topics/'+jms_topic)
    set('JNDIName',jms_topic_jndi)
    set('SubDeploymentName',jms_subdeployment)
    cd('/JMSSystemResources/'+jms_systemResource+'/SubDeployments/'+jms_subdeployment)
    set('Targets',jarray.array([ObjectName('com.bea:Name='+jms_server+',Type=JMSServer')],ObjectName))
 
    
activate()
   

=================end of python script===========

Now open command prompt
Execute the following command after correcting the path as per your soa installation
mvn wls:wlst -DfileName=path/to/jmsobjects.py  - DmiddlewareHome=path/to/oraclehome 
-DdomainHome=path/to/domainhome

Creating JMS Resources using Maven and WLST in 12c


As a first step we need to install maven plugin wls-maven-plugin.

This plugin present in the ORACLE_HOME/wlserver_12.1/server/lib

Open a command prompt and navigate to the above location

Now we need to install this plugin to our repository( here by default the repository will be the local repository which is present at  c:/users/<username>/.m2  (for windows)).

To install the plugin use the following command


mvn install:install-file -Dfile=wls-maven-plugin.jar -DpomFile=pom.xml

Once the installation is successful we can verify whether the required goals are available using the following command

mvn com.oracle.weblogic:wls-maven-plugin:help

Here we can see the wlst task is available. 

Now we are ready to execute the WLST script using maven

Create a jms.properties file as shown below(change the values as per your requirement)
==================
domain.name=DefaultDomain
admin.url=t3://localhost:7101
admin.userName=weblogic
admin.password=weblogic1

jms.jmsserver=TEST_JMSSerer
jms.jmssystemresource=TEST_JMSSystemResource
jms.subdeployment=TEST_JMSSubdeployment
jms.queue=TEST_JMSQUEUE
jms.queue.jndi=jms/TEST_JMSQUEUE
jms.topic=TEST_JMSTOPIC
jms.topic.jndi=jms/TEST_JMSTOPIC
jms.targetserver=DefaultServer
============================================

Save the following python script as jmsobjects.py

note : remember to give the exact path to the jms.properties file)

========start of python script ==========

from java.io import FileInputStream

propInputStream = FileInputStream("path\\to\\jms.properties")
configProps = Properties()
configProps.load(propInputStream)

domainName=configProps.get("domain.name")
adminURL=configProps.get("admin.url")
adminUserName=configProps.get("admin.userName")
adminPassword=configProps.get("admin.password")

jms_server=configProps.get("jms.jmsserver")
jms_systemResource=configProps.get("jms.jmssystemresource")
jms_queue=configProps.get("jms.queue")
jms_queue_jndi=configProps.get("jms.queue.jndi")
jms_subdeployment=configProps.get("jms.subdeployment")
jms_topic=configProps.get("jms.topic")
jms_topic_jndi=configProps.get("jms.topic.jndi")
jms_targetserver=configProps.get("jms.targetserver")


#connect('weblogic','weblogic1', 't3://localhost:7101')
connect(adminUserName, adminPassword, adminURL)

# Creating a JMS Server

edit()
startEdit()
cd('/')
print 'Creating JMS Server.'
cmo.createJMSServer(jms_server)
cd('/JMSServers/'+jms_server)
cmo.addTarget(getMBean('/Servers/'+jms_targetserver))
activate()

# Creating a Module

startEdit()
cd('/')
cmo.createJMSSystemResource(jms_systemResource)
cd('/JMSSystemResources/'+jms_systemResource)
cmo.addTarget(getMBean('/Servers/'+jms_targetserver))
cmo.createSubDeployment(jms_subdeployment)
activate()

# Creating Queue

startEdit()
print 'Creating Queue & Topic '
cd('/')
cd('/JMSSystemResources/'+jms_systemResource+'/JMSResource/'+jms_systemResource)
cmo.createQueue(jms_queue)
cd('/JMSSystemResources/'+jms_systemResource+'/JMSResource/'+jms_systemResource+'/Queues/'+jms_queue)
set('JNDIName',jms_queue_jndi)
set('SubDeploymentName',jms_subdeployment)
cd('/JMSSystemResources/'+jms_systemResource+'/SubDeployments/'+jms_subdeployment)
cmo.addTarget(getMBean('/JMSServers/'+jms_server))
activate()

# Creating Topic

startEdit()
cd('/')
cd('/JMSSystemResources/'+jms_systemResource+'/JMSResource/'+jms_systemResource)
cmo.createTopic(jms_topic)
cd('/JMSSystemResources/'+jms_systemResource+'/JMSResource/'+jms_systemResource+'/Topics/'+jms_topic)
set('JNDIName',jms_topic_jndi)
set('SubDeploymentName',jms_subdeployment)
cd('/JMSSystemResources/'+jms_systemResource+'/SubDeployments/'+jms_subdeployment)
set('Targets',jarray.array([ObjectName('com.bea:Name='+jms_server+',Type=JMSServer')],ObjectName))

activate()

========================end of python script===============

Now open command prompt

Execute the following command after correcting the path as per your soa installation

mvn wls:wlst -DfileName=path/to/jmsobjects.py  - DmiddlewareHome=path/to/oraclehome 
-DdomainHome=path/to/domainhome 

No plugin found for prefix 'wls' in the current project

Even though the wls-maven-plugin is successfully installed, referring the goal via prefix might throw the above error.

mvn wls:wlst

Here wls is the prefix.

In such cases the following approach can be attempted

use the command in following format

mvn groupId:pluginname:goalname

For eg: To invoke the wlst goal on wls-maven-plugin use the following format

mvn com.oracle.weblogic:wls-maven-plugin:wlst


Sunday, November 2, 2014

Disabling logging and reporting globally in OSB 12c

The global disabling/enabling of logging,reporting etc can be performed from em console in 12c.

In 11g this can be done in service bus console

In 12c to  disable logging /reporting follow the below steps


1.       Logon to em console
2.       Under SOA select ServiceBus
3.       Right click on Service Bus which will open the properties as shown in the screenshot
4.       Go to Global Settings tab
5.       Uncheck logging option

6.       Apply the changes


The connection pool associated with it has already been destroyed

This error happens when WLS server invalidates the connections when we redeploy the adapter after adding a new JNDI . In such cases WLS server invalidates all the previous connection pool.

Though the connection pool JNDIs are visible at adapter configuration at run time it may fail with the error message "The connection pool associated with it has already been destroyed".

This seems to be a bug in weblogic

This mostly happens when we perform Adapter redeployment frequently.

To avoid this issue,

1.Delete all the existing connection pool JNDIs
2.Redeploy the Adatper
3.Restart your server
4.Add a new connection pool JNDI
5.Redeploy the Adapter

After this for any new JNDI added to the adapter ,ensure you only update the Adapter, not redeploy.



Thursday, October 30, 2014

Weblogic : Load balancer URL for a cluster

Sometimes in a clustered environment we would like to know whether load balancer is configured.

The easiest way to locate this is by logon to Weblogic Admin Console

Goto Envrioment->Clusters

Select your cluster

Open the HTTP tab

If load balancer is configured it will be available as Frontend Host



Weblogic : Creating Datasource using MAVEN and WLST Script

One of the interesting features of 12c is the option of using Maven for many of the administration tasks.

Maven along with WLST becomes the most convenient and powerful option to perform many of the administration tasks like creating domain,start and stop servers, listing deployed composites etc..

In this post I would like to introduce how maven plugin can be used to invoke a WLST script which creates a datasource in the weblogic domain.

As a first step we need to install maven plugin wls-maven-plugin.

This plugin present in the ORACLE_HOME/wlserver_12.1/server/lib

Open a command prompt and navigate to the above location

Now we need to install this plugin to our repository( here by default the repository will be the local repository which is present at  c:/users/<username>/.m2  (for windows)).

To install the plugin use the following command


mvn install:install-file -Dfile=wls-maven-plugin.jar -DpomFile=pom.xml

Once the installation is successful we can verify whether the required goals are available using the following command

mvn com.oracle.weblogic:wls-maven-plugin:help

Here we can see the wlst task is available. 

Now we are ready to execute the WLST script using maven

Create a datasource.properties file as shown below(change the values as per your requirement)
==================
domain.name=base_domain
admin.url=t3://localhost:7101
admin.userName=weblogic
admin.password=weblogic1

datasource.name=MyDataSource
datasource.database.name=XE
datasource.target=DefaultServer
datasource.filename=DS_One.xml
datasource.jndiname=DS_One_JNDI
datasource.driver.class=oracle.jdbc.xa.client.OracleXADataSource
datasource.url=jdbc:oracle:thin:@localhost:1521:XE
datasource.username=aq_user
datasource.password=aq_user

datasource.test.query=SQL SELECT * FROM DUAL
============================================

Save the following python script as datasource.py

note : remember to give the exact path to the datasource.properties file)

========start of python script ==========

from java.io import FileInputStream

propInputStream = FileInputStream("\\path\\to\\datasource.properties")
configProps = Properties()
configProps.load(propInputStream)

domainName=configProps.get("domain.name")
adminURL=configProps.get("admin.url")
adminUserName=configProps.get("admin.userName")
adminPassword=configProps.get("admin.password")

dsName=configProps.get("datasource.name")
dsFileName=configProps.get("datasource.filename")
dsDatabaseName=configProps.get("datasource.database.name")
datasourceTarget=configProps.get("datasource.target")
dsJNDIName=configProps.get("datasource.jndiname")
dsDriverName=configProps.get("datasource.driver.class")
dsURL=configProps.get("datasource.url")
dsUserName=configProps.get("datasource.username")
dsPassword=configProps.get("datasource.password")
dsTestQuery=configProps.get("datasource.test.query")

connect(adminUserName, adminPassword, adminURL)
edit()
startEdit()
cd('/')
cmo.createJDBCSystemResource(dsName)
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName)
cmo.setName(dsName)

cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDataSourceParams/' + dsName )
set('JNDINames',jarray.array([String('jdbc/' + dsName )], String))

cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDriverParams/' + dsName )
cmo.setUrl(dsURL)
cmo.setDriverName(dsDriverName)
cmo.setPassword(dsPassword)

cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCConnectionPoolParams/' + dsName )
cmo.setTestTableName(dsTestQuery)
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDriverParams/' + dsName + '/Properties/' + dsName )
cmo.createProperty('user')

cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDriverParams/' + dsName + '/Properties/' + dsName + '/Properties/user')
cmo.setValue(dsUserName)

cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDriverParams/' + dsName + '/Properties/' + dsName )
cmo.createProperty('databaseName')

cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDriverParams/' + dsName + '/Properties/' + dsName + '/Properties/databaseName')
cmo.setValue(dsDatabaseName)

cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDataSourceParams/' + dsName )
cmo.setGlobalTransactionsProtocol('OnePhaseCommit')

cd('/SystemResources/' + dsName )
set('Targets',jarray.array([ObjectName('com.bea:Name=' + datasourceTarget + ',Type=Server')], ObjectName))

save()
activate()

========================end of python script===============

Now open command prompt

Execute the following command after correcting the path as per your soa installation

mvn wls:wlst -DfileName=path/to/datasource.py  - DmiddlewareHome=path/to/oraclehome 
-DdomainHome=path/to/domainhome 

Once the script is executed successfully. Open the weblogic console and verify the datasource is created successfully

Monday, October 27, 2014

Namespace value in SOAPAction does not match Namespace value 'http://schemas.xmlsoap.org/soap/envelope/' in xml tag 'Body'

This issue normally comes when we use Service Callout.

Service Callout has an option to  configure Body or Payload

Payload means , it will be send as a child of Body.

If you pass your request which is already a SOAP Body as a payload,  and if you select Payload Document Option it will be like sending a SOAP Body inside SOAP Body. That might result the above error.

In such cases choose wisely which option you need to select while sending request via service callout

If your request itself is a SOAPBody choose the SOAP Body option. Otherwise choose the payload option


Tuesday, October 21, 2014

How to install a maven plugin to the central repository

If you want to install a plugin to the central repository like Archiva or Artifactory, follow the below steps

1) Download the plugin jar from
2) Extract the jar file and from the META_INF folder copy the path to POM file
3) Open the command prompt and navigate to the directory where the jar and POM file resides
4) Run the following command by replacing the jar file name and pom name

For eg. to install  properties-maven-plugin-1.0-alpha-2.jar to central repository

mvn deploy:deploy-file -DpomFile=<path_to>\properties-maven-plugin-1.0-alpha-2\META-INF\maven\org.codehaus.mojo\properties-maven
-plugin\pom.xml -Dfile=properties-maven-plugin-1.0-alpha-2.jar -Durl=http://localhost:8091/artifactory/internal -DrepositoryId=internal


Now to use this plugin along with your POM file add the following section  in the POM file under the plugin section

 <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>properties-maven-plugin</artifactId>
                <version>1.0-alpha-2</version>
                <executions>
                  <execution>
                    <phase>initialize</phase>
                    <goals>
                      <goal>read-project-properties</goal>
                    </goals>
                    <configuration>
                      <files>
                        <file>build-${deploy}.properties</file>
                      </files>
                    </configuration>
                  </execution>
                </executions>
              </plugin>

Thursday, October 9, 2014

12C OSB DVM usage :oracle.tip.dvm.exception.DVMValidationException: Unable to get Metadata Manager

When we use DVM in OSB 12c, during runtime there is a possibility to encounter a below as given below

weblogic.work.ExecuteThread.run(ExecuteThread.java:263) Caused by: oracle.tip.dvm.exception.DVMValidationException: Unable to get Metadata Manager for DVM "xxx.dvm" Please ensure the Metadata Manager is available. at oracle.tip.dvm.DVMManagerImpl.getDVMRTObject(DVMManagerImpl.java:223) at oracle.tip.dvm.DVMManagerImpl.lookupValue(DVMManagerImpl.java:88) at com.bea.wli.sb.functions.dvm.DVMFunctions.lookupValue(DVMFunctions.java:40) ... 78 more

This could be due to the fact that process is not able to locate the dvm file. If the DVM file is part of your project ensure you refer that in the dvm lookup fuction as given below

dvm:lookup('<projectname>/<relativepathToDVMfile>.dvm', 'PROPERTY_KEY', 'key', 'PROPERTY_VALUE', ' ')

Oracle Maven Sync Plugin Installation : Return code is: 401, ReasonPhrase: Unauthorized

While trying to install the maven-sync-plugin to a centralized repository like Archiva/Artifactory

sometimes an authorization error happens as follows

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:
deploy-file (default-cli) on project standalone-pom: Failed to deploy artifacts:
 Could not transfer artifact com.oracle.maven:oracle-maven-sync:jar:12.1.3-0-0 f
rom/to remote-repository (http://localhost:8091/artifactory/internal): Failed to
 transfer file: http://localhost:8091/artifactory/internal/com/oracle/maven/orac
le-maven-sync/12.1.3-0-0/oracle-maven-sync-12.1.3-0-0.jar. Return code is: 401,
ReasonPhrase: Unauthorized. -> [Help 1]

This can be resolved by doing the following steps

1) Create a new user called demouser in the Archiva/Artifactory
2) Give the permissions to the user to the desired repositories
3) encrypt the password using the command mvn -ep <password>

4)Use the encrypted password in the settings.xml, as shown below

<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <profiles>
    <profile>
      <id>default</id>
      <repositories>
        <repository>
          <id>internal</id>
          <name>internal</name>
          <url>http://localhost:8091/artifactory/internal</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
        <repository>
          <id>snapshot</id>
          <name>snapshot</name>
          <url>http://localhost:8091/artifactory/snapshot</url>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
          </snapshots>
        </repository>
      </repositories>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>default</activeProfile>
  </activeProfiles>
  <mirrors>
    <mirror>
      <id>mirror</id>
      <name>mirror</name>
      <url>http://localhost:8091/artifactory/repo1</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
  </mirrors>
  <servers>
    <server>
      <id>internal</id>
     <username>demouser</username>
   <password>{y2ZZOfE4lLkH78iLLX9xLQjL2/Rkoocq/Yq5HrACJdM=}</password>
   </server>
    <server>
      <id>snapshot</id>
     <username>demouser</username>
  <password>{y2ZZOfE4lLkH78iLLX9xLQjL2/Rkoocq/Yq5HrACJdM=}</password>
    </server>
  </servers>
</settings>

6)Also create a master password using mvn -emp <masterpassword>

7)Create a settings-security.xml with the encrypted master password as shown below
 Note: replace your master password inside the <master> tag

<settingsSecurity>
  <master>{nng7rwwwwKMHM+yJE3201WFQ1WlzYUfgoZGxW2mIcTc=}</master>
</settingsSecurity>

8)Place this  settings.xml and settings-security.xml  under <userhome>/.m2 directory

9) Now execute the install command as follows.

open the command prompt

Navigate to <ORACLE_HOME>\oracle_common\plugins\maven\com\oracle\maven\oracle-maven-sync\12.1.3

The execute the following command at the prompt :

mvn deploy:deploy-file -DpomFile=oracle-mave
n-sync-12.1.3.pom -Dfile=oracle-maven-sync-12.1.3.jar -Durl=http://localhost:8091/artifactory/internal -DrepositoryId=internal

Note : Ensure the  -DrepositoryId is spelled as given in the above command(case sensitive).  Don't use  -DRepositoryId

10)Once this command runs successfully, then execute the push goal as shown below

mvn com.oracle.maven:oracle-maven-sync:push
-DoracleHome=C:\installed\Oracle\Middleware12C\Oracle_Home  -DserverId=internal

This too will now run successfully and your repository will now have all the necessary artifacts installed .

11) To validate your installation run the following command. This will show all the availble goals which you can now use

mvn help:describe -DgroupId=com.oracle.soa.plugin -DartifactId=oracle-soa-plugin -Dversion=12.1.3-0-0

The result will be as follows
====================================
This plugin has 6 goals:

oracle-soa:compile
  Description: Compiles the composite. Note that 'compiling' a composite does
    not actually produce any new files, it is really a 'validation' and
    produces only output messages.

oracle-soa:deploy
  Description: To deploy a SOA composite (supports all formats SAR, MAR,
    etc.)

oracle-soa:help
  Description: Display help information on oracle-soa-plugin.
    Call mvn oracle-soa:help -Ddetail=true -Dgoal=<goal-name> to display
    parameter details.

oracle-soa:sar
  Description: Packages the composite into a SAR.

oracle-soa:test
  Description: To execute SCA Test Suites.

oracle-soa:undeploy
  Description: Undeploy a SOA composite from a SOA managed server or cluster

For more information, run 'mvn help:describe [...] -Ddetail'

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

Thursday, September 4, 2014

REST Service in 12C OSB and SOA

In this blog I would like to explain how to use the  REST Adapter from SOA as well as in OSB in the 12C Release of Oracle SOA Suite

In this exercise a REST service implemented in BPEL acts as provider and OSB will have a REST  client. Both will use the REST Adapter feature.

Step 1: Create an xml schema as follows(RestSchema.xsd)

<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:vrs="http://test.schemas/RESTSchema"
targetNamespace="http://test.schemas/RESTSchema" elementFormDefault="qualified">
<xsd:element name="request">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="message" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>

Step2: Create a SOA project in12C Jdev

Step 3: Open the projectname.xml(composite.xml) file  and add a REST Adapter to the exposed Service Section


Step4:  Choose the type as Service. From the operational bindings add Operation Binding

Step5:
In the request tab choose the payload type as XML, JSON or URL_Encoded. Choose the  request element from the RESTschema.xsd for the request type


Step6: In the response tab choose the payload type as XML or JSON. Choose the request element from the RESTSchema.xsd



Step7: Add a mediator and BPEL process and wire them as shown below

Step 8 : Configure the BPEL process as below




Step 9: Map the mediator as shown below
Step10 : Deploy the composite

Step 11: Now create new OSB Project. We can use the same schema in OSB service as well

Add the REST Binding to  External Services section

Step 12 :  Configure the REST Binding as follows. Select the payload type as XML/JSON. Select the request element from the RestSchema.xsd

Step13: On clicking OK it will create a business service as shown below


Step 14 : Deploy the OSB service and test  the business service using the osb test console


Monday, July 28, 2014

Get the thread dump for weblogic server from command prompt

Open the command prompt and type jps.
This will give the PID of the server.
>jps

Then type jstack <PID> on command prompt . This will give the thread dump
>jstack 3176

How to get garbage collection statistics

Get the ProcessID using jps command
Then execute the jstat command with the following option
-gccause
-h10  : number of lines
-<PID> : processID
-2000 : time interval


D:\>jstat -gccause -h10 3176 2000
  S0     S1     E      O      P     YGC     YGCT    FGC    FGCT     GCT    LGCC                 GCC
 27.88   0.00  32.55  24.67  47.10     16    1.074     0    0.000    1.074 unknown GCCause      No GC
 27.88   0.00  32.56  24.67  47.10     16    1.074     0    0.000    1.074 unknown GCCause      No GC
 27.88   0.00  32.56  24.67  47.10     16    1.074     0    0.000    1.074 unknown GCCause      No GC
 27.88   0.00  32.56  24.67  47.10     16    1.074     0    0.000    1.074 unknown GCCause      No GC
 27.88   0.00  32.56  24.67  47.10     16    1.074     0    0.000    1.074 unknown GCCause      No GC
 27.88   0.00  32.56  24.67  47.10     16    1.074     0    0.000    1.074 unknown GCCause      No GC
 27.88   0.00  32.56  24.67  47.10     16    1.074     0    0.000    1.074 unknown GCCause      No GC
 27.88   0.00  32.56  24.67  47.10     16    1.074     0    0.000    1.074 unknown GCCause      No GC


Where S0 and S1 are survivor spaces
 E is Eden space
 O Old Generation Size
 P Permanent generation
YGC Young Garbage Collection
YGCT Time taken for Young Garbage Collection
FGC FullGarbage Collection
FGCT Time taken for  FullGarbage Collection
GCT Total Garbage Collection Time

How to get the ProcessID of weblogic server in windows

Open the command prompt and type the command jps. This will give the process and their IDs as shown below. The ID corresponding to Server is the weblogic server processId


How to configure JMX Port for weblogic managed servers

There could be situations we need to set JMX Port on the managed servers to allow monitoring tools like VisualVM to connect to the managed server and get the server statistics.

 To configure the JMX port just add the following as the arguments for JVM in the setDomainEnv.sh or setDomainENV.cmd as shown below

-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8500 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djavax.management.builder.initial=weblogic.management.jmx.mbeanserver.WLSMBeanServerBuilder

Monday, June 16, 2014

Consumer is not getting listed for JMS Queue

Sometimes even though the JMS Queue and ConnectionFactory is existing in the JMS Module and the JMSAdpater Outbound connection pool JNDI  rightly points to the ConnectionFactory, still we may encounter issues like the consumer is not getting listed for the queue even after the BPEL consumer code deployed properly

In such cases follow this below rules


  • Check the persistent store is created and targeted to the SOA Managed Server
  • Check the JMS server is referring to the above persistent store and targeted to the SOA Managed Server
  • Ensure the JMS Module has a subdeployment , which is targetted to the above JMSServer
  • Ensure the ConnectionFactory/Queue/Topic has targettted to the above subdeployment
  • Finally ensure the queue is existing in the JNDI tree. (console->Environment->Servers->SOAManagedServer->JNDI tree Icon)


Only if the Queue/Topic/ConnectionFactory exist in the Managed Servers JNDI tree , the consumer component can connect to it

Saturday, March 1, 2014

this unique/primary key is referenced by some foreign keys

Sometimes while trying to drop the constraint we may encounter some issues as described below

SQL Error: ORA-02273: this unique/primary key is referenced by some foreign keys
02273. 00000 -  "this unique/primary key is referenced by some foreign keys"
*Cause:    Self-evident.
*Action:   Remove all references to the key before the key is to be dropped.

This issue can be fixed by adding the keyword 'CASCADE' at the end of the contraint drop statement

ALTER TABLE USER DROP CONSTRAINT USER_CON CASCADE;