Author Archives: ChandanPandey

Getting started with Java interview questions

Are you getting ready for your next career move? And Java is your preferred tool -well its worth getting through interviewers mind set and acquaint with commonly asked questions. Yeah, agree, a simple Google search will get you a “lot of stuff” -one specific can be tried here. In fact this is bit uncommon, I have not faced 50% of these in any of my interview! but then who knows, writer can turn out to be next interviewer 🙂

Top 10 mistakes by Java programmer

Recently stumbled upon this post which outlines few common mistakes made by Java Programmer. Forgetting to write break statements in switch case constructs reminded me of my initial days -although now editors are capable to giving a warning about such oversight. Running a code quality will uncover few of these errors as well for example resource not closed or probability of getting ConcurrentModificationException. But  a good read, complete article here:

What is spring integration and how can it help solve enterprise integration challenges

Over past couple of years I have been heavily involved with enterprise integration. Have worked with content management applications, enterprise telephony and many other domains –one of the key challenges faced by me is interaction and integration with external systems. Let me explain a bit, in an era of “as a service” model, an application need to integrate with n number of heterogeneous system to come in totality. Let’s take a quick example, typically new publishing might source content from one vendor, images from Instagram account, social feeds from Twitter/Facebook etc. As you might have observed –these systems are “totally” disconnected. To emphasize my point –while developing these module no one might have an idea that it could be even useful for others! Obvious enough that when we try to integrate these we will run into a hell lot of issues, let’s try to bullet out a few:

  1. How to interact with the other module? Shared file, shared DB, HTTP protocol, proprietary protocol –the list is endless, should we sit down and write all of these “Adapters”?
  2. How these systems will understand data? Data transformation –should we write converters for all the permutation combination of data formats?
  3. Definition of failure is always subjective –some will log it and ask user to try next time while other may rollback all previous step. How do we deal when we have to integrate system which follow different paradigm for failure?
  4. Rate of processing – areal time application may churn data pretty fast, what if the consumer is slow? How do we deal with that?

These are just a sneak peek in issues which I face every day. And not only me, but tons of developer out there –can we say it as an era of service integrations! And what happens when a mass faces similar kind of issue –yep, we develop frameworks, tool, so that it can be reused.
In the mess of inequality, we need a sort of mediator which can orchestrate the interaction. If all is successful – well it’s nice, but if something goes wrong –it also brings them on last stable state! And this where enterprise integration patterns gains its relevance. There are many implementations of these patterns –ApacheCamel, Spring Integration etc., but I have primarily worked with Spring Integration. Reason, we have existing Spring ecosystem, its very lightweight, does not need a separate process space, and over all very easy to use and integrate.

I have written a quick “getting started” blog on spring integration and then to further share my experience with this topic, I have jotted down, basic theory, real time issues and their ready to implement code in a book “Spring Integration Essentials” available at amazon and packtpub.
It’s not a theory book –rather “learn by example” and you will find running code for real time scenarios. Some quick examples:

  1. How to transform message from one format to other –for example XML to a java bean; key is without writing explicit code –instead suing the components from spring integration
  2. How to connect to FTP server by passing just the connection credential –not a single line of input output code
  3. Interact with JMS –again using adapters from spring and not custom code
  4. Send out emails
  5. Get feeds from twitter
  6. Triggering, Controlling and Monitoring Batch jobs
  7. Managing the performance of sporing integration components
  8. You will find code for each scenario which is executable –and at end there is an end to end real time scenario implementation

Check it out at amazon and packtpub. , and code samples at Github -please free to connect with me for any clarification or issues

classNotFoundException : Javax.Servlet.Jsp.Jstl.Core.Config

Are you trying to leverage JSTL tags in JSP but getting classNotFoundException? This might be the case if you are deploying your web application in tomcat (I came across this while migrating from one container to other). Many JEE containers provides this, but not tomcat.
To solve this, Include following dependency in project to fetch the jar and bundle it with library


Book review of “HTML5 & CSS3 For The Real World” By Estelle Weyl, Louis Lazaris, Alexis Goldstein

HTML and CSS for real world is a quick peak into HTML5 and CSS elements for developing modern web apps. But it for UI –do not look out for WebRtc, CORS feature etc.

This books expects familiarity with the HTML and CSS –so if it’s your first encounter with HTML and CSS, skip this book and get familiarity with those first as many a place you will find phrase “as you already know”.
Book starts nice with a bit of background and history, weighing in why HTML5 is good, how much it is supported –but then it became too theoretical, at least till chapter 5. Some visuals have been provided along with code, but I felt a lack of “hands on approach”. Chapters 6 and 7 have plenty of examples but again starting chapter 8, it weighs more towards theory.

The part I like most is that it covers compatibility across browsers quite comprehensively, augmenting it with notes, tips and tricks

Why to buy the book: If you do not know what to learn in HTML5 and CSS3 and not keen on getting your hands on reference guide –go for this book. It will give you enough steam to get you started. Cross browser compatibility have been covered thoroughly.

Why not to buy the book: If you know what to learn, this book is no better than reference guide. Practical tips and tricks help, but anyway it can be acquired as one get hands on.

Review of “The Basics of Web Hacking Tools and Techniques to Attack the Web” by Josh Pauli; O’Reilly Media

Josh Pauli, in this book tries to touch of the basics of web hacking -concepts, tools, methodologies and all. The author does a great justice providing enough pointers to start with and then delve as much deeper as ones interest.

It identifies different layers at which hacking can be done for example network layer, application layer etc., provides insight about the tools (Burp, Zed Attack Proxy, Nmap, Nessus etc.) which can be used at each layer –both free as well as paid ones, discusses what are the ways an application vulnerability can be attacked, good analogies to understand the issues better and many hands on example to try out each one of them. In fact analogies makes life much easier to understand stuff!
If you are developer and have not thought about the security issues before –it will be an eye-opener! Oh no, can this be hacked? Tools to monitor HTTP traffic (Browser extension as well as PC tools), types of XSS attack, how user’s trust and server’s trust can be fooled –many more concepts have been nicely touched upon. For advanced knowledge, author have given out an impressive list of book at the end.

One drawback –or maybe not, it’s really subjective, is that most of context is for Linux –so users working primarily with windows will have to map all linux stuff to windows parallel.

For the users who already are well versed with the tools, methodology and type of attacks -this might be a refresher, but at end it does justice for its title, BASICs.

A must have for everyone who want to understand the basic, what really a PEN test mean, want to “break” and fix application before the penetration test team does it! Have fun hacking your own website 😉

Failing unit tests with mockito

I posted a question here

Mockito will report an exception in calling class and fail the test -but it would not print the trace. Check out for two stuff:

  1. toString -can it result in NPTR? Do not print the field values blindly, have a NULLability check there.
  2. equals -While mocking, we pay not initialize the ID, for example if ID is a DB generated, then it’s NOT
    part of constructor and one can easily forget to assign it..
  3. Check for exception which can occur in calling module -may be the problem is as simple as trace not being printed!

Mock annotation returning null for mocked object

Using mockito and had written

private SomeService someService;

This was returning NULL and my test cases were failing -What was the missing element – a one liner

public class SomeClass{

Which is needed for @Mock annotation to work!

Remote debugging eclipse with tomcat

Its extremely basic -but I always miss a step or so and end up searching on google. So I though I will just Jot it down -more so for me!

  • In bin/catalina.bat add following

    set JPDA_OPTS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
  • For starting tomcat, do not use startup.bat instead navigate to bin folder from command prompt and use following command to start tomcat
    “catalina.bat jpda start”
  • If tomcat starts listening successfully -it should print a message as

    “Listening for transport dt_socket at address: 8000”
  • Next In eclipse,

    1. select the project and click on debug->debug configurations Under “Remote Java application” -create a new configuration, and then enter

      Host -> localhost

      Port -> 8000 (same as given in address for JPDA_OPTS)
    2. All set ..eclipse should be able to connect to tomcat and debug points should be enabled in webapp