No getter method for property

No getter method for property
       60 point fra fredand      

 X
Hello!

I have ran into a strange problem. (To me it looks strange beacuse this should be easy to solve, but perhaps I'm blind)

This is a small app that I use for testing at home.

The error I get is:

javax.servlet.jsp.JspException: No getter method for property name of bean AddNameFormWebService

Usally this means that I refer to a member in the Form-class with wrong method-name. In this case getName I guess?

To me this there is no method named getName in class AddNameFormWebService.

First this part works with a similar structure:
<html:form action="/AddNameActionEJB" method="post" >
    <html:errors/>
   
    <table border="0">
        <tr>
            <td align="right">
            <html:submit>Add Name</html:submit>
        </td>
        <td align="left">
            <html:text property="name" size="30" maxlength="30"/>
        </td>
    </tr>
        <tr>
            <td>
                &nbsp;
            </td>
            <td>
                <textarea name="namestextarea" cols="35" rows="5">
                    <logic:empty name="AddNameFormEJB" property="names">AddNameFormEJB - No names available</logic:empty>
                    <logic:notEmpty name="AddNameFormEJB" property="names">
                        <logic:iterate name="AddNameFormEJB" property="names" id="AddNameFormEJB">
                            <bean:write name="AddNameFormEJB" property="name"/>
                        </logic:iterate>
                    </logic:notEmpty>
                </textarea>
            </td>
        </tr>
    </table>
</html:form>

The Form class looks like:

package nameswebapplication.controller.form;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.*;

public class AddNameFormEJB extends ActionForm
{
    static final long serialVersionUID = 1l;
    private String name = null;
    private List names = null;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List getNames() {
        return names;
    }

    public void setNames(List names) {
        this.names = names;
    }
}

The above works fine.

But this do not work:

<html:form action="/AddNameActionWebService" method="post" >
    <html:errors/>
   
    <table border="0">
        <tr>
            <td align="right">
            <html:submit>Add Name</html:submit>
        </td>
        <td align="left">
            <html:text property="name" size="30" maxlength="30"/>
        </td>
    </tr>
        <tr>
            <td>
                &nbsp;
            </td>
            <td>
                <textarea name="namestextarea" cols="35" rows="5">
                    <logic:empty name="AddNameFormWebService" property="names">AddNameFormWebService - No names available</logic:empty>
                    <logic:notEmpty name="AddNameFormWebService" property="names">
                        <logic:iterate name="AddNameFormWebService" property="names" id="AddNameFormWebService">
                            <bean:write name="AddNameFormWebService" property="name"/>
                        </logic:iterate>
                    </logic:notEmpty>
                </textarea>
            </td>
        </tr>
    </table>
</html:form>

This Form class looks like:

package nameswebapplication.controller.form;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.*;

public class AddNameFormWebService extends ActionForm
{
    static final long serialVersionUID = 1l;
    private String name = null;
    private List names = null;
   
    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public List getNames()
    {
        return names;
    }

    public void setNames(List names)
    {
        this.names = names;
    }
}

Pretty much the same.

The row where it goes wrong is:
<bean:write name="AddNameFormWebService" property="name"/>

If you can spot the reason please let me know!

Best regards
Fredrik
fredand44Asked:
Who is Participating?
 
brunoguimaraesCommented:
Apparently everything is right. Unless we're missing something.

You could try a few things:

1 - Clean your webserver's cache and temporary files, recompile the application and try again.
2 - Use <c:out> instead of <bean:write>.
3 - Add another property in your AddNameFormWebService bean and try to print it using <bean:write>

Sorry I couldn't be more helpful.
0
 
brunoguimaraesCommented:
Check if there is something missing in your struts-config.xml
0
 
fredand44Author Commented:
Hello!

Thanks for your fast reply!

I have checked it and correct me if I'm worng when I say that there is 2 areas that needs to be set:
The fom beans:

   <form-beans >
           <form-bean name="AddNameFormEJB" type="nameswebapplication.controller.form.AddNameFormEJB" />
           <form-bean name="AddNameFormWebService" type="nameswebapplication.controller.form.AddNameFormWebService" />
   </form-beans>

The actions:
      <action
         path="/AddNameActionEJB"
         name="AddNameFormEJB"
         scope="request"
         type="nameswebapplication.controller.action.AddNameActionEJB"
         validate="true">
         <forward name="success" path="/index.do" />
      </action>
     
      <action
         path="/AddNameActionWebService"
         name="AddNameFormWebService"
         scope="request"
         type="nameswebapplication.controller.action.AddNameActionWebService"
         validate="true">
         <forward name="success" path="/index.do" />
      </action>

This should do the trick if I'm not right.
But there must be something that I have messed up.
/Fredrik
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
fredand44Author Commented:
Hello!
Still same problem.

Removed it all from my webserver and restarted it. (Wls 8.1.6)
Rebuild it with:

public class AddNameFormWebService extends ActionForm
{
      static final long serialVersionUID = 1l;
      private String name = null;
      private List names = null;
      
      String hello = "hello";
      
      public String getName()
      {
            return name;
      }

      public void setName(String name)
      {
            this.name = name;
      }
      
      public String getHello()
      {
            return hello;
      }

      public void setHello(String hello)
      {
            this.hello = hello;
      }.....

Also changed the jsp to:

                                                            <logic:empty name="AddNameFormWebService" property="names">AddNameFormWebService - No names available</logic:empty>
                                                            <logic:notEmpty name="AddNameFormWebService" property="names">
                                                                  <logic:iterate name="AddNameFormWebService" property="names" id="AddNameFormWebService">
                                                                        <bean:write name="AddNameFormWebService" property="hello"/>
                                                                  </logic:iterate>
                                                            </logic:notEmpty>

Deployed it again.

But I still get the same error:

No getter method for property hello of bean AddNameFormWebService

Very strange since I have en other example that works fine as I mentioned above.

So if you guys get any ides, please let me know!

Best regards
Fredrik

0
 
brunoguimaraesCommented:
You could try on a different webserver, like JBoss or Glassfish, just in case.

Well, if I have a better idea, I'll let you know.
0
 
fredand44Author Commented:
Hello!

Stupid me!

It turned out that in the list put into "public void setNames(List names)" at AddNameFormWebService was a List of String.

In my other form it was a List of objects of class myapp.Name with a method called getName.

Thank you all!

Best regards
Fredrik
0
 
fredand44Author Commented:
Thanks mate!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.