How to diagnose memory leaks in java

Memory leaks doesn't have to be hard/scary/tedious problem to solve, if you follow below mentioned 3 simple steps:

Step 1: Capture baseline heap dump

You need to capture heap dump when it’s in healthy state. Start your application. Let it take real traffic for 10 minutes. At this point capture heap dump. Heap Dump is basically snapshot of your memory. It contains all objects that are residing in the memory, values stored in those objects, inbound & outbound references of those object. You can capture Heap dump can be captured using following command:

jmap -dump:format=b,file=<file-path> <pid>


pid: is the Java Process Id, whose heap dump should be captured

file-path: is the file path where heap dump will be written in to.

How to Avoid Liferay DXP Upgrading Pitfalls?

Timely upgrades can be proved a strategic move towards lifting the operational excellence to the next level. Experienced management individuals know very well that how the essential pieces of functionalities can greatly improve performance of process along with addressing the security challenges. Hence, they favor the technology upgrades anticipating reasonable amount of Return on Investment (ROI).

As Liferay DXP is a revolutionary version of Liferay enterprise portal launched in 2016, lot many organizations would rather opt for upgrading to Liferay DXP.

7 Reasons Why You Should Learn Python

Python is preferred by many developers for its strong emphasis on productivity and readability, especially when compared to other languages like Java, PHP, and C++.

Professionally, Python is great for backend web development, data analysis, artificial intelligence, and scientific computing. Here’s why Python is worth learning in 2017 and the years ahead:

Anti Cross-Site Scripting (XSS) For Java Web Application

In this tutorial, I am showing how to protect cross site scripting (xss) attacks for a java web application.

Cross-site scripting (XSS) happens, when an attacker injects malicious client sides scripts in the application.

How can we prevent Cross-site scripting (XSS)?

We can prevent xss attacks through hibernate validator’s @safehtml, which prevents HTML tags for XSS protection. @safehtml ensure that it contains no malicious code, such as embedded <script> elements.

Iterate HashMap Using Java

In this tutorial, I am showing how to iterate through a HashMap using java in different useful ways.

If you are using Java 8 for the map iteration, you can use lambda expression as like method 5.

You can also use with generics as method 3, and without generics as method 4, if you are using old versions of jdk.

Trace SOAP message Using Eclipse IDE

Trace SOAP message Using Eclipse IDE explains step by step details of How to debugging web service using Eclipse IDE.

By using Eclipse TCP/IP monitor, we can check the data flowing through TCP network. TCP/IP monitor placed intermediate to a consumer and a server. The consumer is made to contact with TCP/IP monitor, and it further send the data to the server and will shows on in its Graphical User Interface(GUI).

For example if you, created webservice is deployed using Apache CXF or Apache AXIS, you can able to monitor traffic on TCP connections by using this tool  

Jersey Bean Validation Example

Jersey Bean Validation Example explains about Jersey bean valiation both input validations and service layer validations

JAX-RS is Java API for RESTful Webservices which is very rely upon Representational State Transfer model, you can view JAX-RS specification 

JAX-RS uses annotations for simplifying the development efforts.

Now a days more & more deployment is going based on restful services compare to WSDL Webservices, due to the weights towards the simplicity of configuration

Bean Validation is a process of verifying that some data obeys one or more pre-defined constraints. The Bean Validation specification supports the use of constraint annotations as a way of declaratively validating beans, method parameters and method returned values. Below post describes support for Bean Validation in Jersey in terms of the needed dependencies, configuration, registration and usage

Reference ->

You can see the below example, which is demonstrating How to do bean validations using jersey 2

Convert Java InputStream to String

In this tutorial, I am showing how to convert Java InputStream to String using Plain Java, Java 8, Apache Commons IO library and Guava.

An InputStream is connected to some data streams like a file, memory bufferes, network connection, pipe etc. It is used for reading the data from above sources.

You can also see an example for convert Java String to InputStream (java String to InputStream).