hi every one I m just dong a little sample to learn more about Spring, I made something quite close to the MVC sample, but I have a error with me beans declaration and I really can't find out the trouble. When I lunch tomcat on it I get :
in my springapp-servlet
they refer to simple class :
the controller
[CODE]package web;
import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;
import java.util.HashMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import artists.Product;
import artists.ProductManager;
public class SpringappController implements Controller {
/** Logger for this class and subclasses */
private ProductManager prodMa;
protected final Log logger = LogFactory.getLog(getClass());
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response){
try {
String now = (new java.util.Date()).toString();
logger.info("returning hello view with " + now);
Map myModel = new HashMap();
myModel.put("now", now);
myModel.put("products", getProductManager().getProducts());
return new ModelAndView("main", "model", myModel);}
catch (ServletException e){}
catch (IOException e) {}
}
public void setProductManager(ProductManager pm) {
prodMa = pm;
}
public ProductManager getProductManager() {
return prodMa;
}
}
[CODE]
artistManager
and artists
It's maybe quite nothing but I spend hours on it, I really apreciate I somebody can Help. thanks Bye
Code:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'artistsController' defined in ServletContext resource [/WEB-INF/springapp-servlet.xml]: Can't resolve reference to bean 'art' while setting property 'artistsController'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'art' defined in ServletContext resource [/WEB-INF/springapp-servlet.xml]: Can't resolve reference to bean 'art1' while setting property 'artists[0]'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'art1' defined in ServletContext resource [/WEB-INF/springapp-servlet.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'nom' of bean class [bus.Artist]: Bean property 'nom' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
Code:
... <bean id="artistsController" class="web.ArtistsController"> <property name="artistsController"> <ref local="art"/> </property> </bean> ... <bean id="art" class="bus.ArtistManager"> <property name="artists"> <list> <ref bean="art1"/> <ref bean="art2"/> ...
the controller
[CODE]package web;
import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;
import java.util.HashMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import artists.Product;
import artists.ProductManager;
public class SpringappController implements Controller {
/** Logger for this class and subclasses */
private ProductManager prodMa;
protected final Log logger = LogFactory.getLog(getClass());
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response){
try {
String now = (new java.util.Date()).toString();
logger.info("returning hello view with " + now);
Map myModel = new HashMap();
myModel.put("now", now);
myModel.put("products", getProductManager().getProducts());
return new ModelAndView("main", "model", myModel);}
catch (ServletException e){}
catch (IOException e) {}
}
public void setProductManager(ProductManager pm) {
prodMa = pm;
}
public ProductManager getProductManager() {
return prodMa;
}
}
[CODE]
artistManager
Code:
package artists; import java.io.Serializable; import java.util.List; public class ArtistManager implements Serializable { private List artists; public void setArtists(List a) { artists = a; } public List getArtists() { return artists; } }
Code:
package artists; import java.io.Serializable; public class Artists implements Serializable { private String name private String genre private String description } public void setName(String n) { name = n; } public String getName() { return name; } public void setGenre(String g) { genre = g; } public Double getGenre() { return genre; } public void setDescription(String d) { description = d; } public String getDescription() { return description; }
It's maybe quite nothing but I spend hours on it, I really apreciate I somebody can Help. thanks Bye
Comment