Showing posts with label BPM. Show all posts
Showing posts with label BPM. Show all posts

Wednesday, June 8, 2016

Weblogic 12c: start and stop script for starting weblogic admin and managed server

As in my previous blog post I share the concept of starting and stopping nodemanager. In this blog post I am going to show you how you can start and stop weblogic admin server and managed server using admin server connection.

Start scripts for admin server and managed server

Well the basic logic to start admin and managed server is as:

  • Start the admin server using ./startWeblogic.sh script stored at the domain directory.
  • check for the admin server status is running or not by using same way as did for nodemanager in this post. But here we check for the string "RUNNING"
  • After admin started we invoke to start all the managed server cluster (all the server in a cluster will automatically start).
Here is the script:


rm -rf  *_Server.out AdminServer.out

tfile="AdminServer.out"

cd $DOMAIN_HOME
nohup ./startWebLogic.sh > AdminServer.out &

AdminStatus="STOP"

while [ "$AdminStatus" = "STOP" ]; do
                echo $tfile

                count=$(cat $tfile | grep "RUNNING" | wc -l)

echo "The value of count is ${count}"

                if [[ "$count" -gt 0 ]]; then
                        echo "AdminServer Started..."
AdminStatus="RUNNING"
nohup $WEBLOGIC_HOME/common/bin/wlst.sh startOSB.sh > OSB_Server.out &
                        nohup $WEBLOGIC_HOME/common/bin/wlst.sh startSOA.sh > SOA_Server.out &
                        nohup $WEBLOGIC_HOME/common/bin/wlst.sh startWSM.sh > WSM_Server.out &

                        rm -f $tfile
                        exit 0
                else
                    echo "Waiting For AdminServer To Start..."
                        
                fi
        sleep 5s
        done


echo "Please check ${tfile} log file for more issues"
exit 1 

In the above scripts I am calling three more scripts which are used to start the managed server cluster.

startOSB.sh

Content of the script is as follow:

connect('weblogic', 'welcome1', 't3://adminhostname:port')

start('bpm_osb_cluster','Cluster')

disconnect()

startSOA.sh

Content of the script is as follow:

connect('weblogic', 'Oracle123', 't3://adminhostname:port')

start('bpm_soa_cluster','Cluster')

disconnect()

startWSM.sh

Content of the script is as follow:

connect('weblogic', 'Oracle123', 't3://adminhostname:port')

start('bpm_wsm_cluster','Cluster')

disconnect()

Note: you can start the server instead of start cluster, refer this documentation 

Stop scripts for admin and managed server

For stopping managed server scripts first connect to the nodemanager and use the nmkill() method to kill the managed server

nmConnect('weblogic', 'Oracle123', 'prdbpmn01.ebsafrica.com', '5556', 'BPMDomain', '/u02/oracle/config/domains/BPMDomain','ssl')

nmKill('wls_wsm1')
nmKill('wls_osb1')
nmKill('wls_soa1')

nmDisconnect()

exit()

so you have to kill each server because there is no such method available to stop the cluster.

After that stop the admin server using this script.

nohup sh /u01/oracle/config/domains/BPMDomain/bin/stopWebLogic.sh &

Weblogic 12c: start and stop script for nodemanager

Recently I was working on the automated script to start and stop the nodemanager, AdminServer and all managed server (ESS, SOA, OSB, WSM) in a domain. So in this post I am going to share my work, it may be possible that these scripts may not be suited for your environment but yes It must give you a basic idea of how to start and stop nodemanager automatically.

Start scripts for nodemanager

Well the basic logic that I used to start the nodemanager is

  • check if nodemanager is running or not
  • start the nodemanager and take the output in a temporary file.
  • while the nodemanager is starting keep looking for the string "socket listener started on port" in a temporary file. 
  • if the matching string is found that means node manager is started and exit().
rm -rf nodemanage.*

tfile="nodemanage.$$.out"
status= ps -eaf | grep "weblogic.NodeManager" | grep -v grep| wc -l
date=date
echo $status
echo "Node Manager Directory: " $1

if [[ "$status" -eq 0 ]]; then
echo  $date " :Starting Weblogic NodeManager..."
echo $1
nohup $1 > $tfile 2>&1 &

else
echo  $date " :NodeManager is already RUNNING.."
fi

if [ "$?" != 0 ]; then
echo "Command Failed To Execute Properly"
exit 1;
fi

export a=0;
while [ $a -lt 10 ]; do
echo $tfile

count=$(cat $tfile | grep "socket listener started on port" | wc -l)

echo "The value of count is ${count}"                 

if [[ "$count" -gt 0 ]]; then
echo "NodeManager Started..."
rm -f $tfile
exit 0
else
echo "Waiting For NodeManager To Start..."
echo $a
((a++))
fi
sleep 5s
done
echo "Please check ${tfile} log file for more issues"
exit 1

Save the above script in .sh file e.g. startNode.sh. Now to run this script you have to pass the location of the nodemanager i.e.

nohup ./StartNode.sh $DOMAIN_HOME/bin/startNodeManager.sh > nodemanage.out &


Stop script for nodemanager

To stop the nodemanager find the process id of nodemanager instance and kill that process id, here is the script below:

node1=$(ps -ef | grep weblogic.nodemanager | grep config=/u01 | awk '{printf $2}')

kill -9 $node1

Save the above code in the .sh file e.g. stopNode.sh and execute the script as below:

nohup sh StopNode.sh &


In the next post I am going to share the start and stop script for weblogic AdminServer and Managed server.

Wednesday, May 11, 2016

Deployment Failed: XML-24500: (Error) Can not build schema 'http://www.springframework.org/schema/util' located at 'http://www.springframework.org/schema/util/spring-util.xsd'.

Today I was deploying soa composite for oracle enterprise repository on soa server and getting the following exception:

Deploying on partition "default" of "/Domain_base_domain/base_domain/AdminServer" ...
Deploying on "/Domain_base_domain/base_domain/AdminServer" failed!
There was an error deploying the composite on AdminServer: Deployment Failed: Error occurred during deployment of component: TimedEventClass to service engine: implementation.spring for composite: OERWorkflows: SCA Engine deployment failure.: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 10 in XML document from URL [oramds:/deployed-composites/default/OERWorkflows_rev1.0/TimedEventClass.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 834; <Line 10 Column 834>: XML-24500: (Error) Can not build schema 'http://www.springframework.org/schema/tool' located at 'http://www.springframework.org/schema/tool/spring-tool-2.5.xsd'.


Cause

This problem comes in oracle product version 12.1.3.0.0 and on windows-7 64 bit system. It occurs due to the parameter -Doracle.xml.schema\Ignore_Duplicate_components=true has back slash in setDomainEnv.cmd file.

Solution

  1. Go to <DOMAIN_HOME>/bin/setDomainEnv.cmd
  2. Change -Doracle.xml.schema\Ignore_Duplicate_components=true to -Doracle.xml.schema/Ignore_Duplicate_components=true i.e. change back slash to forward slash.
  3. Restart the server.
Reference: check the oracle support document Doc ID 2092104.1

Thursday, March 17, 2016

Oracle BPM 12c: how to change PAM repository path in oracle bpm

By default BPM tries to create a repository under the following path:

Oracle_Home\user_projects\domains\fmw_domain\bpm\bac\AdminServer\repositories

The following steps need to be performed to change the repository path
  • Login to 12c EM console.
  • Right click on soa-infra and go to Administration--> System MBean Browser.
  • Now click on the search icon and do an Attribute search for RespositotyPatch attribute.
  • The search results display a page showing the  BacNode MBean.
  • One can change the repository path by editing the RepositoryPath attribute on the BacNode Bean.

Oracle API Gateway: Configure Outbound one way ssl from OAG

In my previous post Oracle API Gateway: Configure Inbound one way ssl in OAG I showed you how to enable one way ssl in oracle application gateway for the inbound communication. In this blog post I am going to configure one way ssl certificate for outbound communication for example suppose you want to call a http service which is secured by SSL certificates.

Note: I don't have the ssl service so that I can show as an example but I will list down all the basic steps require to configure outbound ssl communication

Steps to configure outbound one way SSL in OAG:
  • Extract the Public Key cert
  • Import Certificate in OAG
  • Create Policy for SSL outbound connection in OAG
  • Create HTTP listener to consume this policy

Extract the Public Key cert
  • Go to Command Prompt or Putty --> run the command openssl s_client -connect HOSTNAME:PORT
  • The Key is printed on the screen, copy the key and save it to the file e.g. testcert.cer
Import Certificate in OAG
  • Go to Certificates and Keys --> certificates tab --> click on create/import
  • Click import to import the finacle certificate created above, and give some alias name e.g. testcert.cer

Create Policy for SSL outbound connection in OAG
  • Go to Policies --> Create container "Outbound" --> Add Policy "SSL"
  • Drag and drop Connect to URL filter, configure as below
  • Go to SSL Tab --> and select the finacle cert you have imported before like below
  • Click OK and Finish wizard
Create HTTP listener to consume this policy
  • Go to Listerners --> Oracle API Gateway --> Default Services --> Paths --> Add new Relative path and use the policy created above
  • Click OK and deploy all the configurations.

Known Issues:


Issue:

hostname verification error

Solution

Hostname verification should be disable. If the issue persist try to make machine hostname and CN name in the certificate same.

Oracle API Gateway: Configure Inbound one way ssl in OAG

In production environment generally ssl interface is enable for safe and secure communication. In this blog post I am going to show you how to enable one way ssl interface in oracle api gateway.

Steps to enable SSL in OAG

  • Generate SSL certificate
  • Import Certificate in OAG
  • Configure Https Interface in OAG

Generate SSL certificate

You need openssl to create ssl certificate. you can download the openssl from here : https://www.openssl.org/source/

Please follow below blog post to configure ssl certificate

http://www.codeconfuse.com/2016/01/how-to-generate-ssl-certificate-using.html

Import Certificate in OAG
  • Go to Certificates and Keys --> certificates tab --> click on create/import
  • Click import to import the CA certificate, and give some alias name e.g. IA Cert
  • Import the private key as well if key is provided separately otherwise it is automatically imported in step 2


Configure Https Interface in OAG
  • Go to Listeners --> Oracle API Gateway --> Default Services --> Ports --> Add new Https interface and configure as below
  • Don't forget to select the x.509 certificate that you have imported above.
  • Go to Advance SSL tab and uncheck the box shown below

  • Click ok and finish the wizard
Now HTTPS interface is enabled, and you can use it on any path.

Wednesday, March 16, 2016

Oracle API Gateway: Enable embedded JMS in OAG

I was working on one of the requirement in which we have to communicate third party application using JMS queues. We are using oracle application gateway as a inbound/outbound interface so all the communication done through OAG, so in this case we are using JMS configured on oracle application gateway. Well in this blog post I am not going to describe my usecase but I will describe the basic step required to enable JMS in oracle application gateway (OAG).

Scenario:

I am going to enable jms in OAG first. I will create two queues incoming and outgoing. OSB application put the data on to incoming queue then jms listener in oag listen this incoming queue and put the data on outgoing queue. Well I am just showing here how to create a api gateway policy for jms communication so I am not going to tell how to configure your osb application to put the data on incoming (I hope you all know how to configure that).

Steps require to enable JMS in OAG:

  • Enable Embedded Active MQ on OAG
  • Create JMS Service External Connection in OAG
  • Create Queue in OAG Embedded Active MQ
  • Create OAG outgoing policy
  • Create JMS listener in OAG
  • Configure Embedded Active MQ jms connection on osb server
  • Test application


Enable Embedded Active MQ on OAG
  • Open policystudio --> go to server setting --> Messaging --> Embedded Active MQ -> configure as below

  • Check the box Enable Embedded Active MQ Broker
  • Active MQ connection details.
    • Address - localhost
    • Port: 62626
    • username: weblogic
    • password: welcome1
  • Apply changes.

Create JMS Service External Connection in OAG

  • Expand External Connection --> JMS Service --> Add a JMS Service 
  • JMS service Connection Details
    • Name: Embedded OAG JMS Service
    • Provider url : tcp://localhost:62626
    • Initial Context Factory : org.apache.activemq.jndi.ActiveMQInitialContextFactory
    • Connection Factory : QueueConnectionFactory
    • Username : weblogic
    • Password : welcome1

  •   Click Ok. Deploy your configurations.
Create Queue in OAG Embedded Active MQ
  • open url : https://localhost:8090 in browser
  • Go to Messaging --> Queues --> Actions --> Create Queue
  • create two queues i.e. InQueue and OutQueue.


Create OAG outgoing policy
  • Under policies --> create a policy container name "JMS Policies"
  • Create policy i.e. "OAG Outgoing"
  • Drag and drop messaging system from the Routing menu (from right panel)
  • Configure as below:
  • Click Ok to create a policy.
Create JMS listener in OAG
  • In the left panel under Listeners --> right click on Oracle API Gateway --> Messaging --> JMS Session, select the jms session you have created before

  • Add JMS consumer inside this JMS listener.

  • Click ok and deploy.

Configure Embedded Active MQ jms connection on osb server

This step is not require if you are not using osb application to test, you can configure other applicatoin to put the data on the incoming queue so that OAG Policy will work. Well my configurations is like below: 


Test the application

Now test your application and check if you are getting the messages in outgoing queue as below : 







Oracle API Gateway: Binary file issue in file upload filter in OAG 12.1.2.3.0

I was working on the oracle api gateway policy and using the file upload filter to upload the file onto the  ftp server. But I was unable to upload the correct file i.e. whenever the binary file uploaded to the server it gets corrupted

Solution:

As recommended by oracle that you should apply the patch SP4 and its working fine then.

the patch number is 22805555

Oracle API Gateway: Role based authorization using oracle XE database

Role based authorization enables you to restrict service access to authorized users based on their assigned roles or groups. In this blog post I am going to show you how authorization could be achieved in oracle api gateway without using any ldap server but using oracle xe database for storing the roles or groups and requested URI.

Scenario:

Suppose we have four services as follows
  • http://www.codeconfuse.com/search/label/12c
  • http://www.codeconfuse.com/search/label/SOA
  • http://www.codeconfuse.com/search/label/OSB
  • http://www.codeconfuse.com/search/label/weblogic
now we want to authorize these service based on roles or groups.

Steps to enable authorization in OAG:
  • Create users in OAG
  • Create Groups in OAG
  • Create table in database
  • Create database connection in OAG
  • Create a Group Authorization policy
  • Create Role Based Policies in OAG
  • Create Http Listener in OAG
  • Test the service in browser

Create Users in OAG

Lets create 5 user to demonstrate the role based authorization. Five user needed because 4 user for each services and 1 user is authorize to access all the service
  • Open Policystudio -> left navigation expand users and groups -> select users -> Add new user name that user user12c and password as welcome1

  • Similarly create 4 other user with name usersoa, userosb, userweblogic and useradmin with password as welcome1


Create Groups in OAG

 we create four groups for example

Critical - can access 12c service url
High - can access SOA service url
Medium - can access OSB service url
Low - can access weblogic service url

  • Go to groups tab -> add new group name as Low and assign user userweblogic and useradmin to this group

  • Simlarly create 3 more groups with name as Critical, High and Medium
    • Assign user usersoa and useradmin to group High
    • Assign user userosb and useradmin to group Medium
    • Assign user user12c and useradmin to group Critical

Create table in database

  • Open Sqlplus -> create a table name URI with two columns Groups and URL

  • Insert the following data into the table URI
    • insert into URI value ('Critical','/12c');
    • insert into URI value ('High','/soa');
    • insert into URI value ('Medium','/osb');
    • insert into URI value ('Low','/weblogic');
    • Commit ;

Create database connection in OAG

  • Go to External Connection --> Database connection --> Add a database connection

  • Click Ok and finish the wizard
Create a Group Authorization policy

This policy is common policy which authorize user to access the service based on roles and groups

  • Go to Policies --> Add policy --> give name Group Authorization policy
  • Drag and drop HTTP Basic filter, configure as below 
  • set http basic as set as start
  • Drag and drop Retrieve from or write to database, configure as below

SELECT * FROM uri where url = ${http.request.path}
  • Go to Advance tab. and configure as below
  • Click OK.
  • Drag and Drop Scripting Language, configure as below 

Here what is happening is the db query executed in the previous step retuns the a groups and url, this data stored in the user attribute list as groups and url and it can be access as user.groups or user.url. After extracting the value of groups then it passed to userGroup attribute which is use in the next step to check the group membership. The code snippet is below:

function invoke(msg)         {           

java.lang.System.out.println("Message is " + msg.get("attribute.lookup.list"));
var userGroup = msg.get("user.groups");

java.lang.System.out.println("user group is " + userGroup );

msg.put("user.group", userGroup );

return true;       

 }
  • Drag and drop Check Group Memebership, configure as below 
  • Finally connect all the filters and it looks like below



Create Role Based Policies in OAG

This policy is created for each service URI and it reuse the Group Authorization Policy created above and finally connect to the url.

  • Add container in Policies and name Role Based Policies
  • Create 4 Policies
    • 12c Policy
    • SOA Policy
    • OSB Policy
    • Weblogic Policy

  • one by one configure each policies. Open Google policy --> drag and drop policy shortcut and select the Group Authorization Policy
  • Drag and drop Connect to URL filter and configure as below
  • Finally connect all the filter and it looks like below

  • Similarly configure for other policies.


Create Http Listener in OAG

  • Go to Listeners --> Oracle API Gateway --> Default Services --> Paths --> Click Add and select Relative Path, configure as below

  • Click OK
  • Similarly create for other 3 service url's
Test the service in browser

Now if your api gateway is configure with http port as 8080, so to access the above services from the api gateway is
  • http://localhost:8080/12c
  • http://localhost:8080/soa
  • http://localhost:8080/osb
  • http://localhost:8080/weblogic

Run the above url and it will prompt for the username and password. Pass the username and password you have created above and check the authorization is working or not.

Sunday, January 31, 2016

Oracle API Gateway : Getting started with FTPS server

In this blog post I going demonstrate how to create a FTPS server inside the Oracle API Gateway (OAG).

Below are the steps required to create FTPS server:

  • Generate SSL certificate for ftps server
  • Configure SSL certificate in OAG
  • Create ftps Incoming file policy
  • Create Password Authentication Policy
  • Create User in OAG
  • Configure ftps server in OAG
  • Test and verify ftps connection using client

Generate SSL certificate for ftps server

You need openssl to create ssl certificate. you can download the openssl from here : https://www.openssl.org/source/

Please follow below blog post to configure ssl certificate

http://www.codeconfuse.com/2016/01/how-to-generate-ssl-certificate-using.html

Configure SSL certificate in OAG

  • Open policy studio --> Go to Certificates and Keys --> Certificates --> Click on Create/Import



  • Import the certificate that you have created above, click on import certificate



  • Go to Private Key tab and import the private key

  • Click Ok and finish the certificate import wizard.

Create FTPS incoming file policy

This policy is used to handle the incoming file coming from the ftps client and this is required to create ftps server listener.
  • Under Policies --> Create container "File Transfer" --> Right click and Add Policy, give the name of the policy "FTPS Incoming"
  • Open the FTPS Incoming policy, from the right menu go to Routing --> drag n drop "Save to File" filter.


Note: For the demonstration purpose I am saving the file in local server, you can use other filters according to your usecases.

  • Open "Save to File" filter and configure as below
Create Password Authentication Policy

This policy required to authenticate the client using username and password.

  • Add new policy similary created for FTPS Incoming policy, give the name "Password Authentication"
  • Open the policy, from right menu go to Authentication --> drag n drop Attribute Authentication and configure as below

  • Click Finish.

Create a User in OAG
  • Go to Users and Groups --> Users --> Click on Add, add new user weblogic.


  • Click Ok.
Configure FTPS server in OAG
  • Go to Listeners --> Oracle API Gateway --> Right Click and selct "Add File Transfer Service"
  • Configure as shown below

  • Select Password Authentication policy and FTPS Incoming policy as shown in the picture above
  • Select the IA server Cert that you have created above.
  • The directory used above is default directory, you can change this directory by putting folder name like ${environment.VINSTDIR}/file-transfer/in/weblogic

Test FTPS server connection

You can use any client like Filezilla or WinScp to test the FTPS connection. 
Use the user weblogic that is created in Oracle API Gateway.

Reference
  • https://docs.oracle.com/cd/E39820_01/doc.11121/gateway_docs/content/general_file_transfer.html

Friday, January 29, 2016

java.lang.Error: Critical Error. Failed to write transaction file /osb/configfwk/core_wls_osb1/_xact_ctrl.ih

Sometimes when you deployed the osb project using /sbconsole you will get the following exception while activating the project i.e.


Cause: 

The possible reason for this exception is the disk is full

Solution:

Check the disk space using the follwoing command

df -h

if the disk is full, then empty the space by deleting the logs file.

Saturday, January 23, 2016

Oracle API Gateway 12c : Getting started with SFTP server

In this blog post I going demonstrate how to create a SFTP server inside the Oracle API Gateway (OAG).

Below are the steps required to create SFTP server:

  • Generate SSL certificate for sftp server
  • Configure SSL certificate in OAG
  • Create SFTP Incoming file policy
  • Create Password Authentication Policy
  • Create User in OAG
  • Configure SFTP server in OAG
  • Test and verify SFTP connection using client


Generate SSL certificate for sftp server

You need openssl to create ssl certificate. you can download the openssl from here : https://www.openssl.org/source/

Please follow below blog post to configure ssl certificate

http://www.codeconfuse.com/2016/01/how-to-generate-ssl-certificate-using.html

Configure SSL certificate in OAG

  • Open policy studio --> Go to Certificates and Keys --> Certificates --> Click on Create/Import



  • Import the certificate that you have created above, click on import certificate




  • Go to Private Key tab and import the private key

  • Click Ok and finish the certificate import wizard.

Create SFTP Incoming Policy

This policy is used to handle the incoming file coming from the sftp client and this is required to create sftp server listener.
  • Under Policies --> Create container "File Transfer" --> Right click and Add Policy, give the name of the policy "SFTP Incoming"
  • Open the SFTP Incoming policy, from the right menu go to Routing --> drag n drop "Save to File" filter.

Note: For the demonstration purpose I am saving the file in local server, you can use other filters according to your usecases.

  • Open "Save to File" filter and configure as below



Create Password Authentication Policy

This policy required to authenticate the client using username and password.

  • Add new policy similary created for SFTP Incoming policy, give the name "Password Authentication"
  • Open the policy, from right menu go to Authentication --> drag n drop Attribute Authentication and configure as below

  • Click Finish.

Create a User in OAG
  • Go to Users and Groups --> Users --> Click on Add, add new user weblogic.


  • Click Ok.

Configure SFTP server in OAG


  • Go to Listeners --> Oracle API Gateway --> Right Click and selct "Add File Transfer Service"
  • Configure as shown below


  • Select Password Authentication policy and SFTP Incoming policy as shown in the picture above
  • Select the IA server Cert that you have created above.
  • The directory used above is default directory, you can change this directory by putting folder name like ${environment.VINSTDIR}/file-transfer/in/weblogic

Test SFTP server connection

You can use any client like Filezilla or WinScp to test the SFTP connection. 
Use the user weblogic that is created in Oracle API Gateway.

Reference
  • https://docs.oracle.com/cd/E39820_01/doc.11121/gateway_docs/content/general_file_transfer.html


How to generate ssl certificate using openssl

This blog post is about how to create ssl certificate using openssl. you require openssl software to create certificate so you can download the openssl binaries from here
https://www.openssl.org/source/

Below are the steps required to create ssl certificate

  • Create Root CA Key
  • Create Root CA based on the CA Key
  • Create Subordinate certificate key
  • Create subordinate certificate request 
  • Signed the subordinate certificate with the Root CA


Create Root CA Key

genrsa -out ca.key 1024

This command create 1024-bit key with no password







genrsa -des3 -out ca.key 1024

This command generate 1024-bit key with password




Create Self Signed Root CA

req -new -x509 -days 730 -key ca.key -out ca.crt

ca.crt is root ca which is valid for 2 years.

Create subordinate certificate key

genrsa -out ia.key 1024

The key generated is 1024-bit with no password, you can create with password as created above for  Root CA.

Note: Size of the key should be same

Create subordinate certificate request

req -new -key ia.key -out ia.csr


Signed subordinate certificate with Root CA

x509 -req -days 365 -in ia.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out ia.crt



This is a signed certificate valid for 1 year and used for actual signing. so use the ia.crt as certificate and ia.key its private key.