web-dev-qa-db-ja.com

Tomcat 6にSpring 4.0をデプロイする際のAbstractMethodError

Tomcat 6.0.37でSpring 4.0.1アプリをデプロイする際に以下の例外が発生しています:

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

次の関連する依存関係が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
....
}

Tomcat 6にはEL 2.1が付属していますが、spring-beansとspring-webmvcはEL 2.2.4バージョンに依存しているため、エラーですか?もしそうなら、それを解決する方法は?また、Tomcat dirのライブラリを更新する権限もありません。

39
Vikas Sharma

エラーはELとは関係ありません。 javax.validation apiとhibernateに関係しています。

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

Hibernateバリデーター4.3.xは、javax.validation 1.0(JSR-303)の実装です。ただし、1.1 APIバージョンは含まれています。含まれているjavax.validationバージョンをダウングレードするか、Hibernateバリデーターを5.0.xにアップグレードします。

84
M. Deinum

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