Unable to build the default ValidatorFactory

今天数据库连接配置全写在hibernate.cfg.xml的时候没有问题,与spring整合的时候就出现了这个问题,反复查了代码,没找到问题

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to get the default Bean Validation factory
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
	at lindl.ssh.oa.test.SpringTest.<init>(SpringTest.java:12)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:209)
	at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:258)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:255)
	at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.hibernate.HibernateException: Unable to get the default Bean Validation factory
	at org.hibernate.cfg.beanvalidation.BeanValidationActivator.applyDDL(BeanValidationActivator.java:127)
	at org.hibernate.cfg.Configuration.applyBeanValidationConstraintsOnDDL(Configuration.java:1674)
	at org.hibernate.cfg.Configuration.applyConstraintsToDDL(Configuration.java:1624)
	at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1415)
	at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1345)
	at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:673)
	at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
	... 38 more
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.hibernate.cfg.beanvalidation.BeanValidationActivator.applyDDL(BeanValidationActivator.java:118)
	... 46 more
Caused by: org.hibernate.HibernateException: Unable to build the default ValidatorFactory
	at org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafeActivator.java:345)
	at org.hibernate.cfg.beanvalidation.TypeSafeActivator.applyDDL(TypeSafeActivator.java:106)
	... 51 more
Caused by: javax.validation.ValidationException: Unable to instantiate Configuration.
	at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:272)
	at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:111)
	at org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafeActivator.java:342)
	... 52 more
Caused by: java.lang.NullPointerException
	at java.util.ResourceBundle.getBundle(ResourceBundle.java:960)
	at org.hibernate.validator.engine.ResourceBundleMessageInterpolator.loadBundle(ResourceBundleMessageInterpolator.java:202)
	at org.hibernate.validator.engine.ResourceBundleMessageInterpolator.getFileBasedResourceBundle(ResourceBundleMessageInterpolator.java:182)
	at org.hibernate.validator.engine.ResourceBundleMessageInterpolator.<init>(ResourceBundleMessageInterpolator.java:81)
	at org.hibernate.validator.engine.ResourceBundleMessageInterpolator.<init>(ResourceBundleMessageInterpolator.java:73)
	at org.hibernate.validator.engine.ConfigurationImpl.<init>(ConfigurationImpl.java:57)
	at org.hibernate.validator.HibernateValidator.createGenericConfiguration(HibernateValidator.java:43)
	at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:269)
	... 54 more

最后有网友说是版本问题,要配置javax.persistence.validation.mode项

注意,是在hibernate.cfg.xml的session-factory里面加上这个属性配置

<property name="javax.persistence.validation.mode">none</property>

"javax.persistence.validation.mode默认情况下是auto的,就是说如果不设置的话它是会自动去你的classpath下面找一个bean-validation**包,但是找不到,所以beanvalitionFactory错误。由于javax.persistence.validation.mode的属性值默认是auto,所以会出错。"

版权声明:本文为博主原创文章,未经博主允许不得转载。如需转载,请注明出处:http://blog.csdn.net/lindonglian

时间: 2024-10-15 18:53:53

Unable to build the default ValidatorFactory的相关文章

使用hibernate时出现 org.hibernate.HibernateException: Unable to get the default Bean Validation factory

hibernate 在使用junit测试报错: org.hibernate.HibernateException: Unable to get the default Bean Validation factory at org.hibernate.cfg.beanvalidation.BeanValidationActivator.applyDDL(BeanValidationActivator.java:127) at org.hibernate.cfg.Configuration.appl

hibernate 错误:org.hibernate.HibernateException: Unable to get the default Bean Validation factory

最近在自学Hibernate与Struts2进行集成时,出现了一个错误,错误截图如下: 错误代码如下: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for

解决 Springboot Unable to build Hibernate SessionFactory @Column命名不起作用

问题: Springboot启动报错: Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.

Exception in thread &quot;main&quot; javax.validation.ValidationException: Unable to find a default provider

Exception in thread "main" javax.validation.ValidationException: Unable to find a default provider 在使用Spring MVC+Mybatis整合的时候出现上面的问题 要将下面三个包加入项目的BuildPath中才行:    hibernate-validator-4.2.0.Final.jar    validation-api-1.0.0.GA.jar    slf4j-api-1.6

Unknown error: Unable to build: the file dx.jar was not loaded from the SDK folder!

Eclipse 编译没问题,但是运行就出现这个报错:Unknown error: Unable to build: the file dx.jar was not loaded from the SDK folder! 这个报错是由于安卓的SDK版本太高导致的.两个解决方法,一个是直接使用Android studio,一个是删除高版本的构建包. 先看看报错情况: 如图提示,加载失败26.0.1,那么我们需要打开SDK管理器,并删除这几个包 删除后,重启Eclipse并Clean项目即可.

eclipse升级Android SDK Tool版本到25.2.5后运行项目报错Unable to build: the file dx.jar was not loaded from the SDK folder

概述 由于最近通过SDK-Manager更新了build-tools,当要用到dx.jar这个包时,自动调用最新版本Android SDK build-tools中dx.jar,但是运行android项目时Console却提示: 解决方案 解决办法就是:确保dx.jar这个文件在build-tools\lib和选择的Andriod SDK Tools版本一致就可以. 我用的 Android SDk build-tools 最新版本是 28.0.3,安装的Andriod SDK Tools版本是2

解决Unknown error: Unable to build: the file dx.jar was not loaded from the SDK folder!

解决Unknown error: to the dx.jar the SDK folder!最近渐渐迁移到Android Studio来了,更新过Android SDK Manager里的东西后,打开Eclipse Run工程报错.查找各种解决办法,发现: Android SDK Build-tools的版本已经高于Android SDK Platform-tools版本了,见图 由于Android Studio有时必须用高版本的Build-tools,所以简单的删除高版本的Build-tool

升级adt插件后,eclipse突然出现Unable to build: the file dx.jar was not loaded from the SDK folder 错误

旧版的SDK管理器里面最高只能安装Android 3.2 API,需要更新SDK管理器版本后才能安装Android 4.0.Android 4.1,方法如下: http://blog.csdn.net/aminfo/article/details/7788614 第一步:打开SDK管理器 第二步:选择Available packages 第三步:点击“Add Add-on Site...”,然后输入网址 http://developer.android.com/sdk/index.html 第四

java.lang.IllegalStateException: Failed to load ApplicationContext

1.错误描述 INFO:2015-02-05 22:14:21[main] - Loading XML bean definitions from class path resource [applicationContext.xml] INFO:2015-02-05 22:14:22[main] - JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning INFO:2015-02-05