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

What is polymorphism in java

$
0
0

“Subtype polymorphism, often referred to as simply polymorphism in the context of object-oriented programming, is the ability to create a variable, a function, or an object that has more than one form.” – Wikipedia In more simple words, polymorphism is the ability by which, we can create functions or reference variables which behaves differently in [...]

[SOLVED] org.hibernate.ObjectNotFoundException: No row with the given identifier exists

$
0
0

Reason: This exception is thrown when you try to load an entity in hibernate with session.load() method and entity is not found. Exception trace look like this: Hibernate: select department0_.ID as ID0_0_, department0_.NAME as NAME0_0_ from DEPARTMENT department0_ where department0_.ID=? org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [hibernate.test.dto.DepartmentEntity#11] at org.hibernate.impl.SessionFactoryImpl$1.handleEntityNotFound(SessionFactoryImpl.java:375) at org.hibernate.proxy.AbstractLazyInitializer.checkTargetState(AbstractLazyInitializer.java:79) at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:68) [...]

Hibernate OSCache configuration example tutorial

$
0
0

OSCache is a Java framework developed by OpenSymphony that makes it easy to cache content in Web applications. With hibernate, it can be configured to act as second level cache. In my previous post, we learned about configuring EhCache with hibernate, which is default second level cache in hibernate. In this post, I am taking [...]

Automatic resource management with try-with-resources in java 7

$
0
0

Java 7 has brought some very good features for lazy java developers. Try-with-resources is one of such feature which cuts line of code and also make the code more robust. In this tutorial, I will discuss things around this feature. Sections in this post: The old way of resource cleanup (Before java 7) The new [...]

When to use CountDownLatch : Java concurrency example tutorial

$
0
0

As per java docs, CountDownLatch is a synchronization aid that allows one or more threads to wait until a set of operations being performed in other threads completes. CountDownLatch concept is very common interview question in java concurrency, so make sure you understand it well. In this post, I will cover following points related to [...]

5 popular java development frameworks

$
0
0

There are plenty of Java frameworks available on the web, and developers use them quite frequently to build websites. These frameworks offer lots of functions and reduce the working hours by leaps and bounds. These frameworks make the coding process faster, thanks to their inbuilt modules and functions. Sometimes too many options can confuse you [...]

How to generate secure password hash : MD5, SHA, PBKDF2, BCrypt examples

$
0
0

A password hash is an encrypted sequence of characters obtained after applying certain algorithms and manipulations on user provided password, which are generally very weak and easy to guess. There are many such hashing algorithms in java also, which can prove really effective for password security. In this post, I will discuss some of them. [...]

How to view/generate bytecode for a java class file

$
0
0

Many times, we need to understand what a compiler is doing under the hood. How java statements we are writing, will be reordered and executed. Also, we need to see the byte code for learning purpose also, I do it seldom. In this tutorial, I am giving an example of how to generate the byte [...]

JAX-RS 2.0 RESTEasy 3.0.2.Final security tutorial

$
0
0

The new RESTEasy version 3.0.2 final has been recently released and is made compatible with JAX-RS 2.0. If you remember that previous JAX-RS releases had no specification regarding implementing filters and interceptors. That’s why all JAX-RS implementations had their own flavors. e.g. RESTEasy had PreProcessorInterceptor and PostProcessorInterceptor. PreProcessorInterceptor and PostProcessorInterceptor are deprecated now. Now JAX-RS [...]

Internationalization (i18n) support in spring 3 example tutorial

$
0
0

Internationalization is the process of designing a software application so that it can be adapted to various languages and regions without engineering changes. The term is frequently abbreviated as i18n (where 18 stands for the number of letters between the first i and last n in internationalization). Above definition essentially means making changes in your [...]

JAXB exmaple: Marshalling and Unmarshalling list or set of objects

$
0
0

We know that JAXB(Java Architecture for XML Binding) allows Java developers to map Java classes to XML representations. JAXB provides two main features: the ability to marshal Java objects into XML and the inverse, i.e. to unmarshal XML back into Java objects. JAXB mostly is used while implementing webservices or any other such client interface [...]

[Solved]: javax.xml.bind.JAXBException: class java.util.ArrayList nor any of its super class is known to this context

$
0
0

This exception occur when you are using JAXB to marshal a java object (collection type) to xml format. The stack trace looks like this: Exception in thread "main" javax.xml.bind.JAXBException: class java.util.ArrayList nor any of its super class is known to this context. at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getBeanInfo(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsRoot(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(Unknown Source) at [...]

[Solved]: Exception in thread “main” com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 3 counts of IllegalAnnotationExceptions

$
0
0

This exception occur when you are using JAXB to marshal a java object (collection type) to xml format. The stack trace looks like this: Exception in thread "main" com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions Class has two properties of the same name "employees" this problem is related to the following location: at public java.util.List com.howtodoinjava.jaxb.examples.list.Employees.getEmployees() at [...]

JAXB example: Marshalling and Unmarshalling HashMap in java

$
0
0

We know that JAXB(Java Architecture for XML Binding) allows Java developers to map Java classes to XML representations. JAXB provides two main features: the ability to marshal Java objects into XML and the inverse, i.e. to unmarshal XML back into Java objects. JAXB mostly is used while implementing webservices or any other such client interface [...]

[SOLVED] java.lang.ClassNotFoundException: org.glassfish.jersey.client.JerseyClientBuilder

$
0
0

If you are using RESTEasy 3.x.y which has been support for JAX-RS 2.0, and you are trying to write RESTEasy client then you can face this exception. Full stack trace might look like this: Exception in thread "main" java.lang.RuntimeException: java.lang.ClassNotFoundException: org.glassfish.jersey.client.JerseyClientBuilder at javax.ws.rs.client.ClientBuilder.newBuilder(ClientBuilder.java:103) at test.jaxrs2.Demo_JAXRS_2_Example.main(Demo_JAXRS_2_Example.java:14) Caused by: java.lang.ClassNotFoundException: org.glassfish.jersey.client.JerseyClientBuilder at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) [...]

JAX-RS 2.0 RESTEasy 3.0.2.Final Client API example

$
0
0

JAX-RS 2.0 has brought lots of improvement over previous version. One of major improvement is client API which was completely missing in JAX-RS 1.0. While it was easy to write a portable JAX-RS service, each JAX-RS implementation defined their own proprietary API. JAX-RS 2.0 fills in this gap with a fluent, low-level, request building API. [...]

Enable gzip compression content encoding in RESTEasy

$
0
0

JAX-RS Resteasy has automatic GZIP decompression support. If the client framework or a JAX-RS service receives a message body with a Content-Encoding of “gzip”, it will automatically decompress it. The client framework automatically sets the Accept-Encoding header to be “gzip, deflate”. So you do not have to set this header yourself. To use gzip compression, [...]

Struts 2 hello world example application

$
0
0

In my previous posts, I have written many examples and tutorials on JAX-RS RESTEasy, Spring 3, Hibernate and other java frameworks e.g. maven or junit. I got many requests to write something on struts 2 also. Well, Here I am starting with hello world example. In next posts, I will try to cover maximum areas [...]

Hibernate @NaturalId example tutorial

$
0
0

Hibernate 4 has bring lots of improvements and @NaturalId is one of such nice improvements. As you know @Id annotation is used as meta data for specifying the primary key of an entity. But sometimes, entity is usually used in DAO layer code with id which not not primary key but its logical or natural [...]

Hibernate 4 example to get entity reference for lazy loading

$
0
0

By Wikipedia definition, Lazy loading is a design pattern commonly used in computer programming to defer initialization of an object until the point at which it is needed. We know that in hibernate lazy loading can be done by specifying “fetch= FetchType.LAZY” in hibernate mapping annotations. e.g. @ManyToOne ( fetch = FetchType.LAZY ) @JoinColumns( { [...]
Viewing all 768 articles
Browse latest View live