Tuesday, September 6, 2016

Two way handshake in Java

I recently happened to work on two-way SSL handshake where client authorization will take place using certificate provided by trusted one. I got into lot of problems when I was trying to achieve this in Java. So I started reading about this and came to know that we can even enable SSL handshake debugging by just providing -Djavax.net.debug=all in your VM arguments. But trust me, again this log was a mystery to me to understand. Then again started asking Google about this. It gave me handful of blogs and stackexchange answers to get more details on this. I went through most of them and understood how to read this SSL debug log and finally solved the problem. May be if you are interested you can refer this simple blog 'http://www.smartjava.org/content/how-analyze-java-ssl-errors' explains step by step on what happens during SSL handshake process. Please share if you get into any such issues in this.

Sunday, May 17, 2015

Log4j configuration in Java applications

Hello Guys,
This time I come with a very simple, useful and very common requirement that all of our Java developers have.

I used System.out.println extensively when I was new to Java world but after few years(1 or 2 may be) :) I realized that it is not really a good idea to use it in production ready applications. Then slowly moved to Log4j for all logging requirements and made my life simple.

So here I am giving you the configuration file that I am currently using for all my applications. I don't change this file unless my application demands it. I know it is very simple and everyone knows about what I am writing here but I still feel that it would be handy when you guys really need it. I configure this based on my regular requirements and feel free to change this on need basis

Small notes:
  • You can see log4j internal debug statements by enabling  log4j.debug property
  • It basically writes all (INFO, DEBUG, ERROR) level logs into separate files
  • They role the files on daily basis
  • You can change the file paths based on your folder structures
  • Change the package name to enable DEBUG level to your application logging

#log4j.debug=true
# Root logger option
log4j.rootLogger=INFO, infoappend, debugappend, errorappend
log4j.logger.<Give your package name>=DEBUG

# Only DEBUG
log4j.appender.debugappend=org.apache.log4j.DailyRollingFileAppender
log4j.appender.debugappend.File=/opt/apache-tomcat-7.0.40/logs/app_DEBUG.log
log4j.appender.debugappend.DatePattern='.'yyyy-MM-dd
log4j.appender.debugappend.layout=org.apache.log4j.PatternLayout
log4j.appender.debugappend.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
log4j.appender.debugappend.filter.A=org.apache.log4j.varia.LevelRangeFilter
log4j.appender.debugappend.filter.A.LevelMin=DEBUG   
log4j.appender.debugappend.filter.A.LevelMax=DEBUG
log4j.appender.debugappend.filter.A.AcceptOnMatch=true

# Only INFO
log4j.appender.infoappend=org.apache.log4j.DailyRollingFileAppender
log4j.appender.infoappend.File=/opt/apache-tomcat-7.0.40/logs/app_INFO.log
log4j.appender.infoappend.DatePattern='.'yyyy-MM-dd
log4j.appender.infoappend.layout=org.apache.log4j.PatternLayout
log4j.appender.infoappend.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
log4j.appender.infoappend.filter.A=org.apache.log4j.varia.LevelRangeFilter
log4j.appender.infoappend.filter.A.LevelMin=INFO   
log4j.appender.infoappend.filter.A.LevelMax=INFO
log4j.appender.infoappend.filter.A.AcceptOnMatch=true

# Only ERROR
log4j.appender.errorappend=org.apache.log4j.DailyRollingFileAppender
log4j.appender.errorappend.DatePattern='.'yyyy-MM-dd
log4j.appender.errorappend.File=/opt/apache-tomcat-7.0.40/logs/app_ERROR.log
log4j.appender.errorappend.layout=org.apache.log4j.PatternLayout
log4j.appender.errorappend.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
log4j.appender.errorappend.filter.A=org.apache.log4j.varia.LevelRangeFilter
log4j.appender.errorappend.filter.A.LevelMin=ERROR   
log4j.appender.errorappend.filter.A.LevelMax=ERROR
log4j.appender.errorappend.filter.A.AcceptOnMatch=true

#Redirect to Tomcat logs folder
#log4j.appender.file.File=${catalina.home}/logs/logging.log

# Direct log messages to a log file and role it based on it's size
#log4j.appender.file=org.apache.log4j.RollingFileAppender
#log4j.appender.file.File=C://app.log
#log4j.appender.file.MaxFileSize=10MB
#log4j.appender.file.MaxBackupIndex=10

# Direct log messages to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n


Sunday, February 8, 2015

HUDSON + SonarQube

Hello,
In my last post i mentioned about HUDSON and now I am going to extend this to get best out of it

  • I configured HUDSON to poll my SVN repository for every 5 minutes to check any recent changes are there and to prepare a build with those changes and deploy it to Tomcat container (It is pretty straight forward. i certainly used HUDSON's plugins)
So building and deploying changes continuously task is given to HUDSON and it is happily doing without any rest. Now it is time to automate QA checks to make sure that builds are having valid and quality code. 

SonarQube is an open platform to manage your code quality. It is a one stop solution for all your quality related tasks( static checks, dynamic checks, quality reports, code duplicates, comments, coding rules, complexity..etc) It covers more than 20 programming languages like Java, C, C++...etc. You can basically analyze code by it's own Sonar analyzer or you can even use Maven analyzer(can configure to analyze with many plugins like Findbugs, PMD...etc ) and then your results will be stored into your favorite database automatically. You will be provided a nice dash board where you can see all the reports at once and take actions accordingly. Actually you can do a lot better with this great combination.

I will write another blog on how to setup SonarQube. Please do visit again.

Thursday, January 29, 2015

Configure HUDSON CI tool in Tomcat

I thought of automating the build and deployment process to reduce  the efforts that my team spends and minimize the errors that we see later while integrating and deploying to production by adopting one Continuous Integration (CI) tool into my project. I chose HUDSON as it is very simple to configure, opensource, widely adopted and I used it in one of my previous projects (5 years back). Here are the steps to configure Hudson in Tomcat

·         Download Hudson.war file from http://eclipse.org/hudson/download.php
·         Go through the best practices http://wiki.eclipse.org/Hudson-ci/Hudson_Best_Practices
·         Deploy the war file into your favorite web container(Tomcat, JBoss..etc)
·         You may need to tweak your JVM memory options like set "JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx1024m -XX:MaxPermSize=256m -server" https://docs.oracle.com/cd/E40518_01/integrator.311/integrator_install/src/cli_ldi_server_config.html
·         Start your web container and open it in browser (http://localhost:8080/hudson-3.2.1/)
·         Select or unselect required plugins and enter your proxy details if you are under proxy

·         It will download those plugins and will be ready to start play around it

Thursday, November 20, 2014

Netgear N150 WNR612 classic wireless router unboxing




Box contains: Router (WNR612), Ethernet Cable, Power Adapter, User Manual and CD
Network frequency: 2.4GHz

Setup Bower in windows machine and run angular seed projects in Netbeans.



1.     Download and install nodejs from http://nodejs.org/
a.     You can verify this by typing 2+3 and enter in the nodejs command window. It should return 5.
b.      If you are under proxy then you may need to set it using
                                                              i.       npm config set proxy http://”username:password”@proxyserver:port
                                                            ii.       npm config set https-proxy http://”username:password”@proxyserver:port
2.      Install git from http://git-scm.com/ all default options except one change as  shown below

a.     If you are under proxy you may need to specify proxy details as environment variables
                                                              i.      set HTTP_PROXY http://domain\username:password@proxyserver:port
                                                            ii.      set HTTPS_PROXY http://domain\username:password@proxyserver:port
                                                          iii.      set all_proxy http://domain\username:password@proxyserver:port
                                                          iv.      git config --global http.sslverify false
3.      Install Netbeans IDE 8.0.1 if you don’t have one
4.      Create HTML5 project using angularjs seed.
5.     You can see red mark on the project folder which you can resolve by right clicking on the project folder and selecting ‘Resolve project problems’
a.     If you are under proxy you may need to set proxy details in /.bowerrc as below
                                                              i.      "registry": "http://bower.herokuapp.com",
                                                            ii.      "proxy": "http://”username:password”@proxyserver:port".
                                                          iii.      "https-proxy": "http://”username:password”@proxyserver:port",
                                                          iv.      "strict-ssl": false.
6.     Now you can simply run this project in Netbeans just like any other project.



Thursday, July 21, 2011

SwiftkeyX application is free for today

Guys,
Have you ever bored of the default keys in your Android mobile or Tablet?
Are you looking for a better app which learns your key strokes and eases your typing next time you type?
Are you looking for an app, which understands your lazy short-cuts even?
Then I can suggest you to try SwiftkeyX application for your own Android.  But it it not a free app. I can tell you an easy way to get it free for today only. It is available for free in Amazon app store, so go and grab it immediately. Have style and fun in typing :)






Monday, July 18, 2011

Google extended transit service in hyderabad and chennai

Google has already launched their transit service in india a couple of days back and now they extended this service in Hyderabad and Chennai. Transit is really a useful feature to those who comes to city newly. If you enter source and destination and clicks on get directions, then the google maps will show you the best roots availabe and the local bus numbers also. Sounds cool?

Monday, July 4, 2011

Google+ will be in developer's hand soon..

Hi All,
I know many of you have known about Google+ by this time. I know what makes you crazy about Google Plus. It is a rock solid Social networking application from the Legendary Google. Till now I can say , I love FB in social networking but now Google+ is added to the list and heading towards top. It is really cool.

As a developer, I can even think about making some cool plug-ins or add-ons or whatever you call it is, to make Google Plus more yummy... :) . But Google  not released any API publicly  :(  So waiting eagerly for it. I know the developer inside you is  also waiting for this. You can even register to get updates on API whenever it is available. So you never miss the opportunity to spice it up.