복붙노트

[SPRING] java.lang.NoSuchMethodError org.springframework.core.annotation.AnnotationUtils.getAnnotation

SPRING

java.lang.NoSuchMethodError org.springframework.core.annotation.AnnotationUtils.getAnnotation

junit 테스트를 실행할 때 올바른 결과를 얻을 수 있고 데이터를 데이터베이스에 저장할 수 있습니다.

내가 tomcat에 프로젝트를 배포 할 때, 나는이 예외를 얻었다.

내 봄 버전은 3.1.1이고 톰캣 버전은 6.0입니다.

2012-02-29-16:40:54,968 ERROR   - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0': Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotationUtils.getAnnotation(Ljava/lang/reflect/AnnotatedElement;Ljava/lang/Class;)Ljava/lang/annotation/Annotation;
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
    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.deployApps(HostConfig.java:563)
    at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1399)
    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.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
    at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1500)
    at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:670)
    at org.apache.catalina.manager.ManagerServlet.doPut(ManagerServlet.java:435)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:640)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:563)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:619)

작동하지 않습니다 ):

Pom.hml :

<properties>
        <spring.version>3.1.1.RELEASE</spring.version>
        <hibernate.version>3.6.9.Final</hibernate.version>
        <jdbc.driver.groupId>mysql</jdbc.driver.groupId>
        <jdbc.driver.artifactId>mysql-connector-java</jdbc.driver.artifactId>
        <jdbc.driver.version>5.1.13</jdbc.driver.version>
    </properties>

    <dependencies>

        <!-- Spring 3 dependencies -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>


        <!-- spring tx -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>1.6.12</version>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>1.6.12</version>
        </dependency>
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib-nodep</artifactId>
            <version>2.2.2</version>
        </dependency>
        <!-- asm -->
        <dependency>
            <groupId>asm</groupId>
            <artifactId>asm</artifactId>
            <version>3.3.1</version>
        </dependency>
        <!-- SPRING end -->

        <!-- jstl -->
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.1.2</version>
        </dependency>

        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <version>1.1.2</version>
        </dependency>


        <!-- LOGGING begin -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <optional>true</optional>
            <version>1.6.4</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <optional>true</optional>
            <version>1.6.4</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <optional>true</optional>
            <version>1.2.15</version>
        </dependency>
        <!-- LOGGING end -->





        <!-- PERSISTENCE begin -->
        <!-- hibernate -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>${hibernate.version}</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>${hibernate.version}</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-ehcache</artifactId>
            <version>${hibernate.version}</version>
        </dependency>
        <dependency>
            <groupId>org.javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.15.0-GA</version>
        </dependency>
        <!-- PERSISTENCE end -->

        <!-- dbcp connection pool -->
        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.4</version>
        </dependency>


        <!-- spring orm -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${spring.version}</version>
        </dependency>


        <!-- jdbc driver -->
        <dependency>
            <groupId>${jdbc.driver.groupId}</groupId>
            <artifactId>${jdbc.driver.artifactId}</artifactId>
            <version>${jdbc.driver.version}</version>
            <scope>runtime</scope>
        </dependency>


    </dependencies>

해결법

  1. ==============================

    1.올바른 서명은 다음과 같습니다.

    올바른 서명은 다음과 같습니다.

    public static <A extends Annotation> A getAnnotation(Method method,
                                                     Class<A> annotationType)
    

    하지만 뭔가가 전화를하려고합니다.

    public static <A extends Annotation> A getAnnotation(AnnotatedElement element,
                                                     Class<A> annotationType)
    

    두 번째 방법은 Spring 3.2.0 (적어도 Spring 3.0까지 API에서 발견되지 않음) Spring 3.1 (Sebastien 덕분에)에서 소개되었으므로 응용 프로그램을 빌드하기 위해 Spring 3.1 이상을 사용했을 가능성이 높습니다. 3.1에 바람둥이. 그 방향으로 조사하십시오.

  2. ==============================

    2.원인과 함께 전체 스택을 더 잘 처리하면 도움이 될 것입니다 (이 경우 많지는 않지만 항상 좋습니다).

    원인과 함께 전체 스택을 더 잘 처리하면 도움이 될 것입니다 (이 경우 많지는 않지만 항상 좋습니다).

    NoSuchMethodError를 얻었으므로 AnnotationUtils 클래스가 있지만 getAnnotation이라는 메서드를 찾을 수없는 것 같습니다. 그래서 런타임에 클래스의 잘못된 버전을 사용할 수 있다고 생각합니다.

    webapp 폴더에서 배포되는 스프링의 버전을 확인하고 버전에 "getAnnotation"메소드가 있는지 확인해야합니다.

    거기에서 확인할 수 있습니다. https://fisheye.springsource.org/browse/spring-framework/org.springframework.core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java

    클래스가 마스터 브랜치에서 재구성되었다는 것을주의하십시오 (당신은 그것을 사용하고 있습니까?)

    또한 mvn 의존성을 수행해야합니다 : 트리와 여기에서 스프링 버전을 확인하고 여기에 여러 가지 스프링 버전이 없는지 확인하십시오. 그렇다면 종속성 제외 또는 maven의 종속성 관리 태그를 사용하여 정확하게 지정하십시오 사용할 버전

  3. ==============================

    3.Tomcat의 인스턴스에 Spring 라이브러리를 올바르게 배치하지 않았다.

    Tomcat의 인스턴스에 Spring 라이브러리를 올바르게 배치하지 않았다.

  4. from https://stackoverflow.com/questions/9496413/java-lang-nosuchmethoderror-org-springframework-core-annotation-annotationutils by cc-by-sa and MIT license