Quantcast
Channel: About Me
Viewing all 768 articles
Browse latest View live

How to override toString() effectively with ToStringBuilder

$
0
0

ToStringBuilder is a utility class provided by apache commons lang library. ToStringBuilder is a utility class provided by apache commons lang library. It provides a consistent and better control over what and how much data, an object should expose using toString() method and in which format. It can also help in removing the code size [...]

SOLVED: java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer

$
0
0

If you have start working on Jersey then you might face this issue while configuring it. This is the result of insufficient project dependencies on runtime. This issue is likely to be faced in tomcat server. The error log will look like this. SEVERE: Servlet /JerseyHelloWorld threw load() exception java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1713) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1558) [...]

Solved: Java compiler level does not match the version of the installed Java project facet

$
0
0

I have been facing this issue from quite long time as I didn’t took care of it. Everytime I faced this issue, I just went and changed the project compiler level for projects facets menu in eclipse. Today, I decided to end this for all. This error looks like in eclipse is as follow: Reason: [...]

JAX-RS RESTEasy Cache control with ETag example

$
0
0

ETags or entity tags are useful HTTP headers which can help in building a super fast application by minimizing the server load on system. ETag is set to the response to the client so a client can use various control request headers such as If-Match and If-None-Match for conditional requests. javax.ws.rs.core.Response.ResponseBuilder#tag() and javax.ws.rs.core.EntityTag are useful [...]

JAX-RS Jersey hello world example

$
0
0

I have written a number of posts on JAX-RS RESTEasy concepts and how to. Now I have started exploring Jersey which is another popular framework for making RESTFul applications. To start with, I am writing my hello world application in this post, which I will modify in next posts to show demos of other features [...]

5 class design principles [S.O.L.I.D.] in java

$
0
0

Classes are the building blocks of your java application. If these blocks are not strong, your building (i.e. application) is going to face the tough time in future. This essentially means that not so well-written can lead to very difficult situations when the application scope goes up or application faces certain design issues either in [...]

8 signs of bad unit test cases

$
0
0

If you have been in software development for a long time, then you can easily relate with the importance of unit testing. Experts say that most of bugs can be captured in unit testing phase itself, which eventually get passed to quality teams, IF we follow these best practices for writing junit unit tests. "It's [...]

Popular HashMap and ConcurrentHashMap interview questions

$
0
0

In my previous post related to “How HashMap works in java“, I explained the internals of HashMap class and how they fit into whole concept. But when interviewer ask you about HashMap related concepts, he does not stop only on core concept. The discussion usually goes in multiple directions to understand whether you really understand [...]

Reading/writing excel files in java : POI tutorial

$
0
0

If you are building a software for HR or finance domain, there is usually requirement for generating excel reports which are usually across management levels. Apart from reports, you can expect input data for application coming in form of excel sheets and application is expected to support it. These are many open source APIs to [...]

Complete AJAX tutorial

$
0
0

Asynchronous JavaScript and XML (AJAX) is the art of exchanging data with a server, and updating parts of a web page – without reloading the whole webpage. In other words, AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. If application are not using [...]

Implement MVC and PubSub in JavaScript

$
0
0

We know what is MVC? MVC stands for Model-View-Controller. In simple words, MVC is a design technique in which application components are divided into 3 groups so that they can be developed separately without concerning, how they will interact. If build properly, few configuration code will bind them and they will be ready to use. [...]

JAX-RS RESTEasy basic authentication and authorization tutorial

$
0
0

Security is an integral part of any enterprise application. Security involves two phases i.e. authentication and authorization. Authentication verifies who you are. Authorization verifies what you are authorized to do. In this post, we will learn to build role based basic authentication/ authorization security for REST APIs. Sections in this post: Background information Important classes/annotations [...]

Hibernate insert query tutorial

$
0
0

Hibernate is an object-relational mapping (ORM) library for the Java language, providing a framework for mapping an object-oriented domain model to a traditional relational database. This means you are not required to build and execute SQL queries for interaction with database. You just have to instruct hibernate for that by calling hibernate APIs and hibernate [...]

Understanding hibernate first level cache with example

$
0
0

Caching is a facility provided by ORM frameworks which help users to get fast running web application, while help framework itself to reduce number of queries made to database in a single transaction. Hibernate achieves the second goal by implementing first level cache. Fist level cache in hibernate is enabled by default and you do [...]

How hibernate second level cache works?

$
0
0

Caching is facility provided by ORM frameworks which help users to get fast running web application, while help framework itself to reduce number of queries made to database in a single transaction. Hibernate also provide this caching functionality, in two layers. Fist level cache: This is enabled by default and works in session scope. Read [...]

Hibernate named query tutorial

$
0
0

Named queries in hibernate is a technique to group the HQL statements in single location, and lately refer them by some name whenever need to use them. It helps largely in code cleanup because these HQL statements are no longer scattered in whole code. Apart from above, below are some minor advantages of named queries: [...]

[Solved] Initial SessionFactory creation failed.org.hibernate.HibernateException: Errors in named queries

$
0
0

While working on post “Named queries in hibernate“, I encountered this error. Hibernate entity I coded was like this: @Entity @Table(name = "DEPARTMENT", uniqueConstraints = { @UniqueConstraint(columnNames = "ID"), @UniqueConstraint(columnNames = "NAME") }) @NamedQueries ( { @NamedQuery(name=DepartmentEntity.GET_DEPARTMENT_BY_ID, query=DepartmentEntity.GET_DEPARTMENT_BY_ID_QUERY), @NamedQuery(name=DepartmentEntity.UPDATE_DEPARTMENT_BY_ID, query=DepartmentEntity.UPDATE_DEPARTMENT_BY_ID_QUERY) } ) public class DepartmentEntity implements Serializable { static final String GET_DEPARTMENT_BY_ID_QUERY = "from Department [...]

Hibernate EhCache configuration tutorial

$
0
0

Caching is facility provided by ORM frameworks which help users to get fast running web application, while help framework itself to reduce number of queries made to database in a single transaction. Hibernate also provide this caching functionality, in two layers. Fist level cache: This is enabled by default and works in session scope. Read [...]

How to define Path in java NIO

$
0
0

As we know, that Path class, introduced in the Java SE 7 release, is one of the primary entry points of the java.nio.file package. If your application uses NIO, you should learn more about the powerful features available in this class. I am beginning the NIO tutorials with defining Path in NIO 2. In this [...]

Useful java collection interview questions

$
0
0

Without argument, java collections is one of the most important area where you will be tested in any position whether junior or senior. The scope is so much wide, that its almost impossible to cover all the questions. Yet based on my previous interviews, I am attempting to put as many as possible GOOD interview [...]
Viewing all 768 articles
Browse latest View live