Sunday, June 29, 2014

SOA 12c - Accessing soainfra database

SOA12c has been bundled into a single installation package to provide a quick start for everyone to use it easily without the hassles like running rcu.. but it does mean that as a developer you are not directly exposed to the soa-infra schema, if you want to play with the underlying tables and how the data is being created behind the scenes.

When you set up the integration domain for SOA12c, internally a JavaDB(Apache Derby DB) database 'soainfra' gets created. To give a bit of background on what a JavaDB is - It is a RDBMS primarily aimed for embedded java applications where in the client-server model & clustering is not the main priority.

The JavaDB is included as part of the JDK installation and can be accessed via either EmbeddedDriver(org.apache.derby.jdbc.EmbeddedDriver) for the embedding application (or) via the Derby Network Server drivers(org.apache.derby.jdbc.ClientDriver, org.apache.derby.jdbc.ClientXADriver) for other clients.

Lets see how we can setup the clients to access the soainfra db for SOA 12c.

JavaDB has a built-in interactive SQL client - 'ij' which can be used to query the schemas/tables in the database. Below image shows how to use the tool -


The other easy option is to use the JDeveloper to setup an IDEConnection to the soa-infra database as shown below:



Enter the soainfra db details for building the custom jdbc url.


Click on the Library search icon to verify the right version of the library for the driver.

Test the connection


Now we can query the soainfra schema :)




Unfortunately, I think currently the SQL Developer doesn't have the support for JavaDB and hence cannot use it.


Maven Support for Oracle Fusion Middleware 12c - SOA/OSB/Coherence

I am sure you are one among many who have been waiting for Oracle to provide native support for building their various technology artefacts through maven. In a way they started doing it from 11gR2, but the support really lacked in terms of built-in plug-in / archetype support for building applications for technologies like SOA,OSB,ADF,Coherence etc.. The main problem was to find a way to describe the dependencies to compile,build & package the artefacts for different projects that are part of the above listed technologies.

With the release of 12c, things have been changing and when SOA 12c was released late last week, I couldn't resist myself to check the maven support as the first thing. 

Oracle Maven Synchronization Plug-in
Oracle Maven Synchronization plug-in provides a mechanism for Oracle to handle library dependencies & technology plug-ins from a Oracle Home perspective (i.e) it allows us to populate the repository for a Oracle Home and any patching going forward will allow us to sync the repository for that particular environment without affecting other installations.

It is shipped with Oracle weblogic server, Jdeveloper & Oracle coherence installation bundles and to install/deploy into a repository, you should provide the Oracle Home details as well to manage the synchronization going forward. When we install the plug-in, it looks for all the maven artefacts in the Oracle Home & installs them in the specified Maven repository. This ensures that the version numbers would match exactly at the binary level ensuring the consistency.

Installation Process
In my laptop, I have a maven local repository and also configured 'Artifactory' as the remote repository. Below shows the remote repository configuration in the maven settings.xml file.



#Maven settings.xml configurations
<servers>
    <server>
      <id>lib-snapshot</id>
      <username>admin</username>
      <password>{jbf3GAd5kk8H/zUwaYzA2dDzabrj+jrSVwN76oM3FZ4=}</password>
    </server>
    <server>
      <id>lib-release</id>
      <username>admin</username>
      <password>{jbf3GAd5kk8H/zUwaYzA2dDzabrj+jrSVwN76oM3FZ4=}</password>
    </server>
    <server>
      <id>plugin-release</id>
      <username>admin</username>
      <password>{jbf3GAd5kk8H/zUwaYzA2dDzabrj+jrSVwN76oM3FZ4=}</password>
    </server>
    <server>
      <id>plugin-snapshot</id>
      <username>admin</username>
      <password>{jbf3GAd5kk8H/zUwaYzA2dDzabrj+jrSVwN76oM3FZ4=}</password>
    </server>
  </servers>
<profile>
      <id>artifactory</id>
      <repositories>
        <repository>
          <snapshots><enabled>false</enabled></snapshots>
          <id>lib-release</id>
          <name>Repository for library release</name>
          <url>http://localhost:8081/artifactory/libs-releases-local</url>
          <layout>default</layout>
          </repository>
        <repository>
          <snapshots></snapshots>
          <id>lib-snapshot</id>
          <name>Repository for snapshots</name>
          <url>http://localhost:8081/artifactory/libs-snapshots-local</url>
          <layout>default</layout>
        </repository>
        <repository>
          <snapshots></snapshots>
          <id>ext-snapshot</id>
          <name>Repository for external snapshots</name>
          <url>http://localhost:8081/artifactory/ext-snapshots-local</url>
          <layout>default</layout>
        </repository>
        <repository>
          <snapshots></snapshots>
          <id>ext-release</id>
          <name>Repository for external release</name>
          <url>http://localhost:8081/artifactory/ext-releases-local</url>
          <layout>default</layout>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
          <id>plugin-release</id>
          <name>Plugin Repository for release</name>
          <url>http://localhost:8081/artifactory/plugins-releases-local</url>
        </pluginRepository>
        <pluginRepository>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
          <id>plugin-snapshot</id>
          <name>Plugin Repository for snapshot</name>
          <url>http://localhost:8081/artifactory/plugins-snapshots-local</url>
        </pluginRepository>
      </pluginRepositories>
    </profile>

    <activeProfiles>
      <activeProfile>artifactory</activeProfile>
    </activeProfiles>

Script to install oracle sync plugin into the local & remote repository.


# setEnv.sh
export M2_HOME=/u01/apps/maven3.1.1
export MW_HOME=$HOME/Oracle/12c/Middleware/Oracle_Home
export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)
export ARTIFACTORY_HOME=/u01/apps/artifactory-2.0.1
export PATH=$JAVA_HOME/bin:$M2_HOME/bin:$ARTIFACTORY_HOME/bin:$PATH


#install_oracle_maven_sync_plugin.sh

#Provisioning the environment variables
sh ./setEnv.sh

#Installing the oracle maven sync plugin to the local repository
mvn -X install:install-file -DpomFile=$MW_HOME/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.1.3/oracle-maven-sync-12.1.3.pom 
-Dfile=$MW_HOME/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.1.3/oracle-maven-sync-12.1.3.jar -DoracleHome=$MW_HOME

#Pushing all the libraries into the local repository
mvn -X com.oracle.maven:oracle-maven-sync:push -DoracleHome=$MW_HOME -Doracle-maven-sync.testingOnly=false

#Rebuilding the archetype catalog
mvn archetype:crawl -Dcatalog=$HOME/.m2/archetype-catalog.xml

#Deploying all the libraries into a remote repository
mvn -X deploy:deploy-file -DpomFile=$MW_HOME/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.1.3/oracle-maven-sync-12.1.3.pom 
-Dfile=$MW_HOME/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.1.3/oracle-maven-sync-12.1.3.jar -Durl=http://localhost:8081/artifactory/plugins-releases-local 
-DrepositoryId=plugin-release

#Pushing all the libraries into the remote library release repository
mvn -X com.oracle.maven:oracle-maven-sync:push -DoracleHome=$MW_HOME -Doracle-maven-sync.serverId=lib-release


The terminal output shows that the plugin was successfully deployed to the remote repository.














Artifactory console showing the successful upload of plugins/libraries.



With all the technology specific plug-ins now loaded, lets describe them one by one:

Service Bus Plug-in

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

SOA Suite Plug-in

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

Oracle Coherence Plug-in


mvn help:describe -DgroupId=com.oracle.coherence -DartifactId=maven-gar-plugin -Dversion=12.1.3-0-0


Oracle Weblogic Plug-in


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



Generating Service Bus project from Maven Architype
Now that we have deployed the oracle sync plugin and reloaded the maven archetypes, we can create service bus,soa,coherence projects using them. The below example shows how to generate a service bus application using the built-in archetype

In the New Gallery Select -> Maven -> Generate from Archetype

Click on the Maven Architype LOV to select the servicebus archetype


Search by text 'servicebus' and select the appropriate archetype populated from the local repository.



The Service Bus application has been successfully created using the archetype.




There are two different kinds of project archetypes available for a service bus application. They are :

<groupId>com.oracle.servicebus.archetype</groupId>
<artifactId>oracle-servicebus-project</artifactId>
<version>12.1.3-0-0</version>
<name>Oracle Service Bus - Project Archetype</name>

<groupId>com.oracle.servicebus.archetype</groupId>
<artifactId>oracle-servicebus-system</artifactId>
<version>12.1.3-0-0</version>
<name>Oracle Service Bus - System Resources Archetype</name>

The first one is for the actual service bus project and the second is for the System resources (we will see more about this in coming blog posts). The system resources are a way of sharing resources like JNDI, SMTP & Proxy servers across different service bus projects.

Lets build & package the application..



Build output...


References -
http://docs.oracle.com/middleware/1212/core/MAVEN/introduction.htm#MAVEN8755
http://docs.oracle.com/middleware/1213/osb/develop/osb-maven.htm

Friday, May 2, 2014

Adding components to finder toolbar

In previous versions of Mac, you can just drag & drop apps to the finder window, but with Mavericks, you also need to hold the cmd button while drag & drop.

Unix Startup Scripts

There is always a confusion on which dot file to use to initialise environment variables under unix (i.e) .bash_profile , /etc/profile , .bashrc, .bash_login et.al?

There is two different types of shells called login shell & interactive shell and each has it own sequence of dot files to look for while starting. How do you differentiate them ? When trying to remotely login through ssh or any shell which asks to login is considered as login shell.



In the case of a login shell, the /etc/profile file is sourced first. Then it looks for the files in below sequence
.bash_profile -> ~/.bash_login -> .profile and whichever is found first & readable is executed.

In the case of a interactive shell, then it looks for ~/.bashrc and executes it if present.

On my setup  what ideally I do is to keep my environment variables in ~./profile file as the subshell (or) subprocess would inherit that. All the alias definitions would go into the ~/.bashrc file.

A good reference is available here


How to open more than one instance of the app in mac

Normally you can only open one instance of the application in mac from the applications menu.. To open multiple instances here is a way to do it - either open a terminal & type open -n <The .app file path' or create a apple script which will do it for you. Make sure you save it as .app to launch it as an application.

Below is an example for a sample script i have created to launch multiple instances of soap ui.


simple hack to open unauthorized apps in mac

By default the security & privacy setting in mac would allow you open applications downloaded from appstore & identified developers. The apps that you download from web, normally they are not allowed to be opened and a simple hack to do is to press command and double click on the app. This will open a window with a warning having a open button. The other option is to change the security & privacy setting to open applications downloaded from anywhere and that could be a bit risky.




bash vs sh

There is always a confusion as to why we define the following while writing a shell script in unix based system:
#! /bin/sh (or) #! /bin/bash
#! is known as shebang which lets the rest of the line to be considered as a interpreter directive by the program loader. Thus the program loader knows which interpreter needs to be used to execute the shell script.
sh - Bourne Shell used to be the default shell of the old unix systems.
bash - Bourne-again shell is the outcome of the GNU project and it supersedes sh. In Mac and most of the linux distributions bash is shipped as the default interpreter. In fact sh is considered as a system shell and hence in most distributions is mostly a symbolic link to bash.