4

I am using Spring 3.0. I am not using hibernate or maven dependencies. I have downloaded the jar files and added it to my classpath. I am receiving a javax.validation.ValidationException. After researching this issue i have included hibernate-core-3.5.6.jar and slf4-api.1.4.3.jar files to the classpath.

Error Log

2073 [ContainerBackgroundProcessor[StandardEngine[Catalina]]] ERROR org.springframework.web.servlet.DispatcherServlet  - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0': Invocation of init method failed; nested exception is javax.validation.ValidationException: Unable to find a default provider
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
    at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:631)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:588)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:645)
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:508)
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:449)
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:133)
    at javax.servlet.GenericServlet.init(GenericServlet.java:212)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1206)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1026)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4421)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4734)
    at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1284)
    at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1382)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:306)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
    at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1389)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1653)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1662)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1642)
    at java.lang.Thread.run(Unknown Source)
Caused by: javax.validation.ValidationException: Unable to find a default provider
    at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:264)
    at org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.afterPropertiesSet(LocalValidatorFactoryBean.java:184)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
    ... 29 more

6 Answers 6

10

You need to include the hibernate-validator library jar.

Hibernate Validator (version 4.x and above) is the reference implementation of javax.validation.constraints, also known as JSR-303 annotations.
Despite the name, this library has nothing to do with databases and relational mapping, it just does validation.

Sign up to request clarification or add additional context in comments.

5 Comments

i did include the hibernate-validator.jar but i am still getting the following error :org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0': Invocation of init method failed; nested exception is javax.validation.ValidationException: Unable to find a default provider. Do i need to specify any beans in the applicationContext.xml?
@dev_darin which verison of hibernate-validator are you using ?
i am now checking that and i am seeing 3.0 i would need to use 4.0 and earlier?
now getting java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder, guess i need the slf4j.jar any suggestions on the version
@dev_darin don't know, maybe try looking at the end of this blog post (click here), there is a list of maven dependencies. You can see that they use sl4j 1.6.1, but it was in early 2011.
6

Add hibernate-validator dependency which has implementation of JSR 303 (bean validation).

   <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-validator</artifactId>
      <version>4.2.0.Final</version>
   </dependency>

Comments

0

I had same problem ... I had this , bu did not want to use validation :

    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.1.0.Final</version>
    </dependency>

Comments

0

I added hibernate-validator as a dependency in pom.xml and it worked

Comments

0

For some weird reason, REMOVING this maven dependency did the trick:

        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>2.0.1.Final</version>
        </dependency>

Comments

0

If none of the above are working for you, there is a chance that you are not using Java 8 or it hasn't been properly installed in your system(give it a check by typing java --version (for mac) in the terminal or command prompt). It was so for me. I had to uninstall Java and reinstall Java 8 (Go to this correct way to uninstall java on mac if you are a mac user) and the problem was solved.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.