web-dev-qa-db-fra.com

AbstractMethodError lors du déploiement de Spring 4.0 dans Tomcat 6

Je reçois une exception sous le déploiement de l'application Spring 4.0.1 dans Tomcat 6.0.37:

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.validation.beanvalidation.OptionalValidatorFactoryBean#0': Invocation of init method failed; nested exception is Java.lang.AbstractMethodError: org.hibernate.validator.internal.engine.ConfigurationImpl.getDefaultParameterNameProvider()Ljavax/validation/ParameterNameProvider;
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.Java:1553)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.Java:539)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.Java:475)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.Java:304)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.Java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.Java:300)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.Java:195)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.Java:700)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.Java:760)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.Java:482)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.Java:403)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.Java:306)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.Java:106)
    at org.Apache.catalina.core.StandardContext.listenerStart(StandardContext.Java:4206)
    at org.Apache.catalina.core.StandardContext.start(StandardContext.Java:4705)
    at org.Apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.Java:799)
    at org.Apache.catalina.core.ContainerBase.addChild(ContainerBase.Java:779)
    at org.Apache.catalina.core.StandardHost.addChild(StandardHost.Java:601)
    at org.Apache.catalina.startup.HostConfig.deployWAR(HostConfig.Java:943)
    at org.Apache.catalina.startup.HostConfig.deployWARs(HostConfig.Java:778)
    at org.Apache.catalina.startup.HostConfig.deployApps(HostConfig.Java:504)
    at org.Apache.catalina.startup.HostConfig.start(HostConfig.Java:1317)
    at org.Apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.Java:324)
    at org.Apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.Java:142)
    at org.Apache.catalina.core.ContainerBase.start(ContainerBase.Java:1065)
    at org.Apache.catalina.core.StandardHost.start(StandardHost.Java:840)
    at org.Apache.catalina.core.ContainerBase.start(ContainerBase.Java:1057)
    at org.Apache.catalina.core.StandardEngine.start(StandardEngine.Java:463)
    at org.Apache.catalina.core.StandardService.start(StandardService.Java:525)
    at org.Apache.catalina.core.StandardServer.start(StandardServer.Java:754)
    at org.Apache.catalina.startup.Catalina.start(Catalina.Java:595)
    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.Apache.catalina.startup.Bootstrap.start(Bootstrap.Java:289)
    at org.Apache.catalina.startup.Bootstrap.main(Bootstrap.Java:414)
Caused by: Java.lang.AbstractMethodError: org.hibernate.validator.internal.engine.ConfigurationImpl.getDefaultParameterNameProvider()Ljavax/validation/ParameterNameProvider;
    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.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.Java:191)
    at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.Java:176)
    at org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.configureParameterNameProviderIfPossible(LocalValidatorFactoryBean.Java:276)
    at org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.afterPropertiesSet(LocalValidatorFactoryBean.Java:245)
    at org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean.afterPropertiesSet(OptionalValidatorFactoryBean.Java:40)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.Java:1612)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.Java:1549)
    ... 36 more

Les dépendances associées suivantes sont ajoutées dans build.gradle:

dependencies {

providedCompile "javax.servlet:servlet-api:2.5"
providedCompile "javax.servlet.jsp:jsp-api:2.2"
providedCompile "javax.el:el-api:2.2"
compile "javax.servlet.jsp.jstl:jstl-api:1.2"
compile "org.glassfish.web:jstl-impl:1.2"

compile "org.slf4j:jcl-over-slf4j:1.7.6"
compile "org.slf4j:slf4j-api:1.7.6"

compile ("org.hibernate:hibernate-validator:4.3.1.Final") {
exclude group: "javax.xml.bind", module: "jaxb-api"
exclude group: "com.Sun.xml.bind", module: "jaxb-impl"
}

compile "javax.validation:validation-api:1.1.0.Final"

// Spring 4.0.1 and other dependencies below
....
}

L'erreur est due aux spring-beans et spring-webmvc dépend de la version EL 2.2.4 alors que Tomcat 6 est livré avec EL 2.1. Si oui, comment le résoudre? De plus, je n'ai pas le droit de mettre à jour les bibliothèques dans le répertoire Tomcat.

39
Vikas Sharma

L'erreur n'a rien à voir avec l'EL. Cela a tout à voir avec l'API javax.validation Et l'hibernation.

Java.lang.AbstractMethodError: org.hibernate.validator.internal.engine.ConfigurationImpl.getDefaultParameterNameProvider()Ljavax/validation/ParameterNameProvider

Le validateur Hibernate 4.3.x est une implémentation de javax.validation 1.0 (JSR-303). Cependant, vous incluez la version 1.1 de l'API. Vous pouvez soit rétrograder la version javax.validation Incluse, soit mettre à niveau votre validateur hibernate vers 5.0.x.

84
M. Deinum

Vérifiez s'il y a plusieurs références au validateur dans votre fichier pom

<?xml version="1.0" encoding="UTF-8"?>
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-validator</artifactId>
    <version>${hibernate-val.version}</version>
</dependency>
1
user6883707