Thursday, August 20, 2015

MongoDB as a Service

Command to create mongodb as a service is 

mongod --dbpath="C:\Program Files\MongoDB\data" --logpath="C:\Program Files\MongoDB\log\log.txt" --install

Execute above command from Mongodb's bin folder,

References :

Wednesday, August 19, 2015

Command to publish jar into your local Maven Repository

D:\Kiran\Kiran\Projects\NCB\ETL>mvn install:install-file -DartifactId=ojdbc6 -Dversion= -Dpackaging=jar -Dfile=ojdbc6.jar

Points to be noted :

  • Maven client to be installed. You can check if maven is installed by running the below command ,
    mvn -version which would result in the below result,

  • Executing above command  results in below results,

Once you see the BUILD SUCCESS in the above command result,

You can add dependency in your POM.xml as below,

<groupId></groupId> <!-- Group ID from the command-->
<artifactId>ojdbc6</artifactId>  <!-- Artifact ID from the command-->
<version></version>       <!-- Version from the command-->

References :

Saturday, July 25, 2015

How to know what version of OS you are running

Command to show the os version of windows,

Open command prompt and type in the below command

wmic os get osarchitecture

Thursday, July 16, 2015

Serialize manually using faster jackson library in spring

I am trying to get a JSON Structure for my object Order which internally has OrderDetails as oneToMany mapping,

public class Order {    
        All the fields associated with this class
    @OneToMany(fetch = FetchType.EAGER, mappedBy = "orderId")
    private Set<OrderDetails> orderDetails;

    //Getters for all properties defined in this class as jackson would depend on this thing
In my case I am using a textWebSocket which is expecting a message only in String format so I need to serialize the objects and push to the client, I am depending on faster jackson to do it and here it goes,

public String getObjectAsString()

    //orderObjs : Considering this is the list of objects of class Order

    ObjectMapper objMapper = new ObjectMapper();
            returnValue = objMapper.writerWithType(
                            List.class, Order.class)).writeValueAsString(
    return returnValue;


Monday, July 6, 2015

Use a new keyword and still inject the object : Spring

Spring works on dependency injection. This means there is no need to create an object explicitly, spring will do it for you.

But there are situations where you have to create new objects (ex., Reflection). By going with this approach you are conveying string that you will have control over the current object. i.e., any Autowired fields inside the object class will be null and spring will not consider injecting it. 

But there is a way to autowire those fields as well,


where appctx is ApplicationContext which is autowired.

Monday, June 29, 2015

Call a procedure from Spring

How to call a procedure using spring :

In this blog post I would take you through the approach of calling a procedure from spring using "StoredProcedure" approach.

StoredProcedure is an abstract class which has to be extended.

Define a class which extends StoredProcedure, below is a sample which is shown,

Then call a procedure which is shown as below,

Friday, June 26, 2015

Autowire datasource while using JdbcDAOSupport

public class EntityDAO extends JdbcDaoSupport{

Logger logger = LoggerFactory.getLogger(EntityDAO.class);

private DataSource datasource;

* Setting data source as it extends jdbcDAOSupport
private void initialize()

Wednesday, May 20, 2015

Comparing arrays in Java Script

A sample on how to compare two arrays :

Array.prototype.diff = function(a) {
    return this.filter(function(i) {return a.indexOf(i) < 0;});
var a = ['b','c'];
var b = ['b','c','d','e','f'];
var temp = a.diff(b);

Credits : Nikhil

Friday, April 10, 2015

Queries for faster development

Concatenation of column values :

I want to concatenate one column values and get it as an aggregated result from database,

For Eg :


Result should be something like this


This can be achieved in SQL Server using STUFF function and the link can be found here

In Oracle it can be achieved by,


Note : This works for Oracle version 11g R2 and higher only.

Credits : PadmaPriya Iyengar

Tuesday, April 7, 2015

Authenticator is not instantiated via the properties constructor

I am triggering a SOAP request from SOAP UI to a custom gateway of cordys environment which accepts user credentials in SOAP header.

For Ex :

<soapenv:Envelope xmlns:soapenv="" xmlns:oas="" xmlns:ns="" xmlns:ns1="">
<!-- Main SOAP Request which is connected to service group SG1-->

Content which is shown in green color is the security information which I am passing from SOAP UI. I hope people are well aware what ${#Project#username} stands for (i.e., I am reading credentials from properties of SOAP Project).

Let's say the request is targeted to service group SG1 in this case. 

As we know that any cordys service is served using SAMLArt. In this case the SAMLArt will be provided by the custom gateway to the application container. Now when the custom gateway tries to get the SAMLArt it uses the property of the application container. If it does not find the property it might throw you an error which was my case.

I encountered an exception which says something like this, Authenticator is not instantiated through the properties constructor.
at com.eibus.soap.SOAPTransaction.<init>(
at com.eibus.soap.SOAPTransaction.<init>(
at com.eibus.soap.Processor.onReceive(
at com.eibus.soap.Processor.onReceive(
at com.eibus.connector.nom.Connector.onReceive(
at com.eibus.transport.Middleware$

Now I found out the property that was missing i.e., the authenticator class. We need to add the authenticator property to the service group that was implementing my service. This should be done by using LDAP explorer,

The property which is to be added is below,

<authenticator implementation="" /> 

Since I am using CARSAuthenticator in my case. This should be added to the service group SG1 (in the above explained scenario). An example of such updation can be found below,


Saturday, April 4, 2015

Usage of elementFormDefault attribute of Schema tag

Learnings from Gora (

I was creating a WSDL in my project to generate contract first webservices. 

When I imported the WSDL in cordys, it gave me empty namespaces just after the attributes, i.e. it looked something like this :

<!--Cordys Input Structure-->

<SOAP:Envelope xmlns:SOAP="">
    <CreateForeclosureProcess xmlns="">
      <CaseId xmlns="">PARAMETER</CaseId>

<!-- External Tool input Structure, Wizdler (>

<Envelope xmlns="">
        <CreateForeclosureProcess xmlns="">
            <CaseId xmlns="">[string]</CaseId>

I did two things to remove these namespaces.

1. To remove from Cordys : Instead to having a direct element in my Request schema, I created a reference to another element.

Old :

<xsd:element name="CreateForeclosureProcess">
 <xsd:element  type="xsd:string" name="CaseId" />           

Modified :

<xsd:element name="CreateForeclosureProcess">
 <xsd:element ref="tns:CaseId" />            
  <xsd:element  type="xsd:string" name="CaseId" />

 2. Even after doing this, the Wizdler plugin was still showing the empty namespace, then a little research on web gave me following link :

which suggested to add 

to my schema tag as an attribute.

Example :
<xsd:schema targetNamespace="" elementFormDefault="qualified">

Friday, March 27, 2015

Learnings on FTPClient class of Apache

Exploration is very good for a person but sometimes there wouldn't be a proper location where you get what you need. This was one of those instances in my exploration phase and hence I would like to share the learnings of FTPClient class.

Problem Statement : ftpClientObject.getTimestamp() is not returning time in seconds field.

Explanation :

My code is something like below,

private static void getFTPFileProperties(FTPClient client,
            String ftpLocation, String pattern) throws IOException {
    FTPFile[] fileList=null;
    fileList = client.listFiles();
    for(int i=0;i<fileList.length;i++)
        FTPFile file= fileList[0];
        Calendar cal = file.getTimestamp();
        DateFormat dateFormater = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
From the above, variable cal is should ideally retrieve timestamp which will be having even seconds field. But somehow I am able to view the date part and only the hours part. The timestamp is carrying 00 in minutes and also in seconds.

Myself being helpless posted this question in stackoverflow and thankfully Martin has caught my problem absolutely right.

Reason : listFiles() will function something like ls command of unix and thus it might not retrieve the entire timestamp part. It is suggested to use mlistDir() function in order to get the entire timestamp. But only condition the method mlistDir is defined in Apache Commons 3.0 version and I was using Commons 2.0 which was the problem. The moment I changed it to Apache Commons 3.0 it started working.

There is also a function client.getModificationTime("upload/01%20(160).jpg"); which might give the same result but this also has limitations when Commons 2.0 is used. would make you understand what is the problem.

Thanks to Martin who has helped me in addressing my issue and thanks to stack overflow in helping me post it.

Reference : 

Tuesday, March 24, 2015

Get Amount in words from query : SQL Developer

Below query helps you get the amount in words and also in camel case


Below screenshot is self explanatory,

In the query mentioned, TO_DATE is used to get the amount in words and INITCAP is used to get the amount in words as camel case.

Learnings : From GIB  

Sunday, March 15, 2015

Auto Login into windows user accounts

The user account in any computer is a security measure but we tend to be always in a situation where we are sure that only we will be using and at time this security measure might become a bit tedious thing. So in order to remove this user Id login situation we can make achieve this using windows functionality,

Padding 0's in XSLT

I want a string to be fixed to 10 digits and pad 0's if it is less than length 10. This I have to achieve in XSLT here is how we can do it,


Assuming //b will have the string which is to be formatted.

Where as the same can be achieved using String functions in java,

String.format("%010d", 1236)

Friday, March 13, 2015

Change default program from command line

Sometime we wont be able to open an executable jar using default program after some infinite attempts using "open with". I have faced similar problem as there is a jar which I have to open using javaw.exe and somehow I was unable to. So here is what I have did,

I have changed the default program of jarfile using command line and awesome thing is "IT WORKED" :P

here is the command,

And then I opened the jar and It worked,

Monday, March 9, 2015

How to change oracle user's password if it is expired

Problem statement : I am trying to connect to database using sql developer and it throwed an error saying "the password has expired" and I find it really difficult to change the password from oracle homepage (ver 11).

Resolution : Open the oracle client and connect using your username and password.  It will automatically ask for change password.

Strange thing is there are no password policies at all. You can keep the old password itself for new password :P

Tuesday, February 24, 2015

Custom date format in XForm

I want to display the date time in xform in a specific format like '20/02/2015 11:23 PM'

This can be by specifying format in the following way,

'dd/MM/yyyy shorttime' or 'dd/MM/yyyy longtime'

dateformats which are defined in cordys are below :

Right click on the field and select format and specify the format as mentioned below

Runtime display of the time which you have selected above 

Thursday, January 29, 2015

XPath for the node with maximum value for a particular element : XPath1.0

Here is the list of bond characters played in bond movies and their earnings from movies,

<Name>Sean Connery</Name>
<Name>Roger Moore</Name>
<Name>George Lazenby</Name>
<Name>Timothy Dalton</Name>
<Name>Pierce Brosnan</Name>
<Name>Danial Craig</Name>

From this list I want to get the Bond details who earned the highest and least during his time. This example is just taken for fun to understand the XPath. 

To get the highest earned bond details use the below XPath


To get the least earned bond details use the below XPath


Note : The XPath which we used here is valid in XPath1.0. Alternatively you can check the same here in the below link

Credits :
GIB Learnings from Anitha and Padma Priya Iyengar