Make sure PersonManagerImpl implements PersonManager and then use a
dependency on the Interface in your action:

private PersonManager personManager;

public void setPersonManager(PersonManager personManager) {
       this.personManager = personManager;
}

Matt

On 4/12/07, Stelios Togias <[EMAIL PROTECTED]> wrote:
Hi,

I have changed applicationContext.xml(from the tutorial) to:

<bean id="personManager"
class="com.mycompany.service.impl.PersonManagerImpl">
        <constructor-arg ref="personDao"/>
</bean>

now in person action I have changed:

private PersonManagerImpl personManager;
private List persons;

public void setPersonManager(PersonManagerImpl
personManager) {
        this.personManager = personManager;
}


and added the function below:

public String search(String lastName) throws Exception {
        persons = personManager.findByLastName(lastName);
        return SUCCESS;
 }

Now when I run "mvn test -Dtest=PersonManagerImplTest" it passes ok.
But when I go to run the app(mvn jetty:run-war) and go to persons .html  I
get the following  error:

 Unable to instantiate Action, personAction,
defined for 'persons' in namespace '/'Error creating bean with name
'personAction'
defined in ServletContext resource
[/WEB-INF/applicationContext.xml]: Error setting property
values;
nested exception is
org.springframework.beans.PropertyBatchUpdateException;
nested PropertyAccessExceptions (1) are:
PropertyAccessException 1:
org.springframework.beans.TypeMismatchException:
Failed to convert property value of type [$Proxy39] to required type [
com.mycompany.service.impl.PersonManagerImpl] for property
'personManager';
nested exception is java.lang.IllegalArgumentException:
Cannot convert value of type [$Proxy39] to required type
[com.mycompany.service.impl.PersonManagerImpl ] for
property 'personManager':
no matching editors or conversion strategy found - action -
file:/D:/workspace/mytest/mytest/target/work/webapp/WEB-INF/classes/struts.xml:133:67

I tried to change in personAction this:

public void setPersonManager(PersonManagerImpl
personManager) {
        this.personManager = personManager;
}

to this:

public void setPersonManagerImpl(PersonManagerImpl
personManager) {
         this.personManager = personManager;
}

and all I did was to get this error:
Unable to instantiate Action, personAction,  defined for 'persons' in
namespace '/'Error creating bean with name 'personAction' defined in
ServletContext resource [/WEB-INF/applicationContext.xml]:
Error setting property values; nested exception is
org.springframework.beans.NotWritablePropertyException:
Invalid property 'personManager' of bean class
[com.mycompany.webapp.action.PersonAction]: Bean property
'personManager' is not writable or has an invalid setter method. Does the
parameter type of the setter match the return type of the getter? - action -
file:/D:/workspace/mytest/mytest/target/work/webapp/WEB-INF/classes/struts.xml:133:67

Am I doing something terribly wrong? Any directions for where to look for
the problem? As well how is the setPersonManager called? does it have to
match some specific name?
Sorry for the long post...
Thanks
 stelios



--
http://raibledesigns.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to