Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

StackOverFlowError

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic