Tuesday, September 16, 2014

Installing and Configuring Oracle HTTP Server 12C in a Standalone Domain

We wanted to install Oracle HTTP Server instance in the DMZ to front-end the web Logic Server hosted in the application layer and hence did the standalone installation.
Launch the installation program by entering the following command: ./fmw_12.1.3.0.0_ohs_linux64.bin



This screen introduces you to the product installer.





Enter the path to an existing Oracle Fusion Middleware Infrastructure Oracle home.



Select Standalone HTTP Server (Managed independently of WebLogic server) if you are installing Oracle HTTP Server in a Standalone domain.








If you want to save these options to a response file, click Save Response File and provide the location and name of the response file










Click Finish to dismiss the installer.



Configuring Oracle HTTP Server in a Standalone Domain


To begin domain configuration, go to ORACLE_HOME/oracle_common/common/bin
./config.sh

Select Oracle HTTP Server (Standalone) - 12.1.3.0 [ohs].



Select Oracle Hotspot JDK.




Specify the system component name


Specify the OHS Server details


Select Per Domain as the Node Manager type and specify the Node Manager credentials.


Review the details of each item on the screen and verify that the information is correct.






Starting the Node Manager & Oracle HTTP Server


Navigate to the DOMAIN_HOME/bin and execute $ nohup sh startNodeManager.sh &
To start the web server run script $ ./startComponent.sh ohs1 in the same location

To test the server enter the url as http://hostname:port


Starting Oracle HTTP Server Instances on a Privileged Port (UNIX Only)


On a UNIX system, TCP ports in a reserved range (typically less than 1024) can only be bound by processes with root privilege. Oracle HTTP Server always runs as a non-root user; that is, the user who installed Oracle Fusion Middleware. On UNIX, special configuration is required to allow Oracle HTTP Server to bind to privileged ports.
To enable Oracle HTTP Server to listen on a port in the reserved range (for example, the default port 80 or port 443) as a process without root privilege, use the following steps.


Saturday, September 13, 2014

Oracle SOA / Weblogic 12C - Register new JDBC drivers

We had a requirement to connect to MS SQL server from Oracle SOA Suite 12C using the microsoft JDBC type 4 driver. But while creating the JDBC connection from weblogic console using the ANY type driver available with 12C it was throwing the below error.

Cannot load driver: com.microsoft.jdbc.sqlserver.SQLServerDriver 

As a workaround we wanted to register  Microsoft’s SQL SERVER Driver (Type 4) Version: 2005 and later. Below are the steps we used to register the missing driver. Although weblogic comes with most of the drivers by default, We can register any third party driver supported by weblogic using the below steps.

Oracle SOA 12C connect to MS SQL server

1. Download the Microsoft JDBC driver  for MS SQL server (sqljdbc4.jar) from http://msdn.microsoft.com/en-us/sqlserver/aa937724.aspx

2.Copy the jar file to the weblogic lib folder ${WL_HOME}/SERVER/lib.The jar file should be available in all the managed servers to which the datasource will be targeted.

3.Add the path to the WEBLOGIC_CLASSPATH in the commEnv.sh located in the ${WL_HOME}/common/bin/commEnv.sh. You can verify if the jar was included to calsspath in the logs during server start up. 

4. To update the list of drivers weblogic navigate to ${WL_HOME}/server/lib and add the below entry to the jdbcdrivers.xml.

<Driver
Database="MS SQL SERVER"
Vendor="Microsoft"
Type="Type 4"
DatabaseVersion="2005 and later"
ForXA="false"
ClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
URLHelperClassname="weblogic.jdbc.utils.MSSQL2005JDBC4DriverURLHelper"
TestSql="SELECT 1">
<Attribute Name="DbmsName" REQUIRED="false" InURL="true"/>
<Attribute Name="DbmsHost" REQUIRED="true" InURL="true"/>
<Attribute Name="DbmsPort" Required="true" InURL="true" DefaultValue="1433"/>
<Attribute Name="DbmsUsername" Required="true" InURL="false"/>
<Attribute Name="DbmsPassword" Required="true" InURL="false"/>

</Driver>

Restart the servers and the new driver should be available as below.


Oracle SOA 12C - Migrating projects with DB adapter returning XMLTYPE

While migrating SOA composites containing DB adpaters which calls stored procedures in Oracle database returning XMLTYPE from SOA suite 11g to 12c an error similar to the below may be noticed.


</faultType> 
-<bindingFault xmlns="http://schemas.oracle.com/bpel/extension"> 
-<part name="summary"> 
<summary> 

Exception occurred when binding was invoked. 
Exception occurred during invocation of JCA binding: "JCA Binding execute of Reference operation '*******' failed due to: Object XML conversion error. 
An error occurred while converting a Java object to XML. 
Unable to convert the XSD element ***** whose JDBC type is OPAQUE to a corresponding XML document element. Cause: java.lang.ClassCastException: weblogic.jdbc.wrapper.WrapperSQLXML_oracle_xdb_XMLType cannot be cast to oracle.sql.OPAQUE 
Analyze the error and correct if possible. Contact oracle support if error is not fixable. This exception is considered not retriable, likely due to a modelling mistake. 
". 
The invoked JCA adapter raised a resource exception. 
Please examine the above error message carefully to determine a resolution. 

</summary> 
</part> 
-<part name="detail"> 
<detail> 

weblogic.jdbc.wrapper.WrapperSQLXML_oracle_xdb_XMLType cannot be cast to oracle.sql.OPAQUE 

</detail> 
</part> 
-<part name="code"> 
<code> 

null 

</code> 
</part> 
</bindingFault> 
</bpelFault>
 

The problem is that in 11G the wizard creates the schema elements as SYS.XMLTYPE for XML type parameters whereas in 12C it should be PUBLIC.XMLTYPE.So changing this in database adapter schema will resolve the issue.

For example,

from

<complexType> 
<sequence> 
<element name="P_XML_VALUE" type="db:SYS.XMLTYPE" db:index="2" db:type="Opaque" minOccurs="0" nillable="true"/> 
</sequence> 
</complexType>

to


<complexType> 
<sequence> 
<element name="P_XML_VALUE" type="db:PUBLIC.XMLTYPE" db:index="2" db:type="Opaque" minOccurs="0" nillable="true"/> 
</sequence> 
</complexType>



Wednesday, June 4, 2014

Installing Oracle Enterprise Repository

We had a requirement of setting up oracle enterprise repository for SOA governance. Below are the steps for single node installation on weblogic server.


Oracle WebLogic Server Installation

Run the installer as follows:
-bash-4.1$ /u01/java/jdk1.7.0_55/bin/java -d64 -jar wls_121200.jar
The Welcome screen is displayed when you start the installer.




Specify the Middleware home directory that will serve as the central support directory for all Fusion Middleware products installed on the target system, including WebLogic Server.







This screen displays a list of JDKs available and also contains the option for browsing for JDK.


You can accept the default product directories or specify new directories.





This screen shows the progress of the installation. When the progress bar reaches 100%, the installation is complete.




Installing Oracle Enterprise Repository



Unzip the downloaded file and execute the jar as follows:
-bash-4.1$ /u01/java/jdk1.7.0_55/bin/java -d64 -jar OER111170_generic.jar

Welcome screen is displayed


Click Next and choose the  existing Middleware Home Directory.



Choose the Products Installation Directories






Specify the information required to initialize Oracle Enterprise Repository for your application server, and click Next. The Configure Database screen is displayed.









Navigate to $WL_HOME/common/bin and run the config script to start the configuration Wizard.



Select the check boxes corresponding to the OER.





Enter the name of the domain and specify the domain location.


 Configure the username and password for the administrator. The username is used to boot the administration server and connect to it.



 Select the WebLogic domain startup mode.














Start the admin server and managed server and the OER is accesible at http://hostname:port/oer

Thursday, March 27, 2014

Java/BPEL Authenticate & Search Active Directory

We recently needed to create a BPEL service to authenticate users in Active Directory and also to search through the AD. For this we used the native LDAP classes in Java to connect to Active directory and embed the code in spring bean and expose as web service in Oracle SOA suite.


AD Authentication

We used the following code in the Spring bean for user authentication.
 public boolean isAuthenticated(String user,String pwd){      
     DirContext ctx = null;  
     boolean result=false;  
     Hashtable env = new Hashtable();  
     String ldapURL = "ldap://myhost1.company.ae:389";  
     env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");  
     env.put(Context.SECURITY_AUTHENTICATION, "simple");  
     env.put(Context.SECURITY_PRINCIPAL, user);  
     env.put(Context.SECURITY_CREDENTIALS,pwd);  
     env.put(Context.PROVIDER_URL, ldapURL);  
     try {  
       ctx = new InitialLdapContext(env, null);  
       result=true;  
     } catch (Exception e) {  
       System.err.println("Invalid login for user: " + user);  
       }finally{  
       try {  
         if(ctx!=null)  
         ctx.close();  
       } catch (NamingException e) {  
         System.err.println("Invalid login for user: " + e);  
       }  
     }  
       return result;  
    }   

And below is the java code to search through the Active directory. Since we have multiple domain controls and the servers hosted in Solaris which is not in the domain we had used the ping functionality to see if the domain control is up before connecting to it.


 package sample.com;  
 import java.io.IOException;  
 import java.net.InetAddress;  
 import java.net.UnknownHostException;  
 import java.util.Hashtable;  
 import javax.naming.ldap.*;  
 import javax.naming.directory.*;  
 import javax.naming.*;  
 public class SearchAD {  
   public static void main(String[] args) {  
     Hashtable env = new Hashtable();  
     String userName ="CN=admin,OU=Application Accounts,DC=company,DC=ae";  
     String password = "******";  
     String ldapURL = getReachableHost();  
     env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");  
     env.put(Context.SECURITY_AUTHENTICATION, "simple");  
     env.put(Context.SECURITY_PRINCIPAL, userName);  
     env.put(Context.SECURITY_CREDENTIALS, password);  
     //Used if LDAPS port is used  
     //   env.put(Context.SECURITY_PROTOCOL,"ssl");  
     //connect to domain controller  
     env.put(Context.PROVIDER_URL, ldapURL);  
     try {  
       // Create the initial directory context  
       DirContext ctx = new InitialLdapContext(env, null);  
       SearchControls searchCtls = new SearchControls();  
       //Array of attributes to be returned  
       String returnedAtts[] ={ "sn", "mail", "cn", "givenName", "title" };  
       searchCtls.setReturningAttributes(returnedAtts);  
       //Provide the search scope  
       searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);  
       //Provide the LDAP filter for search  
       String searchFilter = "(&(sn=Siva*)(mail=*))";  
       //Provide the Base for search  
       String searchBase = "DC=company,DC=ae";  
       // Search for objects using the filter  
       NamingEnumeration results =ctx.search(searchBase, searchFilter, searchCtls);  
       //Iterate through the results  
       while (results.hasMoreElements()) {  
         SearchResult sr = (SearchResult)results.next();  
         System.out.println(">>>" + sr.getName());  
         Attributes attribs = sr.getAttributes();  
         if (attribs != null) {  
           try {  
             System.out.println("surname==>" +  
                       attribs.get("sn").get());  
             System.out.println("firstname==>" +  
                       attribs.get("givenName").get());  
             System.out.println("Email==>" +  
                       attribs.get("mail").get());  
             System.out.println("  cn==>" +  
                       attribs.get("cn").get());  
             System.out.println(" Title==>" +  
                       attribs.get("title").get());  
           } catch (NullPointerException e) {  
             System.out.println("Errors listing attributes: " + e);  
             e.printStackTrace();  
           }  
         }  
       }  
       ctx.close();  
     } catch (NamingException e) {  
       System.err.println("Problem searching directory: " + e);  
       e.printStackTrace();  
     }  
   }  
   public boolean isAuthenticated(String user,String pwd){      
     DirContext ctx = null;  
     boolean result=false;  
     Hashtable env = new Hashtable();  
     String ldapURL = getReachableHost();  
     env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");  
     env.put(Context.SECURITY_AUTHENTICATION, "simple");  
     env.put(Context.SECURITY_PRINCIPAL, user);  
     env.put(Context.SECURITY_CREDENTIALS,pwd);  
     env.put(Context.PROVIDER_URL, ldapURL);  
     try {  
       ctx = new InitialLdapContext(env, null);  
       result=true;  
     } catch (Exception e) {  
       System.err.println("Invalid login for user: " + user);  
       }finally{  
       try {  
         if(ctx!=null)  
         ctx.close();  
       } catch (NamingException e) {  
         System.err.println("Invalid login for user: " + e);  
       }  
     }  
       return result;  
    }   
 //Ping the server to see if alive  
   public static String getReachableHost() {  
     String ldapURL = null;  
     try {  
       InetAddress address = InetAddress.getByName("myhost1.company.ae");  
       if (address.isReachable(3000)) {  
         ldapURL = "ldap://myhost1.company.ae:389";  
       } else {  
         address = InetAddress.getByName("myhost2.company.ae");  
         if (address.isReachable(3000)) {  
           ldapURL = "ldap://myhost2.company.ae:389";  
         } else {  
           address = InetAddress.getByName("myhost3.company.ae");  
           if (address.isReachable(3000)) {  
             ldapURL = "ldap://myhost3.company.ae:389";  
           } else {  
             address = InetAddress.getByName("myhost4.company.ae");  
             if (address.isReachable(3000)) {  
               ldapURL = "ldap://myhost4.company.ae:389";  
             }  
           }  
         }  
       }  
     } catch (UnknownHostException e) {  
       System.err.println("Unable to lookup host");  
     } catch (IOException e) {  
       System.err.println("Unable to reach host");  
     }  
     return ldapURL;  
   }  
 }  

Below are some of the common exceptions thrown by the API.

Invalid AD username or password 

[LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 52e, v1db1
javax.naming.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 52e, v1db1


SSL Port instead of HTTP


javax.naming.CommunicationException: simple bind failed: myhost1.company.ae:389 [Root exception is javax.net.ssl.SSLException: java.net.SocketException: Software caused connection abort: recv failed]
javax.naming.CommunicationException: simple bind failed: myhost1.company.ae:389 [Root exception is javax.net.ssl.SSLException: java.net.SocketException: Software caused connection abort: recv failed]

Tuesday, March 25, 2014

Weblogic decrypt password

Weblogic Server uses AES encryption to save the passwords in file.The database passwords in the jdbc files or passwords in config.xml files are encrypted using a AES cipher and the AES secret key is stored in SerializedSystemIni.dat. At times we will need to decrypt this password to get the plain password.Below are the steps to decrypt the password.

1.Copy the SerializedSystemIni.dat from $DOMAIN_HOME/security folder to the $WL_HOME/common/bin folder.

The SerializedSystemIni.dat file varies across weblogic domains.

2.Create a simple python script file for example(DecryptWLPwd.py) and copy the below contents and save the file.
from weblogic.security.internal import *
from weblogic.security.internal.encryption import *
# Remind user about how to use
raw_input("Please ensure SerializedSystemIni.dat is in the current directory now, and press ENTER to continue.")
# Get encryption service
encryptionService = SerializedSystemIni.getEncryptionService(".")  
clearOrEncryptService = ClearOrEncryptedService(encryptionService)
# Get user to enter password
pwd = raw_input("Enter encrypted password (Eg. {3DES}Y1fA34S...): ")
# Remove unnecessary escape characters
preppwd = pwd.replace("\\", "")
# Decrypt the password
print "Decrypted password is: " + clearOrEncryptService.decrypt(preppwd)



3.Start the Weblogic Scripting tool from $WL_HOME/common/bin
./wlst.sh

4.Execute the script with the below command.

wls:/offline> execfile('DecryptWLPwd.py')

The script will  prompt to confirm the SerializedSystemIni.dat file in the current directory and get the encrypted password and output the decrypted password.

Thursday, March 13, 2014

ODI 11g Additional Drivers to the Standalone Agent and ODI Studio

ODI 11g connect to Firebird SQL

ODI installation includes a set of Data Direct drivers for the following technologies: Oracle, Hypersonic SQL, SQL Server, Sybase ASE, and DB2 UDB. If additional drivers and open tools are needed, they must be added to the Standalone Agent and the ODI Studio.
Even though this post explains how we can connect to Firebird SQL but same steps can be used to any JDBC supported database.

Create a new physical architecture

Create a new Data Server.
Driver Class  : org.firebirdsql.jdbc.FBDriver
Sample JDBC URL: jdbc:firebirdsql://hostname:port/F:/RESPAKDB/respak.gdb


On Windows operating systems, go to the following directory (not created until after ODI Studio is launched for the first time)
%APPDATA%\odi\oracledi\userlib

This folder contains the additional_path.txt file that allows you to declare additional files or folders outside of the /userlib directory from which the ODI Studio acquires its libraries and drivers.
Sample
; Additional paths file; You can add here paths to additional libraries
; Examples:
; C:\ java\libs\myjar.jar
; C:\ java\libs\myzip.zip
; C:\java\libs\*.jar will add all jars contained in the C:\java\libs\ directory
; C:\java\libs\**\*.jar will add all jars contained in the C:\java\libs\ directory and subdirectories
C:\Users\xxxxxxx\AppData\Roaming\odi\oracledi\userlib\jaybird-full-2.1.6.jar


Now click on the Test Connection and you should be able to see the success message as below.

Now you can proceed to create the logical schema and use it in the models and reverse engineer and use in projects.