- 搭建JUnit环境时,测试Controller时,提示“Caused by: javax.validation.ValidationException: Unable to instantiate Configuration.”
2014-11-3 18:06:46 org.springframework.context.support.FileSystemXmlApplicationContext prepareRefresh 信息: Refreshing org.[email protected]f81843: startup date [Mon Nov 03 18:06:46 CST 2014]; root of context hierarchy 2014-11-3 18:06:46 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 信息: Loading XML bean definitions from file [D:\Workspaces\SpringMVCDemo\WebContent\WEB-INF\SpringMVC-servlet.xml] 2014-11-3 18:06:46 org.springframework.context.annotation.ClassPathBeanDefinitionScanner registerDefaultFilters 信息: JSR-250 ‘javax.annotation.ManagedBean‘ found and supported for component scanning 2014-11-3 18:06:46 org.springframework.context.annotation.ClassPathBeanDefinitionScanner registerDefaultFilters 信息: JSR-330 ‘javax.inject.Named‘ annotation found and supported for component scanning 2014-11-3 18:06:46 org.springframework.context.annotation.ClassPathBeanDefinitionScanner registerDefaultFilters 信息: JSR-250 ‘javax.annotation.ManagedBean‘ found and supported for component scanning 2014-11-3 18:06:46 org.springframework.context.annotation.ClassPathBeanDefinitionScanner registerDefaultFilters 信息: JSR-330 ‘javax.inject.Named‘ annotation found and supported for component scanning 2014-11-3 18:06:46 org.springframework.context.annotation.ClassPathBeanDefinitionScanner registerDefaultFilters 信息: JSR-250 ‘javax.annotation.ManagedBean‘ found and supported for component scanning 2014-11-3 18:06:46 org.springframework.context.annotation.ClassPathBeanDefinitionScanner registerDefaultFilters 信息: JSR-330 ‘javax.inject.Named‘ annotation found and supported for component scanning 2014-11-3 18:06:46 org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor <init> 信息: JSR-330 ‘javax.inject.Inject‘ annotation found and supported for autowiring 2014-11-3 18:06:46 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons 信息: Pre-instantiating singletons in org.s[email protected]dda25b: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,baseController,testController,mvcContentNegotiationManager,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0,org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver#0,org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver#0,org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver#0,org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter,viewResolver,org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler#0,org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor]; root of factory hierarchy ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console... 2014-11-3 18:06:46 org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod 信息: Mapped "{[/transfer],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.candy.web.test.TestController.referLogin() 2014-11-3 18:06:46 org.hibernate.validator.util.Version <clinit> 信息: Hibernate Validator bean-validator-3.0-JBoss-4.0.2 2014-11-3 18:06:46 org.springframework.beans.factory.support.DefaultListableBeanFactory destroySingletons 信息: Destroying singletons in org.s[email protected]dda25b: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,baseController,testController,mvcContentNegotiationManager,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0,org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver#0,org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver#0,org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver#0,org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter,viewResolver,org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler#0,org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor]; root of factory hierarchy java.lang.ExceptionInInitializerError Caused by: 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 instantiate Configuration. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1482) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140) at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84) at com.candy.web.BaseController.<clinit>(BaseController.java:25) Caused by: javax.validation.ValidationException: Unable to instantiate Configuration. at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:272) at org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.afterPropertiesSet(LocalValidatorFactoryBean.java:188) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479) ... 12 more Caused by: java.lang.NullPointerException at java.util.ResourceBundle.getBundle(ResourceBundle.java:950) 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) ... 15 more Exception in thread "main"
解决方案:删除JavaEE6中自带的jar包:bean-validator.jar
- 如何删除JavaEE6中自带的jar包?
在MyEclipse的菜单:Window-->Properties-->MyEclipse-->Java Enterprise Project-->Library Sets中,选择到Java EE6.0选项卡(默认选中),然后选择bean-validator.jar,点击右侧的“Remove”按钮,然后点“OK”按钮即可。 - ……
- ……
时间: 2024-10-06 21:41:41