java.lang.NoSuchMethodError: javax.persistence.PersistenceContext.synchronization - java

While deploying application on Tomcat 8.0.36 I am getting following exception
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'eventsDAOImpl' Post-processing of merged bean
definition failed; nested exception is java.lang.NoSuchMethodError:
javax.persistence.PersistenceContext.synchronization()Ljavax/persistence/SynchronizationType;
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)
at
org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:756)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
at
org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:409)
at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:291)
at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4842)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at
org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:940)
at
org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1816)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266) at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748) Caused by:
java.lang.NoSuchMethodError:
javax.persistence.PersistenceContext.synchronization()Ljavax/persistence/SynchronizationType;
at
org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.(PersistenceAnnotationBeanPostProcessor.java:653)
at
org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.lambda$buildPersistenceMetadata$0(PersistenceAnnotationBeanPostProcessor.java:416)
at
org.springframework.util.ReflectionUtils.doWithLocalFields(ReflectionUtils.java:693)
at
org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.buildPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:410)
at
org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:394)
at
org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(PersistenceAnnotationBeanPostProcessor.java:332)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:1015)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557)
... 24 more
I am using eclipselink version 2.5.2 and added following jars in the lib folder of tomcat
eclipselink-2.5.2.jar
javax.persistence-api-2.2.jar
ojdbc6-12.1.0.1.jar
dependencies.gradle is as follows
compile (
'org.aspectj:aspectjrt:1.8.4',
'org.aspectj:aspectjweaver:1.8.4',
'org.springframework:spring-aspects:5.0.0.RELEASE',
'org.springframework:spring-jdbc:5.0.0.RELEASE',
'org.springframework:spring-jms:5.0.0.RELEASE',
'org.springframework:spring-orm:5.0.0.RELEASE',
'org.springframework:spring-oxm:5.0.0.RELEASE',
'org.springframework:spring-web:5.0.0.RELEASE',
'org.springframework:spring-webmvc:5.0.0.RELEASE',
'org.springframework:spring-instrument-tomcat:4.0.9.RELEASE'
}
provided (
'com.oracle:ojdbc6:12.1.0.1',
'org.eclipse.persistence:eclipselink:2.5.2'
)
Edit 1 : Same application is running fine on Tomcat 9 but giving above exception while deploying on Tomcat 8
Edit 2 : After doing some research I found out that Tomcat 8 is loading PersistenceContext class from annotations-api.jar located in TOMCAT_HOME\lib folder instead of javax.persistence-api-2.2.jar and PersistenceContext class available in annotations-api.jar does not contain synchronization method as follows.
package javax.persistence;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
#Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
#Retention(RetentionPolicy.RUNTIME)
public #interface PersistenceContext {
String name() default "";
String unitName() default "";
PersistenceContextType type() default PersistenceContextType.TRANSACTION;
PersistenceProperty[] properties() default {};
}
How to give preference in Tomcat 8 such that Tomcat 8 will load PersistenceContext class from javax.persistence-api-2.2.jar instead of annotations-api.jar

may be you are having conflicts in your spring data dependency version One is vesion1 (or replication of two same jar you can say)another is version2 Please remove older version dependency either version one or version two from pom.xml or from build path jar
OR
may be there is no Spring data jar or dependency over there please kindly add it.

org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Finals delivers an OLD version of javax.persistance that lack of that API PersitanceContext().synchronization()
Solution: add java.persistence:javax.persistence-api:2.2 BEFORE hibernate-jpa-2.0-api in the pom.xml
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.1.Final</version>
</dependency>
No idea about gradle, but at least you can try.

I see PersistenceContext.class with the synchronization() method in javax.persistence-api-2.2.jar. It looks like Apache has removed PersistenceContext (along with other classes) from annotations-api.jar as of Tomcat 7 which means it can't be loading this class from the Tomcat provided jar. Perhaps you have a another jar in your application that has an old version of PersistenceContext in it?

Related

Spring boot application fails because it tries to load application.xml file

I am trying to add Spring boot to an existing and working Java web application, which uses Spring.
On starting the application such error is thrown:
java.lang.IllegalStateException: Failed to load property source from location 'classpath:/application.xml'
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadIntoGroup(ConfigFileApplicationListener.java:476)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:465)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:386)
at org.springframework.boot.context.config.ConfigFileApplicationListener.addPropertySources(ConfigFileApplicationListener.java:225)
at org.springframework.boot.context.config.ConfigFileApplicationListener.postProcessEnvironment(ConfigFileApplicationListener.java:195)
at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:182)
at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:168)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:325)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:296)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
at com.barclays.scp.eps.fullserve.application.Application.main(Application.java:12)
Caused by: java.util.InvalidPropertiesFormatException: org.xml.sax.SAXException: Invalid system identifier: http://java.sun.com/dtd/application_1_3.dtd
at java.util.XMLUtils.load(XMLUtils.java:59)
It seems that Spring boot is trying to load application.xml file as it's config file, though I haven't specified anywhere that such file is required and I had previously created Spring boot apps from scratch, no application.xml was required.
The project is quite big, it has many dependencies, maybe that could be caused by some of them?
I have tried adding application.xml to resources folder, a valid empty xml file - the main exception is still the same, though the cause of it is a bit different - Caused by: java.util.InvalidPropertiesFormatException: org.xml.sax.SAXParseException: Premature end of file. This means the application.xml was read this time, but for some reason - incorrect.
What could be the issue here, why this application.xml is required at all? As far as I understand, such configuration file should not be required in Spring boot app.
Some info about project configuration - these Spring boot dependencies are added (Spring boot version 1.5.9.RELEASE):
compile('org.springframework.boot:spring-boot-starter-web') {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
compile('org.springframework.boot:spring-boot-starter-data-jpa') {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
Main class launching the project is very basic (I know it will need more configuration, but one step at a time):
#SpringBootApplication
public class Application {
public static void main(final String[] args) {
SpringApplication.run(Application.class, args);
}
}
Any suggestions would be appreciated. Thank you!
The essayist is to create new Spring Boot project using https://start.spring.io/ and then migrate your code.
Everything else is much more work.
JDK: 1.8
Spring Boot: 2.1.4-RELEASE
#Adomas I met this situation just now. The reason is that I have a dependency jar which includes the file named 'application.xml' in the classpath.
After I remove this file 'application.xml' from this dependency jar, I had solved this problem.
22:20:52.866 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.IllegalStateException: Failed to load property source from location 'classpath:/application.xml'
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:556)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadForFileExtension(ConfigFileApplicationListener.java:502)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:469)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.lambda$null$6(ConfigFileApplicationListener.java:450)
at java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.lambda$load$7(ConfigFileApplicationListener.java:449)
at java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:446)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:334)
at org.springframework.boot.context.config.ConfigFileApplicationListener.addPropertySources(ConfigFileApplicationListener.java:209)
at org.springframework.boot.context.config.ConfigFileApplicationListener.postProcessEnvironment(ConfigFileApplicationListener.java:192)
at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:179)
at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:75)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:347)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:306)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
at com.xxx.Application.main(Application.java:16)
Caused by: java.util.InvalidPropertiesFormatException: org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 33; 文档根元素 "beans" 必须匹配 DOCTYPE 根 "null"。
at sun.util.xml.PlatformXmlPropertiesProvider.load(PlatformXmlPropertiesProvider.java:80)
at java.util.Properties$XmlSupport.load(Properties.java:1201)
at java.util.Properties.loadFromXML(Properties.java:881)
at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:137)
at org.springframework.core.io.support.PropertiesLoaderUtils.loadProperties(PropertiesLoaderUtils.java:122)
at org.springframework.boot.env.PropertiesPropertySourceLoader.loadProperties(PropertiesPropertySourceLoader.java:59)
at org.springframework.boot.env.PropertiesPropertySourceLoader.load(PropertiesPropertySourceLoader.java:47)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadDocuments(ConfigFileApplicationListener.java:574)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:528)
... 23 common frames omitted
Caused by: org.xml.sax.SAXParseException: 文档根元素 "beans" 必须匹配 DOCTYPE 根 "null"。
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:396)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:284)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.rootElementSpecified(XMLDTDValidator.java:1599)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleStartElement(XMLDTDValidator.java:1877)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(XMLDTDValidator.java:742)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1359)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$ContentDriver.scanRootElementHook(XMLDocumentScannerImpl.java:1289)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3132)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:852)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:842)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:771)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:243)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
at sun.util.xml.PlatformXmlPropertiesProvider.getLoadingDoc(PlatformXmlPropertiesProvider.java:106)
at sun.util.xml.PlatformXmlPropertiesProvider.load(PlatformXmlPropertiesProvider.java:78)
... 31 common frames omitted
Process finished with exit code 1
The issue was caused by a dependency, which had application.xml in it's resources. In my case that was a legacy dependency and it was not used anywhere so the fix was just to remove it. In case that dependency was required, the solution would probably be to somehow exclude that application.xml loading as Spring boot config file.
I had issue with 1.5.9.RELEASE version
Error: Could not find or load main class ... in Spring Boot 1.5.9 version but not in 1.4.7
I currently use the 1.4.7.RELEASE. I would suggest you to try to update your spring dependency to this version
parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
Spring Boot try to load "application.xml", "application.properties" and "application.yml" at "classpath:/". If you want to override the "application.xml", you need to use a valid xml. Like:
<?xml version='1.0' encoding="UTF-8" standalone = "yes"?>
<!DOCTYPE dummy [ <!ELEMENT dummy (dummy?) > ]>
<dummy><dummy></dummy></dummy>

Spring MVC,JdbcTemplate and Security Integration ClassNotFoundException: org.springframework.web.context.request.async.CallableProcessingInterceptor

I am implementing Spring MVC Spring Security MySQL Integration
My Stack Trace will look like this.
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/web/context/request/async/CallableProcessingInterceptor
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:545)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:272)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:196)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4728)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5166)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: org/springframework/web/context/request/async/CallableProcessingInterceptor
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getDeclaredConstructors(Unknown Source)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:228)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:911)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:884)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:270)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:125)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:355)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:153)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:586)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:140)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:984)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:888)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:355)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:153)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1308)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1067)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
... 20 more
Caused by: java.lang.ClassNotFoundException: org.springframework.web.context.request.async.CallableProcessingInterceptor
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1305)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1157)
... 49 more
With reference to Spring Docs
http://docs.spring.io/spring-framework/docs/3.2.0.RC2/api/org/springframework/web/context/request/async/CallableProcessingInterceptor.html
Intercepts concurrent request handling, where the concurrent result is obtained by executing a Callable on behalf of the application with an AsyncTaskExecutor.
A CallableProcessingInterceptor is invoked before and after the invocation of the Callable task in the asynchronous thread, as well as on timeout from a container thread, or after completing for any reason including a timeout or network error.
As a general rule exceptions raised by interceptor methods will cause async processing to resume by dispatching back to the container and using the Exception instance as the concurrent result. Such exceptions will then be processed through the HandlerExceptionResolver mechanism.
The afterTimeout method can select a value to be used to resume processing.
Can anyone please explain and help me out of this.
Trace clearly shows, your application is not able to find CallableProcessingInterceptor class. Edit your pom with below dependency and check if it is working:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.2.0.RELEASE</version>
</dependency>
I have just verified. On a Spring 3.2.8 release, org/springframework/web/context/request/async/CallableProcessingInterceptor lies in spring-web-3.2.8.jar.
The error is :
...exception is java.lang.NoClassDefFoundError: org/springframework/web/context/request/async/CallableProcessingInterceptor
That proves that at run time spring-web.jar is not in classpath, or is not same version as other spring jars. A common cause for that when not using maven, is to declare the jars to the compiler or IDE, not include them in WEB-INF/lib in the war, and not to have them in Tomcat's classpath.
As you do not use maven, it looks like you are in a build and dependencies hell (name is mine). Either tomcat finds other jars (typically other versions of spring) in its classpath, or your build does not include (for any reason) spring-web-version.jar for correct version. This may be hard to fix, but you can try :
control is nothing looks wrong in your build process
control if the deployed application holds proper jars with proper version
strip down the application to remove parts until it works and re-add them one at a time in order to identify exactly what triggers the error
Or if you can do it, convert your application to use maven, and it will deal almost automatically with all those dependencies for you, warning you of incompatible versions.
But I'm afraid that I cannot do more for you here ...
This exception is caused due to Spring dependent jars missing or having conflict between versions of jars
Check whether you have spring-web-X.X.X (X.X.X is the required version depending on project) jar available on your build path/Maven dependency.
If there is any duplicate jar you need to remove it.

Maven: wrong Hibernate version?

I am encounting bug which is supposed to be fixed: isMember on #ElementCollection throws QuerySyntaxException: unexpected end of subtree
I googled about this issue and found ticket HHH-5799 and HHH-5209 where its claimed to be resolved in Hibernate 4.1.8, 4.3.0.Beta1.
I am trying to query for ProductType by one of its barcodes.
My entity looks like this:
#Entity
#XmlRootElement
public class ProductType implements Serializable {
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue
private Long id;
#NotNull
#ElementCollection
private List<String> barcodes = new LinkedList<String>();
... getters+setters
}
I am using criteria api to query for product type by barcode using this code:
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<ProductType> c = cb.createQuery(ProductType.class);
Root<ProductType> f = c.from(ProductType.class);
c.select(f).where(cb.isMember(barcode, f.get(ProductType_.barcodes)));
TypedQuery<ProductType> query = em.createQuery(c);
return query.getSingleResult();
I made a simple test:
#Test
public void testProductTypeWithMultipleBarcodes()
{
ProductType type = new ProductType();
List<String> barcodes = new LinkedList<String>();
barcodes.add("1234561");
barcodes.add("1234562");
barcodes.add("1234563");
type.setBarcodes(barcodes);
em.persist(type);
em.flush();
assertEquals(type, productRepository.findProductTypeByBarcode("1234561"));
assertEquals(type, productRepository.findProductTypeByBarcode("1234562"));
assertEquals(type, productRepository.findProductTypeByBarcode("1234563"));
}
But I am getting org.hibernate.hql.internal.ast.QuerySyntaxException:
Caused by: org.jboss.arquillian.test.spi.ArquillianProxyException: org.hibernate.hql.internal.ast.QuerySyntaxException : unexpected end of subtree [select generatedAlias0 from cz.nuc.skladnik.storagecycle.product.ProductType as generatedAlias0 where :param0 member of generatedAlias0.barcodes] [Proxied because : Original exception not deserilizable, ClassNotFoundException]
at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:54)
at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:47)
at org.hibernate.hql.internal.ast.ErrorCounter.throwQueryException(ErrorCounter.java:79)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.generate(QueryTranslatorImpl.java:238)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:203)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:119)
at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:214)
at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:192)
at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1537)
at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:487)
Before exception I see:
00:40:44,965 ERROR [org.hibernate.hql.internal.ast.ErrorCounter] (http--0_0_0_0_0_0_0_0-8080-1) <AST>:0:0: unexpected end of subtree: <AST>:0:0: unexpected end of subtree
at org.hibernate.hql.internal.antlr.SqlGeneratorBase.selectClause(SqlGeneratorBase.java:490) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
mentioning hibernate-core-4.0.1.Final. So I've tried to add dependency on hibernate-core in my pom with no result:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.1.Final</version>
</dependency>
Full pom.xml is here: http://pastebin.com/8U30fPpn
I think that hibernate-core-4.0.1.Final is dragged in by some other dependency. Is this source of my problem? And if yes is there any way to find out what dependency is the black sheep?
My container is JBoss 7.1.1 and I am using Arquillian for tests. As IDE I use IntelliJ Idea 13.
mvn dependency:tree: http://pastebin.com/k4YM1DpY
UPDATE: I found out that hibernate 4.0.1 was dragged in by JBoss server itself. So I tried to ugrade Hibernate using this Updating the Hibernate 4.x jars to a different Hibernate 4.x version
However after doing this I am getting NoClassDefFoundError: org/jboss/as/jpa/hibernate4/JBossAppServerJtaPlatform.
00:18:36,088 ERROR [org.jboss.as.controller.management-operation] JBAS014612: Operation ("parallel-extension-add") failed - address: ([]): java.lang.RuntimeException: JBAS014670: Failed initializing module org.jboss.as.jpa
at org.jboss.as.controller.extension.ParallelExtensionAddHandler$1.execute(ParallelExtensionAddHandler.java:99) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:385) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.AbstractOperationContext.doCompleteStep(AbstractOperationContext.java:272) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.AbstractOperationContext.completeStep(AbstractOperationContext.java:200) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.ModelControllerImpl.boot(ModelControllerImpl.java:149) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:190) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.server.ServerService.boot(ServerService.java:291) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.server.ServerService.boot(ServerService.java:266) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:155) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]
Caused by: java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: org/jboss/as/jpa/hibernate4/JBossAppServerJtaPlatform
at java.util.concurrent.FutureTask.report(FutureTask.java:122) [rt.jar:1.7.0_51]
at java.util.concurrent.FutureTask.get(FutureTask.java:188) [rt.jar:1.7.0_51]
at org.jboss.as.controller.extension.ParallelExtensionAddHandler$1.execute(ParallelExtensionAddHandler.java:91) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
... 9 more
Caused by: java.lang.NoClassDefFoundError: org/jboss/as/jpa/hibernate4/JBossAppServerJtaPlatform
at org.jboss.as.jpa.hibernate4.HibernatePersistenceProviderAdaptor.injectJtaManager(HibernatePersistenceProviderAdaptor.java:59)
at org.jboss.as.jpa.processor.PersistenceProviderAdaptorLoader.loadPersistenceAdapterModule(PersistenceProviderAdaptorLoader.java:112)
at org.jboss.as.jpa.subsystem.JPAExtension.initialize(JPAExtension.java:118)
at org.jboss.as.controller.extension.ExtensionAddHandler.initializeExtension(ExtensionAddHandler.java:88) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.extension.ParallelExtensionAddHandler$ExtensionInitializeTask.call(ParallelExtensionAddHandler.java:127) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.extension.ParallelExtensionAddHandler$ExtensionInitializeTask.call(ParallelExtensionAddHandler.java:113) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at java.util.concurrent.FutureTask.run(FutureTask.java:262) [rt.jar:1.7.0_51]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_51]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_51]
at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]
at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.0.0.GA.jar:2.0.0.GA]
Caused by: java.lang.ClassNotFoundException: org.jboss.as.jpa.hibernate4.JBossAppServerJtaPlatform from [Module "org.jboss.as.jpa.hibernate:4" from local module loader #4e66ae7 (roots: d:\Programy\jboss-as-7.1.1.Final\modules)]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) [jboss-modules.jar:1.1.1.GA]
... 11 more
If you are somehow pulling in two org.hibernate:hibernate-core artifacts, dependency mediation should kick in and choose one. And there's no sign that you're pulling in two Hibernate artifacts with different coordinates from your dependency:tree output. So it sounds more like a misconfigured project than JAR hell per se, i.e. where you're pulling in conflicting libraries. If you want to be completely sure, though, check for duplicate files in your classpath using
mvn com.ning.maven.plugins:maven-duplicate-finder-plugin:1.0.4:check
which is a good JAR hell plugin.
Your POM file and dependency:tree output is showing your JBoss and Hibernate versions as RELEASE. I don't know if that's a JBoss thing, but it's unclear to me what version RELEASE corresponds to. You should try specifying versions in your dependency management section and seeing if the problem persists, e.g.
<dependencyManagement>
<dependencies>
...
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.4.Final</version>
</dependency>
</dependencies>
</dependencyManagement>
...
<dependencies>
...
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</dependency>
</dependencies>
This has the advantage that you fix the version of the dependency for your whole project, including transitive dependencies, instead of hoping dependency mediation picks the right one.
By the way, a simpler way to get what you need out of dependency:tree is to filter, in your case using
mvn dependency:tree -Dincludes=:*hibernate*::
Try to run this command in the same directory as the pom.xml:
mvn dependency:tree -Ddetail=true -Dincludes=org.hibernate:hibernate-core
This will give you the dependency tree of not only the hibernate-core that was chosen, but other versions dependencies that altough present, where not chosen because some other dependency took precendence.
When in doubt which transitive dependency to choose, maven applies the following rules:
the dependency that is the closest to the pom.xml project wins. for example if one version is two levels away in the tree and another 1 level away, the one 1 level away wins.
if all dependencies are at the same level of distance from the pom.xml artifact, the one that shows up first on the pom wins.
The solution for this problem is to see with the comand above everyone that is requiring hibernate-core, decide which version you want and add the proper exclusions.
EDIT: The problem is that JBoss 7 is an EJB container that includes JPA, and the JPA on the server is interfering with the JPA on the WAR. This is because by default JBoss 7 works in 'server first' mode, where it will fetch libraries first from the server and only if they don't exist from the application.
You can change this to 'server last', where the jars on your application always take precedence. This can be done by setting java2ParentDelegation=false in file jboss-app.xml or jboss-web.xml - see also this answer.
You can also turn off server modules one by one, but this is more error prone.
For that, create a file in src/main/resources/META-INF named jboss-deployment-structure.xml, and there turn off the hibernate/JPA modules on the server:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.hibernate" />
<module name="org.jboss.as.jpa" />
<module name="org.jboss.as.jpa.hibernate" />
...
</exclusions>
</deployment>
</jboss-deployment-structure>

Error loading DispatcherServlet's default strategy class

I m getting the following exception while trying to deploy the war file on Weblogic 10.3.6 server.
The application is using SPring mvc.
Error loading DispatcherServlet's default strategy class [org.springframework.web.servlet.mvc.support.Def
aultHandlerExceptionResolver] for interface [org.springframework.web.servlet.HandlerExceptionResolver]: problem with class file or dependent class; nested exception is
java.lang.NoClassDefFoundError: org/springframework/web/bind/MethodArgumentNotValidException
at org.springframework.web.servlet.DispatcherServlet.getDefaultStrategies(DispatcherServlet.java:766)
at org.springframework.web.servlet.DispatcherServlet.initHandlerExceptionResolvers(DispatcherServlet.java:604)
at org.springframework.web.servlet.DispatcherServlet.initStrategies(DispatcherServlet.java:423)
at org.springframework.web.servlet.DispatcherServlet.onRefresh(DispatcherServlet.java:410)
at org.springframework.web.servlet.FrameworkServlet.onApplicationEvent(FrameworkServlet.java:752)
at org.springframework.web.servlet.FrameworkServlet$ContextRefreshListener.onApplicationEvent(FrameworkServlet.java:989)
at org.springframework.web.servlet.FrameworkServlet$ContextRefreshListener.onApplicationEvent(FrameworkServlet.java:1)
at org.springframework.context.event.GenericApplicationListenerAdapter.onApplicationEvent(GenericApplicationListenerAdapter.java:51)
at org.springframework.context.event.SourceFilteringListener.onApplicationEventInternal(SourceFilteringListener.java:97)
at org.springframework.context.event.SourceFilteringListener.onApplicationEvent(SourceFilteringListener.java:68)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:324)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:929)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:467)
Your classpath doesn't have spring-web-x.x.x.jar, that's why the exception is. Please use Maven build tool for building your Spring MVC project. Add all the necessary dependencies in pom.xml. For spring-web 3.0.4 version, it would be
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.0.4.RELEASE</version>
</dependency>

SpringMvc - javax.validation.ValidationException

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
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.
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>
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>
I added hibernate-validator as a dependency in pom.xml and it worked
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>
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.

Categories