struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dusty <>
Subject Re: Error autowiring an interface
Date Sat, 07 Mar 2009 19:42:50 GMT

You can't do what you are doing exactly.  When you are using the "free"
conversion, Struts2 needs to be able to construct your object with a default
constructor and that is not going to happen with an interface.   So if you
want to dynamically determine the implementation of that Object at runtime
then you should look into the ModelDriven interceptor.

When your action implements ModelDriven you implement a method called
getModel() which returns the implementation you want.  It returns an Object
but struts will use reflection to find the getters you want from the posted
request.  In your form you just use name="name" rather than

In getModel() you can do things like lookup a Spring managed bean based on a
String or whatever factory methodology you want.  

Security Management wrote:
> So, I have a jsp form that uses:
> <s:textfield name=""/> and things like that.
> The action's method for getUser provides an IUser (an interface).
> The instantiated class is provided by a dao provider injected by Spring,
> but
> all the jsp sees is the IUser type.
> Now, it works great getting the form generated, but when submitting, I
> get:
> 2009-03-06 10:54:48,315 [http-8080-Processor24] ERROR
> com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler - Could
> not
> create and/or set value back on to object
> org.springframework.beans.factory.BeanCreationException: Error creating
> bean
> with name 'com.blah.auth.IUser': Could not resolve matching constructor
> 	at
> uctor(
> Any suggestions?  Google is not helpful, strangely enough.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

View this message in context:
Sent from the Struts - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message