Tuesday, June 21, 2016

How to check the validity of a WSDL

Java JDK has provided a way to validate the WSDL and is done in the below way,

Command to use to validate the wsdl : 

wsimport <<WSDL Url>>

I have a WSDL at the below given url :


Now the browser will not be able to validate the wsdl hence needing a validating step. There can be online validator's or even eclipse plug in can also validate the wsdl. If any of the both steps are possible please go ahead with it, this is the third way of validating where in the guy does not have any access to internet nor does he has an eclipse installed in the machine and in need of validating the wsdl.

Java jdk has provided a way to go ahead with this and the command is shown below,

Note : The above command must be executed from bin directory of a java jdk. Yes, you must be having java jdk for it.

The result of the above command is shown here,

Now if you check the above result, the "parsing WSDL..." is completed without any errors giving us the information that the wsdl is perfectly valid.

Saturday, April 30, 2016

Avoiding EventService problem

Problem Statement :

Avoiding the problem, "Event channel is unable to connect to web server. Do you want to reconnect?".

Kiran : Hey Champ, I am trying to build an application in cordys and I am facing a problem.

Champ : What is the problem that you are facing?

Kiran : There is no error while accessing cordys application, but this confirmation box keeps popping up every now and then only to increase irritation.

Champ : I did not get you :( 

Kiran : That error which is shown below,

Champ : That is not an error right? You can simple click "Yes" whenever it pops up. Wouldn't that solve the problem?

Kiran : Yes, that would solve the problem temporarily. Can I fix it permanently?

Champ : Ohh Yes, You can!!!! First tell me, Can you see any error in the debugging tools of the browser? You must be telling me something so that I can solve your problem.

Kiran : Yes, It is trying to download some of the resource and it is failing because of some ERR_HOST_NAME_ERROR or something. I don't remember exact error but what I do remember is that there is definitely a problem with the hostname. I am using the application using the IP Address.

Champ : Thank you!! That information really helps. Now can you try from the command prompt to ping the hostname and as well as the ip address that you are trying to connect. Then let me know the results.

Kiran : I am able to get a response from ping to IP Address but not to the hostname.

Champ : Look!!!! This is the problem. Your system is not able to look up the hostname for the IPAddress that you are connecting.

Kiran : What should I do for solving this problem?

Champ : Okay!!

  • Go to the mentioned folder and locate "hosts" file, shown below,

  • Then edit hosts file with an entry similar to below, 

  • Remember, is my local intranet IP address and the host names are also mine. Don't prove yourself dumb by just copy pasting the same whatever I have shown. Use your brain please.
Kiran : You must be kidding!!!! Anyways thanks for your help champ. I understood the problem and it solved it :) See you again!!!!!! 

Thursday, April 28, 2016

Importance of variable names and column names in Entity of a Spring application

This is to have an understanding of how de-serialization works when JdbcTemplate converts the query result into object form.

My Entity Structure looks as show below,

If you observe, there is a variable name "month" whose column name is "monitor_month". This means it refers to "month" at Object level and "monitor_month" as database column name (as we know @Entity refers to a table).

Now a piece of module was developed in order to retrieve data from database. This can either be done by using JPARepository or by using JdbcTemplate. I am using the later approach,

Below is the piece of code which I have used to retrieve database information and de-serialize the information in the entity shown above,

The targetClassName here refers to the entity shown above. Considering no exception case, this piece of code should retrieve information from database by executing the query which is present in "queryTemplate" and de-serialize it by using the className provided in the variable "targetClassName". 

But somehow all of the data are not being de-serialized. Interestingly only the fields whose column names and variables are same (Ignore underscores and case) are being serialized, i.e., monitor_year is being deserialized because monitor_year and monitorYear are one and the same variable.

Hence it is must and should that the variable name which is being used should be equivalent to the column name that is being defined. 

I have modified the entity as shown below 

Once I have modified the entity as shown above, I was successful in fetching the result.

Explanation :

JdbcTemplate when executes the query gets the information which has meta-data of database (i.e., column names as of table column names). But now we need to de-serialize into an object format. Hence jdbcTemplate would want a kind of understanding between the variable names and the column names and hence it will assume these both are equivalent variables. This means that the column name "monitor_year" is equivalent to "monitoryear" or "MonitorYear" or MoniTORYear" or simply "monitorYear". Hence when there is a database column monitor_year, it will push the value into any of the above mentioned variables.

The problem with my previous approach was, the query result was giving response in the column "monitor_day" where as my variable's name is "day". This means the jdbcTemplate would consider "monitor_day" and "day" as two different variables and hence it will not de-serialize this field. The same was the problem with other fields as well.

Installation and change context path of gitlab server in linux

Installation :

The installation process of gitlab-community edition is explained here,
Configure custom Context-Path :

Once you install, there might be a necessary to change the context path of the gitlab-server. 

For example, when you install gitlab in an environment then the gitlab GUI would be accessible from the url . But normally you would want to add a context path to it i.e., you would want to access gitlab from the below url

The same would be achieved by modifying gitlab.rb file present in the installation directory.If you have access to the file, then open with default text editor and modify the property external_url to

Alternatively you can use below command to modify,
sudo vi gitlab.rb
Go to the configuration external_url in the file and modify the property to below,
Once you are done with the changes, you should let linux know about the change and to configure gitlab again, this can be done by the below command
sudo gitlab-ctl reconfigure 
Once the command is executed, the context path is configured for gitlab.

Monday, April 11, 2016

Execute DDL scripts when a spring application is initialized

Normally everyone would encounter a situation where in they want to execute few of the database scripts while deploying a solution. These scripts might include anything like executing a procedure, running a batch, insert script for defaulting of few values, update to existing dataset etc., 

When such situation arises, we can follow the below mentioned approach as an initial approach to handle it.

Spring by default tries to load a script file "data.sql" located in the classpath i.e., where the application.properties, log4j.properties etc., are present. 

Hence try to consolidate all the scripts into one file and name it as "data.sql" and place it under "<<apacheTomcatFolder>>\webapps\<<app>>\WEB-INF\classes", 

Disadvantages of this approach :
  • Since it is an automated process, any failure in the execution of scripts will not be known unless we go through the log files. Hence error percentage should be minimum.
  • Using the above approach, we cannot divide all the scripts into different modules and execute with different names. By default the spring will look for a file named "data.sql" unless someone overrides this setting in application.properties which is not explained in this blogpost.
  • A restart is needed for every change in this file. Try to use only when the script is flawless and also can be executed during the deployment. If there is a provision to execute the scripts in database then try to use that as it will provide more control over the scripts that will be run.