Solved

No getter method for property

Posted on 2008-10-02
7
1,939 Views
Last Modified: 2013-11-24
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
0
Comment
Question by:fredand44
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 9

Expert Comment

by:brunoguimaraes
ID: 22626295
Check if there is something missing in your struts-config.xml
0
 

Author Comment

by:fredand44
ID: 22626847
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
 
LVL 9

Accepted Solution

by:
brunoguimaraes earned 250 total points
ID: 22627143
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
Congratulations! You’re Certified – Now What?

Starting a new career can be overwhelming. Becoming certified in your field of expertise is a great start, but where do you go from here?  Here are some tips to help you on your career journey.

 

Author Comment

by:fredand44
ID: 22627311
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
 
LVL 9

Expert Comment

by:brunoguimaraes
ID: 22627607
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
 

Author Comment

by:fredand44
ID: 22705049
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
 

Author Closing Comment

by:fredand44
ID: 31502455
Thanks mate!
0

Featured Post

Application Discovery Service in AWS

In the era of the cloud, customers migrating away from their existing on-premise infrastructure. This requires lots of planning, strategies, and effort to identify their existing resources and determine how best to migrate.  Datacenter migrations happen in four phases -

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question