Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8905385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:22:53+00:00 2026-06-15T02:22:53+00:00

i am trying to set the value from the springapp-servlet.xml and it fails to

  • 0

i am trying to set the value from the springapp-servlet.xml and it fails to set the property by giving error message

Failed to convert property value of type [java.lang.String] to required type [ProductManager] for property ‘productManager’; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required type [ProductManager] for property ‘productManager’: no matching editors or conversion strategy found

my code

springapp-servlet.xml

view plaincopy to clipboardprint?
<?xml version="1.0" encoding="UTF-8"?>   
<beans xmlns="http://www.springframework.org/schema/beans"  
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
       xmlns:p="http://www.springframework.org/schema/p"  
       xmlns:aop="http://www.springframework.org/schema/aop"  
       xmlns:tx="http://www.springframework.org/schema/tx"  
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd  
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd  
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">  


       <bean id="productManager" class="SimpleProductManager">  
        <property name="products">  
            <list>  
                <ref bean="product1"/>  
                <ref bean="product2"/>  
           </list>  
        </property>  

    </bean>   

    <bean id="product1" class="Product">  
        <property name="description" value="Chair"/>  
    </bean>   

    <bean id="product2" class="Product">  
        <property name="description" value="Desk"/>  
    </bean>   

    <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">  
       <property name="basename" value="messages"/>  
    </bean>   

    <bean name="/hello.htm" class="HelloController">   
            <property name="productManager" value="productManager"/>      
    </bean>         

    <!-- we can prefix="/"   
    http://localhost:8080/HelloSpring/hello.htm  
    specify the path in  modelview from the controller   
                        OR  
    Decouple the view from the controller                      
    prefix="/WEB-INF/jsp/"  
    -->  
            <bean id="viewResolver"  
              class="org.springframework.web.servlet.view.InternalResourceViewResolver"  
              p:prefix="/WEB-INF/jsp/"  
              p:suffix=".jsp" />  
</beans>  

HelloController

view plaincopy to clipboardprint?
/* 
 * To change this template, choose Tools | Templates 
 * and open the template in the editor. 
 */  

/** 
 * 
 * @author gopc 
 */  
import java.util.Date;  
import java.util.Map;  
import java.util.HashMap;  

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 org.apache.commons.logging.Log;  

import org.apache.commons.logging.LogFactory;   

import java.io.IOException;  



public class HelloController implements Controller {   

      private ProductManager productManager;   
    protected final Log logger = LogFactory.getLog(getClass());   


    //Writing some business logic in the controller  

    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)  
            throws ServletException, IOException  
    {  
        String now = (new java.util.Date()).toString();  

        logger.info("returning hello view with " + now);   
        Map<String, Object> myModel = new HashMap<String, Object>();  
        myModel.put("now", now);  
        myModel.put("products", this.productManager.getProducts());   
        return new ModelAndView("hello", "model", myModel);  
    }  

    public void setProductManager(ProductManager productManager)   
    {  
        this.productManager = productManager;  
    }   

}  

SimpleProductManager

view plaincopy to clipboardprint?
/* 
 * To change this template, choose Tools | Templates 
 * and open the template in the editor. 
 */  

/** 
 * 
 * @author gopc 
 */  

import java.util.List;  
import org.apache.commons.logging.LogFactory;  
import org.apache.commons.logging.Log;  


public class SimpleProductManager implements ProductManager{  

    private List<Product> products;      
    protected final Log logger = LogFactory.getLog(getClass());   

    public List<Product> getProducts()  
    {  
       logger.info("inside  getProducts ");  
        return products;  
    }  

    public void increasePrice (int per)  
    {  
        if (products != null)  
        {  
            for (Product prod : products)  
            {  
                double newPrice = prod.getPrice() * (100 + per) /100;  
                prod.setPrice(newPrice);  
            }  
        }  
    }  

    public void setProducts(List <Product> products )  
    {  
        logger.info("inside  setProducts ");  
        this.products = products;  
    }  
}  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:22:56+00:00Added an answer on June 15, 2026 at 2:22 am

    Change

    <property name="productManager" value="productManager"/> 
    <!-- sets "productManager" to "productManager" String -->
    

    to :

    <property name="productManager" ref="productManager"/>
    <!-- sets "productManager" to bean with id="productManager" -->
    

    Right now you’re setting the productManager property of HelloController to a "productManager" String, and what you (probably) want is to wire it up with productManager bean defined earlier in the context.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new in grails and trying to set value from messages.property (i18n) in
I'm trying to set a value from the database into a Html component, the
I am trying to set the selected value of a combobox from a style
I am trying to set a session variable's value from within a class function,
I'm trying to set the htmlOptions using a value from the array used as
I am trying to extract a value from the windows registry of type REG_SZ
I am trying to set a value to a Nested Property of Class dynamically
Using an example from MSDN I'm trying to set the value of a cell
I am trying to set a header value in a response from a RESTful
Trying to set a custom property(value) for a ViewController( e.g.- FirstViewController). FirstViewController.h //.. int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.