No Bean Specified error in Struts

Discussions

General J2EE: No Bean Specified error in Struts

  1. No Bean Specified error in Struts (16 messages)

    Hi,

    I am using an action to both load and update a web form. The form load works fine. I get to see the data. While the form submit gives me the following exception
    java.lang.IllegalArgumentException: No bean specified

    I am setting the form in the request scope within execute method of action class during form load. Please help ASAP.
    Here are the struts config related to the action and jsp set up.

    <form-bean name="userProfileSummaryForm" type="com.phcs.deladmin.forms.UserProfileSummary">
    </form-bean>

    <action path="/editAddUser" type="com.phcs.deladmin.actions.EditAddProfileAction" name="userProfileSummaryForm" validate="true" scope="request">
    <forward name="success" path="edit.def"> </forward>
    </action>

    JSP code
    <html:form action="editAddUser">
    <table width="80%" border="1" align="center">
    <tr><td width="50%">
    <table width="100%">
    <tr>
    <td align="right" width="15%"><font class="labelBold">First Name</font></td>
    <td width="30%"><html:text property="userProfileSummary.firstName"/></td>
    </tr>
    <tr><td colspan="3" align="center">
    <html:submit property="continue" value="Continue" onclick="processForm('continue')"/>&nbsp;&nbsp;&nbsp;&nbsp;
    <html:button property="cancel" value="Cancel" onclick="processForm('cancel')"/>&nbsp;&nbsp;&nbsp;&nbsp;
    <html:button property="clear" value="Clear" onclick="processForm('clear')"/>
    </td></tr>
    </table>
    </td></tr>
    </table>
    <html:hidden property="USER_ACTION" value="SUBMIT"/>
    </html:form>

    Threaded Messages (16)

  2. Hi,I am using an action to both load and update a web form. The form load works fine. I get to see the data. While the form submit gives me the following exception java.lang.IllegalArgumentException: No bean specifiedI am setting the form in the request scope within execute method of action class during form load. Please help ASAP.Here are the struts config related to the action and jsp set up.<form-bean name="userProfileSummaryForm" type="com.phcs.deladmin.forms.UserProfileSummary"></form-bean><action path="/editAddUser" type="com.phcs.deladmin.actions.EditAddProfileAction" name="userProfileSummaryForm" validate="true" scope="request"> <forward name="success" path="edit.def"> </forward></action>JSP code<html:form action="editAddUser"><table width="80%" border="1" align="center"> <tr><td width="50%"> <table width="100%"> <tr> <td align="right" width="15%"><font class="labelBold">First Name</font></td> <td width="30%"><html:text property="userProfileSummary.firstName"/></td> </tr> <tr><td colspan="3" align="center"> <html:submit property="continue" value="Continue" onclick="processForm('continue')"/>&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; <html:button property="cancel" value="Cancel" onclick="processForm('cancel')"/>&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; <html:button property="clear" value="Clear" onclick="processForm('clear')"/> </td></tr> </table> </td></tr></table><html:hidden property="USER_ACTION" value="SUBMIT"/></html:form>



    Hi,
      My suggestion is that you could have problem with the property you have specified.In the struts-config.xml you specified an upper case letter U for "userProfileSummary",whereas in the property you have specified U in lower case letter,pls check it out.


    <td width="30%"><html:text property="userProfileSummary.firstName"/></td>


    (or)

    pls checkout whether the name in the getter and Setter methods of the firstname in the form class is userProfileSummary.firstName.

    I hope your form class must be like this

    public class UserProfileSummary extends ActionForm {

     /**
        * @return Returns the firstName.
        */
        public String getFirstName() {
            return firstName;
        }
        /**
        * @param firstName The firstName to set.
        */
        public void setFirstName(String firstName) {
            this.firstName=firstName;
        }
        /**
    }

    If so its enough if you specify like the following in the jsp

    <td width="30%"><html:text property="firstName"/></td>


    cheers,
    Priya.R
  3. Hi,

    Thanks for the reply. The case for the form attribute in action-mapping is correct. I have checked it several times.
    Inside the userProfileSummaryForm, I have the following properties with getter and setter functions.
    private UserProfileSummaryVO userProfileSummary;
    private String USER_ACTION;

    And the UserProfileSummaryVO has getter and setter functions for all variables - Like the following

    public String getFirstName() {
    return firstName;
    }
    public void setFirstName(String firstName) {
    System.out.println("Inside setFirstName()");
    this.firstName = firstName;
    }

    I do not see any mismatch with getter and setter functions. Neither can I find any missing map-form xref. Pls help me out.
  4. You need to have a getUserProfileSummary() and setUserProfileSummary() on your ActionForm class which should return an instance of the UserProfileSummaryVO.

    OR

    the getters and setters in your Action form class need to return UserProfileSummaryVO.getXXXX - Not recommended

    OR

    You should have the parameters + getters + setters at the ActionForm level and transfer the values into the VO in your ActionClass
  5. Inside the userProfileSummaryForm, I have the following >>properties with getter and setter functions.
    >>private UserProfileSummaryVO userProfileSummary;

    try removing the setter for UserProfileSummaryVO

    Gook luck
    Albert
  6. I have figured out a solution. Although I do not know the root cause of it. All I did was to store the UserProfileSummaryVO object in request scope. Then within the jsp I declare it as bean:define and then the html input was modified as follows
    <html:input bean="userProfileSummary" property="lastName" value='<%=userProfileSummary.getLastName()%>'>

    This works for both form pre-load and post.
  7. Could you elaborate on your fix? I am getting the same error using Struts nested tags, but I tried your fix without the nested tags and still get the error. I have an urgent need for this fix! It is so ludicrous to me that the nested or any other Struts tags should perform properly for web page display but not submission. Makes me doubt Struts entirely. -Joe
  8. This error is usually caused by a bean within form that is not initialized. Within you reset method add a constructor call myUserBean = new MyUserBean(); If there is an Address bean within myUserBean and it is referenced by struts tag like you need to init that property as well myUserBean.setAddress(new Address()); Take care Roman
  9. Hi,

    I have a getUserProfileSummary() and setUserProfileSummary() inside the ActionForm. As I mentioned earlier, I only get this exception during submit. While loading the form with pre-populated data in the form, I do not get any error. This means that the getter methods definitely work.
    Help please.
  10. Like suggested earlier, you just need to use <html:text property="firstName"/> instead of <html:text property="userProfileSummary.firstName"/>

    If you use <html:text property="userProfileSummary.firstName"/>, you're telling Struts that your form bean has a UserProfileSummary. That is,

    class UserProfileSummary extends ActionForm {
      private UserProfileSummary ups;
      UserProfileSummary getUserProfileSummary()
      void setUserProfileSummary(UserProfileSummary ups)
    }

    I doubt this is the case.

    Since you're nesting your html:text tag within an html:form tag that references an action mapping involving a UserProfileSummary form bean, the html:text tag automatically knows that you're using a UserProfileSummary form bean. You don't need to explicitly state which form bean you're using.
  11. Oops[ Go to top ]

    Sorry, I just noticed you said you have a getUserProfileSummary() method within your UserProfileSummary class. Maybe you could try flattening out your form bean...have getFirstName() and setFirstName() methods, and then assemble a UserProfileSummary bean from the form in your Action or Validate method or something.
  12. I do not think that by moving the properties from value object to action form will solve the problem or even related to the problem. The form load works fine, which explains that the property relationships are properly set. The error occurs only during form submit, which is completely absurd to me.
  13. Solution[ Go to top ]

    I came across the same problem with you recently.And finally,i solved it. The problem is then initiation of your value object.You should initiate it at your actionForm like salaryVO salVO=new salaryVO();
    This works well.
  14. I came across the same problem with you recently.And finally,i solved it. The problem is then initiation of your value object.You should initiate it at your actionForm like salaryVO salVO=new salaryVO();This works well.

    I am getting the same IllegalArgumentException:no Bean Specified.

    I have an ActionForm 'permitForm' & two actions submitAction & retrieveAction. retrieveaction is working fine,but when I submit the form for submitAction ,I am getting this error.

    could you give me an example for this .

    Thanks
  15. other suggestions?[ Go to top ]

    any other suggestions on whats causing this error? im getting the same error too, and have tried all the solutions above

    thanks
  16. "http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?
    > ubb=get_topic&f=58&t=008312"

    I am presently working on remediation from struts 1.0 to struts 1.2.8. Application is currenty working nicely on struts 1.0. I have deployed the application successfully in struts 1.2.8. I have one screen where i am using same action and action form to load and save the data. Loading the page is happening properly but when i click on save i am getting the following error.

    java.lang.IllegalArgumentException: No bean specified
    at org.apache.commons.beanutils.PropertyUtils.getPropertyDescriptor(PropertyUtils.java:819)
    at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:846)
    at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:726)
    at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:493)
    at org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:804)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:225)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:127)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:272)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:165)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3153)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:1973)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1880)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1310)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:179)

    If anybody has faced the same problem and able to solve the problem, Please help me out. Thanks in advance.
  17. Hi, I have faced similar exception and it has been resolved as follows. * Override the reset method of ActionForm and initialize all your objects used in your bean. For eg., Employee e; has been used then initialize it in the reset method as Employee e = new Employee();