Meaningless Drivel is fun!*
The moose likes Struts and the fly likes BeanUtil Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "BeanUtil Exception" Watch "BeanUtil Exception" New topic
Author

BeanUtil Exception

Mark Reyes
Ranch Hand

Joined: Jul 09, 2007
Posts: 426
Hi Everyone,

I am having a problem trying to submit my JSP. It causes an Exception

javax.servlet.ServletException: BeanUtils.populate
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:469)
org.apache.struts.chain.commands.servlet.PopulateActionForm.populate(PopulateActionForm.java:50)
java.lang.IllegalArgumentException: No bean specified
org.apache.commons.beanutils.PropertyUtilsBean.getPropertyDescriptor(PropertyUtilsBean.java:751)


My JSP looks like this:




And here is my form. My form has a Data Bean Attribute



My field StripMap references a POJO class.




Basically I'm trying to display a table with checkbox in it and during the first time that my JSP load, everything went fine and it displays what I have expected. The problem is when I am submitting the form, it causes the exception.

My Mainform is in request scope. I have read the Struts FAQ regarding changing my object into STRING but I dont know how will I implement such. Is it not advisable to use Bean Object into ActionForm and should I just place all my StripMap property directly into the actionform?

Thanks for the help..


Sean Clark ---> I love this place!!!
Me ------> I definitely love this place!!!
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
It's OK to reference a bean property in a Struts tag, but the bean must be instantiated. Struts won't instantiate it for you. Therefore change the declaration of the stripMap property in MainForm to:


Merrill
Consultant, Sima Solutions
Mark Reyes
Ranch Hand

Joined: Jul 09, 2007
Posts: 426
Hi Merill,

Thanks for the help as always. I miss that instantiation part..

I'm just wondering, while trying to solve my problem, I browse into the Search of previous struts post and found some good advise regarding this exception.

One of which is to place my actionform into session scope instead of the request scope. I have tried it and it worked fine. But I am not into session scope and would prefer request scope.

Does it mean when I place my actionform into session scope, Struts takes care of all the instantiation of every databean in my form? Thanks again..
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Originally posted by mark reyes:
Does it mean when I place my actionform into session scope, Struts takes care of all the instantiation of every databean in my form?

No, it doesn't. The same rules apply. The only difference is that once you instantiate a property of a session-scoped bean, it stays instantiated as long as the user remains signed on. With a request-scoped bean, the properties have to be re-instantiated with every new request.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: BeanUtil Exception