Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!

swaraj gupta

Ranch Hand
+ Follow
since Oct 22, 2010
swaraj likes ...
C++ Java Oracle
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by swaraj gupta

Hello Tim,

Following what you have said as an answer to point # 5 and #6, I believe that following combination should work:

7. Spring Application + JPA(using JPA jar)+ Spring Data JPA(using spring-data-jpa jar) + Hibernate:  JPA to prototype the functions, Spring Data JPA for additional features of Repositories and a JPA implementation(Hibernate etc) as a concrete implementation to JPA.

Thank you Jasper and Tim for your replies and clearing up a lot of my confusion around JPA and its implementations.

I just tried to summarize the discussion here with the help of following points. kindly correct me if anything which I have stated here is not correct.

1. Java Application(Non Spring Application) + Hibernate: It's a tightly coupled Java application with Hibernate. And, in case tomorrow if it would be required to change the JPA implementation then we may need to make the changes in our java application code as well.

2. Java Application(Non Spring Application) + JPA(using JPA jar) + Hibernate: Here, ideally we should be using the method signatures provided by the JPA in our Java application. However, at runtime the JPA implementation provided by Hibernate will be used. And in case if it would be required to change the JPA implementation i.e. Hibernate then it will be required to change the Hibernate jars with some other JPA implementation jars only.

3. Spring Application(without JPA jar) + Hibernate: It's a tightly coupled Spring application with Hibernate and changing the JPA implementation may not be the matter of changing the jars only. It may be required to change the application code as well.

4. Spring Application + JPA(using JPA jar)+ Hibernate: Here, we should be using the method signatures provided by JPA. However, at runtime the JPA implementation provided by Hibernate will be used. But in case if it would be required to change the JPA implementation, then it will be required to change the hibernate jars with some other JPA implementation jars only.

5. Spring Application + Spring Data JPA(using spring-data-jpa jar): This combination can be used but will fail at runtime due to the absence of concrete JPA implementation in our classpath and hence can not be used to access the relational database.

6. Spring Application + Spring Data JPA(using spring-data-jpa jar) + Hibernate: Spring Data JPA is another layer of abstraction or wrapper on top of JPA with some additional interfaces which further reduces our coding efforts required to access any relational database. But under the hood Spring Data JPA uses the core interfaces of JPA having their implementation provided by any of its implementation like Hibernate, Toplink, EclipseLink etc.

Thanks for your reply Jesper. But I am still a bit confused on the following points. If you could clarify or confirm my doubts here.

1. Is there any such thing exists, which is called 'Spring JPA'? or it is that some people used to abbreviate 'Spring Data JPA' as 'Spring JPA' only?

2. When we say:

The Spring Framework consists of a collection of projects, and one of these projects is Spring Data.

Can we say that:
2.1 'Spring Data' project of Spring is totally an independent project of Spring, and has nothing to do with JPA specification?
2.2 'Spring Data' is not an API specification?
2.3 'Spring Data' alone could be used for dao operations as we use Hibernate.


If you are using the Spring Framework for your application, you will most likely want to use Spring Data JPA together with Hibernate.

3.1 Does that mean 'Spring Data JPA' is a specification or api like JPA that we are using it together with Hibernate which is a JPA implementation?
3.2 In case if 'Spring Data JPA' is a specification or api like JPA then why 'Spring  Data JPA' api is written when JPA specification was already in place?


I have been going through lots of tutorials and blogs available over internet regarding JPA. And after reading a handful of blogs on internet, I am badly confused between these terms.

Could you please help me out with my confusion that I can move ahead with my learning?

1. JPA
2. Spring JPA
3. Spring Data JPA
4. Hibernate

Java SE 7 Docs: When the intern method is invoked, if the pool already contains a string equal to this String object as determined by the equals(Object) method, then the string from the pool is returned. Otherwise, this String object is added to the pool and a reference to this String object is returned.

My query is regarding the statement in bold: Otherwise, this String object is added to the pool and a reference to this String object is returned.

I tried a sample java program and realized that on invoking intern over a String object (created via new operator), a new String object is created in String Literal Pool and its reference is returned.

It seems like a new object is created on calling intern() over s1, having its reference returned to variable on stack s4 and added to String Literal Pool table as well.

Please help, where am I getting wrong ?
Hello everyone,

I am new to Spring framework, and constantly enriching my knowledge in it.

Well I got stuck at a point, where I want to pool my web-service client object, and for the same I have made the following configurations in Spring Web Context Configuration file:

Here I am printing cmrcPort in class ComClient at line 12. And I am always getting the same value of cmrcPort for multiple requests that lands on MyController. I suppose, it should come as different at least in some cases.

Here is my java code for ComClient:

I am confused if the pool is actually getting created or not as always getting the same value printed on line 12 of class ComClient .

5 years ago
Hi All,

I would like to include the response from a servlet in JSP, without calling it explicitly.
The code below works fine in my J2EE application and it calls the servlet SendChart. But I want to implement the same in Spring framework and when I use this jsp in Spring it doesn't call my Spring Servlet.

Please refer the code snippet for more clarification:




Plese help.
6 years ago

Hi all,

l am new to JBoss and JMS. I have written a code to push messages in JMS queue as:

But getting an error as:

Exception in thread "main" javax.naming.NameNotFoundException: jms not bound
at org.jnp.server.NamingServer.getBinding(
at org.jnp.server.NamingServer.getBinding(
at org.jnp.server.NamingServer.getObject(
at org.jnp.server.NamingServer.lookup(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at sun.rmi.server.UnicastServerRef.dispatch(
at sun.rmi.transport.Transport$
at Method)
at sun.rmi.transport.Transport.serviceCall(
at sun.rmi.transport.tcp.TCPTransport.handleMessages(
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(
at sun.rmi.transport.tcp.TCPTransport$
at java.util.concurrent.ThreadPoolExecutor.runWorker(
at java.util.concurrent.ThreadPoolExecutor$
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(
at sun.rmi.transport.StreamRemoteCall.executeCall(
at sun.rmi.server.UnicastRef.invoke(
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(
at org.jnp.interfaces.NamingContext.lookup(
at javax.naming.InitialContext.lookup(
at Sender.initializeSender(
at Sender.<init>(
at Sender.main(

Please help, where am I getting wrong?

Along with that I have few queries:
1> java.naming.provider.url: What do we specify in it?
2> What's the argument for lookup method specifies on line no. 44? What should I specify as its argument?

Following is the xml snippet that I have added to ./messaging/destinations-service.xml for creating the JMS queue:

6 years ago
From where should I get jboss 6 package?
Hi all !

While adding server to Eclipse it is giving the following error: "servlet3.0 wich is not available in JBoss until v6 or 7".

Following are the specification of my tools:

Eclipse: Version: Helios Service Release 2
Build id: 20110218-0911

JBoss: jboss-5.1.0.GA

Please help, what's the problem and how should I fix it ?
Hi Frit,
thanks for the reply.

The threads are not created inside the Servlet. For every request a seperate thread is created by the container. The request-threads will all access the single Servlet's instance service() method

If am not wrong, you mean to say container keeps the reference to the servlets object with it. And it uses the same object reference to call the service method for each request from client.

Is it so?
Servlet is instantiated only once, then for every subsequest request a new thread is created to serve it. My questions are:

1. How is it possible to start multiple threads on a single servlet instance.
I mean: servletInstance.start()- Why it doesn't give IllegalThreadStateExcption?

2. Which class or interface in the hierarchy of javax.servlet.http.HttpServlet extends or implents Runnable interface. Where is run() method defined, who calls it and when?
congratulations !!
7 years ago

Congratulation Swaraj

thanks Imad..,

Hi Vinoth, finally I have got the mail from Oracle and verified the information as well...
thanks Vinoth, thanks Bobby...