Announcement Announcement Module
Collapse
No announcement yet.
pb with beans declaration (newbi) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • pb with beans declaration (newbi)

    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 :

    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?
    in my springapp-servlet

    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"/>
    ...
    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

    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;
        }
    }
    and 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

  • #2
    As the exception states; you are trying to call "setNom" on the Artist class, but there is no such setter

    Comment


    • #3
      thanks

      Thak you very much I was focusing on something else

      Comment


      • #4
        Originally posted by Dadooo
        Thak you very much I was focusing on something else
        No worries.

        In general, Spring exceptions are very information and tend to explain exactly what the problem is.

        Comment

        Working...
        X