Announcement Announcement Module
Collapse
No announcement yet.
why NoSuchBeanDefinitionException from spring-sandbox.jar? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • why NoSuchBeanDefinitionException from spring-sandbox.jar?

    I checked out the spring source code from its CVS and built a few jars
    acorrding to spring's build.xml as follows:

    ant modulejars
    ant mockjar
    ant sandbox.jar (637K)

    in the hope that my program runs on the latest version.

    However, I got the following exception when visiting a spring form.

    -----------------------
    org.springframework.beans.factory.NoSuchBeanDefini tionException: No unique bean of type [org.springframework.validation.
    commons.ValidatorFactory] is defined: Expected single bean but found 0
    at org.springframework.beans.factory.BeanFactoryUtils .beanOfTypeIncludingAncestors(BeanFactoryUtils.jav a:256)
    at org.springframework.validation.commons.taglib.Java scriptValidatorTag.getValidatorResources(Javascrip tValidato
    rTag.java:783)
    at org.springframework.validation.commons.taglib.Java scriptValidatorTag.doStartTag(JavascriptValidatorT ag.java:3
    49)
    at org.apache.jsp.scripts.validator_jsp._jspx_meth_ht ml_javascript_0(org.apache.jsp.scripts.validator_j sp:79)
    at org.apache.jsp.scripts.validator_jsp._jspService(o rg.apache.jsp.scripts.validator_jsp:55)
    -----------------------

    I have a spring-sandbox.jar (434K) which I got from Matt
    Raible's book, Spring Alive. If I use this spring-sandbox.jar, my program
    works. Can somebody give me an explanation or let me know how to
    resolve this?

    Thanks, Pete

  • #2
    You're either not in the context of a Spring controller (the tag first looks in the in the Servlet WebAppCtx - xxx-servlet.xml - and the in your applicationContext.xml - if you're not in the context of a spring controller the xxx-servlet.xml will not be available) or you simply haven't defined a ValidatorFactory.

    The change between the latest version and the version you're using is that Spring first looks in the Servlet webapplicationcontext. It didn't do this before.

    Remember, the sandbox code is subject to change without notice so you should be careful with what you're doing here...

    regards,
    Alef Arendsen

    Comment


    • #3
      Alef,

      Thanks for the information which is very useful. I have figured
      it out why. My web-tier application context needs to be specified
      together the context files for other two tiers.

      <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>
      /WEB-INF/app-web.xml
      /WEB-INF/app-service.xml
      /WEB-INF/app-data.xml
      </param-value>
      </context-param>

      Without put /WEB-INF/app-web.xml in the above, my app still works,
      but the validation using the sandbox fails.

      Regards,
      Pete

      Comment

      Working...
      X