Posts

What is Maven repository ?

Maven Repository : A repository is a place where all the project jars, library jar, plugins or any other project specific artifacts are stored and can be used by Maven easily. There are three types of repository :  local central remote  Local Repository : The maven local repository is a local folder that is used to store all your project’s dependencies (plugin jars and other files which are downloaded by Maven). In simple, when you build a Maven project, all dependency files will be stored in your Maven local repository. The default name of the Maven's local repository is .m2. Central Repository Maven central repository is repository provided by Maven community. It contains a large number of commonly used libraries. When you build a Maven’s project, Maven will check your pom.xml file, to identify which dependency to download. First, Maven will get the dependency from your local repository, if not found, then get it from the default Maven central repo...

how to install MAVEN on linux

What is MAVEN ? Read here : http://maven.apache.org/ Here are the steps to download and install Maven on linux : Step 1 : Download the latest binary from the http://maven.apache.org/download.cgi.              apache-maven-3.0.4-bin.tar.gz Step 2 : Untar it using tar command.               tar -zxvf /usr/local/apache-maven-3.0.4-bin.tar.gz Step 3: Add Maven binary Path to the System Path i,e add in .bash_profile path           $ cd $HOME           $ vi ~/.bash_profile Set PATH and M2_HOME as follows M2_HOME=/usr/local/apache_maven-3.0.4 PATH=PATH=$PATH:$HOME/bin:/usr/local/apache_maven-3.0.4/bin save the file by pressing esc : wq button Note: Don't delete the previous PATH, Just append the M2_HOME path after : Now save and clos...

How ExceptionHandler return JSON in spring MVC

I am working on one project where client/server response is in JSON format. It is easy to send object in JSON format but what if some exception occured and you want to send the Exception also in JSON format ? After n number of trial. I finally able to do the above task .  Step 1 : Add following annotation " AnnotationMethodHandlerExceptionResolver " in your <CONTROLLER>-servlet.xml file. <!-- JSON format support for Exception -->     <bean id="methodHandlerExceptionResolver"         class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerExceptionResolver">         <property name="messageConverters">             <list>                 <ref bean="jacksonMessageConverter" />             </list> ...

What is Hibernate Caching?

Image
In a typical application, you perform lot of operations like instantiate objects, load object from the database and so on. Sometime in multiuser application you may face a situation in handling multiple call of databases. Hibernate offers caching functionality which is designed to reduces the amount of necessary database access. This is a very powerful feature if used correctly. It increases your application performance and works between your application and the database as it avoids the number of database hit as many as possible. Hibernate Cache Types : Hibernate uses different types of caches. Each type of cache is used for different purposes. Let us first have a look at this cache types. First level cache Second level cache Query level cache 1. First level cache : First-level cache is the session cache and is always Associates with the Session object. Hibernate uses this cache by default. The Session object keeps an object under its own cache before committing to th...

Useful java Keytool Command

Generate a Java keystore and key pair : keytool -genkey -alias mycert -keyalg RSA -keystore keystore.jks -keysize 1024 Generate a keystore and self-signed certificate :  keytool -genkey -keyalg RSA -alias selfsigned -keystore keystore.jks -storepass password -validity 360 -keysize 2048 keytool command to view certificate details from keyStore : keytool -list -v -keystore keystore.jks Check a particular keystore entry using an alias: keytool -list -v -keystore keystore.jks -alias mydomain keytool command option is -printcert which prints details of a certificate stored in .cer file : keytool -printcert -file test.cer Export a certificate from a keystore: keytool -export -alias mydomain -file mydomain.crt -keystore keystore.jks   keytool -export -alias mydomain -keypass keypass -keystore keystore.jks -storepass jkspass -rfc -file keytool_crt.pem Note : "keytool -export" command uses DER format by default. The "-rfc" option is to...

How to install mod_jk.so on Cent OS

The Basics - What is mod_jk? The mod_jk connector is an Apache HTTPD module that allows HTTPD to communicate with Apache Tomcat instances over the AJP protocol. Steps: 1. Download the latest apache connector from http://tomcat.apache.org/download-connectors.cgi . 2. Untar the download by           tar zxvf <filename> 3. Goto native directory of connector           cd <connector dir>/native/ 4. Run the buildconf.sh scripts        ./buildconf.sh Note : If you get any issue like "autocong" not installed then install following things:        yum install autoconf        yum install libtool 5. You need "httpd-devel" tools to build it. So make sure you have already installed it by          yum list installed | grep httpd-devel     else install it " yum install...

Load Balancing on Web Application server clusters

Image
Overview A cluster is a group of servers running a Web application simultaneously, appearing to the world as if it were a single server. To balance server load, the system distributes requests to different nodes within the server cluster, with the goal of optimizing system performance. This results in higher availability and scalability -- necessities in an enterprise, Web-based application. High availability can be defined as redundancy. If a single Web server fails, then another server takes over, as transparently as possible, to process the request. Scalability is an application's ability to support a growing number of users. If it takes an application 10 milliseconds(ms) to respond to one request, then it should take 10 ms to respond to 10,000 concurrent requests. Of the many methods available to balance a server load, the main two are: DNS round robin and Hardware load balancers. DNS Round Robin To balance server loads using DNS, the DNS server ...