Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!

Parthiban Malayandi

Ranch Hand
+ Follow
since Apr 15, 2008
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 Parthiban Malayandi

Hi All,

I'm new to spring, I'm confused about primary attribute and autowire-candidate attribute.

Could someone explain me ?

6 years ago
Hi Rohit,

Thanks for your reply, I tried to retrieve a record using a primary key (id), which is supposed to return a unique record,still I'm getting the same exception .

Basically if I have more than one record in DB and when I retrieve a record I'm getting that exception.

Since it's a one to one mapping is Am I making a mistake ?
Hi All,

I'm learning Hibernate Framework

I did an simple example of One to One Mapping and when I try to select a row I'm getting an exception

Please find the programs I'm using

The Exception I'm getting is

How ever I'm not getting that exception if I un comment the following the tester program

//SchemaExport export = new SchemaExport(config);

Can somebody let me know what is the problem ?

Thanks in advance
Hi Santhosh,

The mistake I made was
instead of

I changed It and it works fine now.Thanks
Hi All,

I'm following book "Hibernate made easy" book and trying to compile my first Hibernate program.

I have configured classpath and path with appropriate library files and I'm not getting any compilation errors but I'm getting the below error when I try to run it

My config file

Simple Class

Runtime Error

Could you guys please let me know what is the problem ?

Thanks in advance
Hi all,

I have just started to learn Spring MVC and learned about formBackingObject method.

I have wrote a simple program to understand the concept .


Person Class

I came to know that formBackingObject is called twice ( first time when form is loaded with GET request and when it is submitted with POST method) but every time I'm getting null values
when I print the Person object where as I'm getting values in onSubmit method.

Can you please explain what is the significance of formBackingObject method ?

Thanks in advance
9 years ago
Hi all,

I learned about cookie so tried to create a one and found that getMaxAge is not worked as I expected.

I setMaxAge to two minutes and I expect when I call getMaxAge it will return two but it didn't instead it always returns -1 .

What is wrong with my code ?


Please clarify me why it always returns -1
10 years ago
Hi AJ,

Thanks for your reply.First of all sorry for the delayed response from my side. I tried as you said(Implementing Serializable interface in HttpSessionActivationListener class) and I'm getting "SessionDidActivated" message but not when I expected.

Here's the Scenario when I'm getting SessionDidActivated

When I stop Tomcat instance (say for example currently "Tomcat Instance 1" is serving the request) after hitting "SessionExample" Servlet (mapped as "/") as I said I'm getting "SessionWillPassivate " message . When I start the same Tomcat instance again I'm getting "SessionDidActivated" message.

What I Thought

After stopped the Tomcat instance I reloaded the same page expecting this time it will served by another Tomcat instance(say "Tomcat Instance 2" and I will get "SessionDidActivated" message since the session will be migrated.

As I expected the page is served by another Tomcat instance but the session is not migrated and I'm not getting "SessionDidActivated" in the new Tomcat instance.

I also created a new Servlet named as (Servlet3) and modified so that It contains button and when it clicked it will hit a new Servlet(Servlet 3) to test this instead of reloading the same page but it also doesn't help.

Modified Source codes

Modified Listener class

Added in web.xml


I'm trying this in a single physical machine with two tomcat instance configured with Apache Http Server .

Is anything I'm missing ? Will it work ?

Thanks for your patience for reading lengthy post .

10 years ago
This is what I did


JSP File

My Web.xml File

That is URL I used to configure Apache with Tomcat for Load balancing .

Please clarify me.
10 years ago
Hi all,

I studied about HttpSessionActivation Listener and in order understand it fully I created a simple program . I studied that the listener will be invoked whenever session attribute is migrated from one JVM to another .

The following was what I did to understand HttpSessionActivationListener

Created two instances of Tomcat in a single box.(Actually two services)

Configured Apache Http Server to point the two instances (Load balancing and fail over)

Created a small web application and deployed in two servers

Whenever I stop once instance I'm getting a message "Session Will Passivated "(which is what I have in overridden sessionWillPassivate method)

but I'm not getting "Session Did Activated" message (overridden in sessionDidActivated method) .

Please clarify me why I'm not getting Activated method message .

Thanks in advance

10 years ago
Vijitha, Thanks for your clarification
10 years ago
Hi Ulf,

Thanks for correcting my mistake and helped me to understood exactly what happens.

I understood that init() mehod not necessarily will be called just before service() method .

Rahul Kumar Tiwari wrote: I am calling distroy() method within the init() method but servlet service() method is running why ?

For Rahul the service method is called because he explicitly invoked a servlet(which is a request to a web container).
what I understood is correct ?

please clarify me.

Once again thanks for correcting my mistake.

10 years ago
Hi Rahual,

You are calling destroy() inside init but to use that, you are invoking servlet which is a REQUEST to a Web Container . so what happens is in order to respond to your request the servlet will be initalised(init) and service () method is invoked to do that. so the point is WHENEVER you are hitting a servlet means it is request, so service() method will be invoked to process your request .

10 years ago

Tim Hagberg wrote: My first assumption was that these servlets were being destroyed after every use, and thus the init method was being called every time one of the respective actions was performed, however I can't find any evidence of destroy methods being called. Has anyone seen anything like this, and are there easy ways to find out if a servlet is being destroyed before the container is shut down?

Hi Tim,

We have init and destroy methods which serves the purpose but it is invoked whenever a servlet instance is created (Only once if it's the FIRST Request since at that time we won't be having any instance for THAT servlet ) and destroyed .NOT for every servlet Request.

For every request the SAME servlet instance is used with a NEW Thread.

As same with init, destroy method will also be called only if don't have any request for that particular Servlet INSTANCE

Following is the extract form API

Called by the servlet container to indicate to a servlet that the servlet is being taken out of service. This method is only called once all threads within the servlet's service method have exited or after a timeout period has passed. After the servlet container calls this method, it will not call the service method again on this servlet.

This method gives the servlet an opportunity to clean up any resources that are being held (for example, memory, file handles, threads) and make sure that any persistent state is synchronized with the servlet's current state in memory.

Hope this will clear your doubt.

10 years ago
Hi Ulf,

I found where is the problem . Actually I download Tomcat in zip format and used it. Later I created it as service in Windows (using 'sevice install' command ) to configure it to Apache Http Server.

When I use this as service with Apache Http server it's not serving the dynamic things(servlets and JSP) but If I start it as standalone Tomcat using batch file(startup.bat) It's works well.

I even tried logged as administrator but it didn't help .

I guess I need to add some permission to the service which I created for Tomcat.

Can you tell me how to add permissions for the Tomcat instance service in Windows ?
10 years ago