Announcement Announcement Module
Collapse
No announcement yet.
@Autowired Error when used with Validator Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @Autowired Error when used with Validator

    Hi,
    I am trying to use the validator in the container and i am using spring annotations.

    Below is the Exception.
    ================================================== =======
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'tradeInquiryController': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Could not autowire field: private tradeInquiryValidator; nested exception is org.springframework.beans.factory.NoSuchBeanDefini tionException: No unique bean of type [validator.TradeInquiryValidator] is defined: Unsatisfied dependency of type [class validator.TradeInquiryValidator]: expected at least 1 matching bean
    ================================================== =======

    Can somebody help me with the exception.

  • #2
    Please use [ code][/code ] tags.

    The exception is quite clear imho. there is no uniquely detectable TradeInquiryValidator.

    Comment


    • #3
      Thanks Marten,
      My bad, may be i have not shared complete information with you.
      Initially i had autowired the TradeInquiryValidator using the setter method as shown below and later on tired to use
      @Autowired directly on the member variable.


      The TradeInquiryValidator in application-servlet.xml with id as tradeInquiryValidator

      Code:
      <bean id="tradeInquiryValidator" class="validator.TradeInquiryValidator"/>
      In the controller class i have defined it as follows
      Code:
      @Controller
      public class TradeInquiryController {
      private TradeInquiryValidator tradeInquiryValidator;
      
      	/**
      	 * @param validator
      	 *            the validator to set
      	 */
      	@Autowired
      	public void setValidator(TradeInquiryValidator validator) {
      		this.tradeInquiryValidator = validator;
      	}
      ......
      }
      I tired using the following also
      Code:
      @Controller
      public class TradeInquiryController {
      
      @Autowired
      private TradeInquiryValidator tradeInquiryValidator;
      .....
      }
      Last edited by RahulJoshi; Oct 16th, 2008, 06:54 AM. Reason: Adding more information.

      Comment


      • #4
        And where is your Controller situated?! Is it loaded by the DispatcherServlet or by the ContextLoaderListener????

        Post the whole stacktrace.

        Comment

        Working...
        X