-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 
Author Message
 Post subject: No getter method available
PostPosted: Mon Sep 05, 2005 3:12 pm 
Newbie

Joined: Wed Aug 31, 2005 8:18 pm
Posts: 18
Hi,
I am writing an application, which uses struts and hibernate. when i try to retreive the values from bean, i get the following error:
E SRVE0026E: [Servlet Error]-[No getter method for property agentName of bean aMEnrollment]

The following is the code iam using...

struts-config.xml:
- the relevant form definition
<form-bean name="AMEnrollmentForm" type="com.abc.forms.AMEnrollmentForm" />
- the relevant action mapping
<action path="/AMEnrollment" type="com.abc.actions.AMEnrollmentAction">
<forward name="success" path="/jsp/am_enrollment.jsp" />
</action>


Java code:

- relevant snippets from action class

query = session.createQuery("from com.abc.entities.Agent " + params);
results= query.list();
request.setAttribute("aMEnrollments", results);


JSP:

-<jsp:useBean id="aMEnrollments" type="java.util.List" scope="request"/>
<logic:iterate id="aMEnrollment" name="aMEnrollments" scope="request" >
<td><bean:write name="aMEnrollment" property="agentName" /></td>

stacktrace:

E SRVE0026E: [Servlet Error]-[No getter method for property agentName of bean aMEnrollment]: javax.servlet.jsp.JspException: No getter method for property agentName of bean aMEnrollment
at org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:973)
at org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:225)

Please help me.


Top
 Profile  
 
 Post subject: getter
PostPosted: Mon Sep 05, 2005 3:24 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
Are you sure that com.abc.entities.Agent has method getAgetntName() ?

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 05, 2005 3:42 pm 
Newbie

Joined: Wed Aug 31, 2005 8:18 pm
Posts: 18
Yes. I have the method getAgentName() in com.abc.entities.Agent


Top
 Profile  
 
 Post subject: jdbc error
PostPosted: Mon Sep 05, 2005 3:53 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
Since this is JSP error I would suggest you to test if 'aMEnrollments' request attribute contains list of com.abc.entities.Agent objects.

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 05, 2005 4:07 pm 
Newbie

Joined: Wed Aug 31, 2005 8:18 pm
Posts: 18
I have a correction.

The getAgentName() is in com.abc.entities.ClientAgent

I have the following mapping files:

Agent.hbm.xml
<class name="com.abc.entities.Agent"
table="AGENT"
lazy="false">

<id name="agencyNumber" type="string" column="AGCY_NBR">
</id>

<one-to-one name="clientAgent" class="com.abc.ClientAgent" property-ref="clientReferenceNumber" />

Client.hbm.xml
<class name="ClientAgent"
table="CLIENT_AGENT"
lazy="false">
<id name="clientNumber" type="string" column="CLIENT_NBR" unsaved-value="0">

</id>
<property name="clientReferenceNumber" type="string" column="CLIENT_REF_NBR" not-null="true" />
<property name="agentName" type="string" column="AGENT_NAME_1" not-null="true"/>
</class>

I am trying to join two tables Agent, and Client_Agent in the query to retreive values.


Top
 Profile  
 
 Post subject: polymorphic behavior
PostPosted: Mon Sep 05, 2005 4:27 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
Here we are: Agent does not have property agentName :)
It is clientAgent.agentName

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 05, 2005 4:48 pm 
Newbie

Joined: Wed Aug 31, 2005 8:18 pm
Posts: 18
Hi Konstantin,

I appreciate you trying to help me in debugging this.
I know that agentName is not in Agent, but it is in ClientAgent.
As i said earlier i am trying to join two tables Agent and ClientAgent.
Agent table has agencyNumber and agencySweepCode while ClientAgent table has clientReferenceNumber and agentName.
agencyNumber in Agent table is equivalent to clientReferenceNumber in ClientAgent table. For that in the mapping files i am using one-to-one mapping in the Agent.hbm.xml.

In the action class iam using the following query

string params="where AGCY_NBR=?"
query = session.createQuery("from com.abc.entities.Agent " + params);
results= query.list();

Then iam storing the result as follows in a bean
request.setAttribute("aMEnrollments", results);

In the JSP, iam using the following code to access the properties..

<jsp:useBean id="aMEnrollments" type="java.util.List" scope="request"/>
<logic:iterate id="aMEnrollment" name="aMEnrollments" scope="request" >
<td><bean:write name="aMEnrollment" property="agentNumber" /></td>
<td><bean:write name="aMEnrollment" property="agentName" /></td>

When i execute the program i get the following error:
No getter method found for agentName

Please let me whether am i doing the right way. Iam struggling with this error for last 4 days.. please help me in debugging this.


Top
 Profile  
 
 Post subject: ORM
PostPosted: Mon Sep 05, 2005 4:58 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
I guess that your confusion is caused by too much focus on Tables :)
Hibernate is ORM: Object-Relationla-Mapper, therefore in the list you have Objects, not records.

According to your mapping file to get the agentName in Java code we would do this:

Agent aMEnrollment = getSomeAgentSomehow();
String aName = aMEnrollment.getClientAgent().getAgentName();

Hibernate does the required join for you, it puts object of ClientAgent class into clientAgent property of Agent.
Since in JSP code you call Agent instances as aMEnrollment
the JSP code shoiuld look like:

<logic:iterate id="aMEnrollment" name="aMEnrollments" scope="request" >
<td><bean:write name="aMEnrollment" property="clientAgent.agentNumber" /></td>

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 05, 2005 5:20 pm 
Newbie

Joined: Wed Aug 31, 2005 8:18 pm
Posts: 18
Hi Konstatin,

Thanks a lot for ur help.
I followed ur suggestion and now it works fine, once again thanks for correcting me.

--kum


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.