Hi, I wanted to know if it is alright to instantiate a javabean? I am not sure if this is the right forum for this question. I am accessing the methods of a bean from a servlet. The servlet is throwing StackOverFlow Error. Also, I am creating instances of the bean in the servlet with the new() operator. The codes are developed by someone else in the past and now we are struggling to rectify this StackOverFlow Error. I've read somewhere that beans don't have explicit constructors, but ours has one. Is this constructor thing is what is causing the StackOverFlow Error? I am not able to figure out.
Any help will be of great help.
RAGHU<br /> <br />"When the going gets tough, the tough get going"
With "bean" do you mean an EJB (Enterprise Java Bean) or a regular Java bean?
You should never instantiate EJBs yourself, the EJB container takes care of the lifecycle of EJBs and normally you look them up via JNDI if you need to access them in a servlet.
Regular Java beans are something entirely different; they are just simple Java classes and you can use them as you like in your servlet.
To solve your StackOverflowError, you should look at the stack trace of the error to see where exactly in your code it happens. This kind of error usually happens if you have an endless recursive loop in your program, so you might want to check your code for recursive calls.