복붙노트

[SPRING] 스프링 코어 3.2.2 + 스프링 보안 3.1.4 : java.lang.IncompatibleClassChangeError : org.springframework.asm.ClassVisitor

SPRING

스프링 코어 3.2.2 + 스프링 보안 3.1.4 : java.lang.IncompatibleClassChangeError : org.springframework.asm.ClassVisitor

Spring 3.2.2 옆에 Spring 보안 3.1.4를 추가했을 때, 아래에이 추악한 예외가 있습니다. 나는 그것을 봤는데 같은 오류에 대해서만이 링크를 가지고 : http://forum.springsource.org/showthread.php?133706-Spring-3-2-0-RELEASE-breaks-with-JBoss-7 Spring-asm이 현재 Spring-core에 있다고 설명하는 Spring JIRA를 가리키고 있습니다. https://jira.springsource.org/browse/SPR-10134

어떻게 든 스프링 보안에서 스프링 쉼표를 제외해야한다고 생각했습니다.

여기에 제가 가진 예외가 있습니다 :

java.lang.IncompatibleClassChangeError: class org.springframework.core.LocalVariableTableParameterNameDiscoverer$ParameterNameDiscoveringVisitor has interface org.springframework.asm.ClassVisitor as super class
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java:791)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2895)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1173)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
org.springframework.core.LocalVariableTableParameterNameDiscoverer.inspectClass(LocalVariableTableParameterNameDiscoverer.java:112)
org.springframework.core.LocalVariableTableParameterNameDiscoverer.getParameterNames(LocalVariableTableParameterNameDiscoverer.java:85)
org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:193)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1051)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:955)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:490)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626)
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:651)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:599)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:665)
org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:518)
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:459)
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
javax.servlet.GenericServlet.init(GenericServlet.java:160)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1008)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:722)

해결법

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

    1.그럼 내가 발견 : http://www.mkyong.com/mongodb/spring-asm-dependency-issue-in-spring-data/ 스프링 데이터에서도 비슷한 문제가 발생합니다. pom.xml의 배제는 다음과 같이 잘 작동합니다.

    그럼 내가 발견 : http://www.mkyong.com/mongodb/spring-asm-dependency-issue-in-spring-data/ 스프링 데이터에서도 비슷한 문제가 발생합니다. pom.xml의 배제는 다음과 같이 잘 작동합니다.

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>3.1.4.RELEASE</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-asm</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    

    같은 오류가 발생하는 사람들을위한 솔루션을 공유합니다!

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

    2.문제는 Spring Security 3.1.4가 Spring 3.0.7에 의존하기 때문에 Spring-Aop 3.0.7을 가져 오는 것으로 끝난다. Spring-Aop 3.0.7은 Spring-asm 3.0.7을 가져온다. 당신이하고 싶은 일은 maven의 dependencyManagement 섹션을 사용하여 스프링 흠도가 최신 버전을 사용하도록하는 것입니다 :

    문제는 Spring Security 3.1.4가 Spring 3.0.7에 의존하기 때문에 Spring-Aop 3.0.7을 가져 오는 것으로 끝난다. Spring-Aop 3.0.7은 Spring-asm 3.0.7을 가져온다. 당신이하고 싶은 일은 maven의 dependencyManagement 섹션을 사용하여 스프링 흠도가 최신 버전을 사용하도록하는 것입니다 :

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aop</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <!-- etc... 
              -- enumerate all Spring sub-projects here that spring-security includes 
              -->
            </dependency>
        </dependencies>
    </dependencyManagement>
    

    mvn dependency : tree를 실행하여 모든 의존성을 제거했는지 확인할 수 있습니다.

    예를 들어, dependencyManagement를 사용하기 전에, 내 mvn 종속성 : 트리 출력은 다음과 같습니다.

    [INFO] +- org.springframework.security:spring-security-core:jar:3.1.4.RELEASE:compile
    [INFO] |  +- org.springframework:spring-aop:jar:3.0.7.RELEASE:compile
    [INFO] |  |  \- org.springframework:spring-asm:jar:3.0.7.RELEASE:compile
    [INFO] |  +- org.springframework:spring-core:jar:3.2.3.RELEASE:compile (version managed from 3.0.7.RELEASE)
    [INFO] |  +- org.springframework:spring-context:jar:3.0.7.RELEASE:compile
    [INFO] |  +- org.springframework:spring-beans:jar:3.0.7.RELEASE:compile
    [INFO] |  \- org.springframework:spring-expression:jar:3.0.7.RELEASE:compile
    [INFO] +- org.springframework.security:spring-security-config:jar:3.1.4.RELEASE:compile
    [INFO] +- org.springframework.security:spring-security-web:jar:3.1.4.RELEASE:compile
    [INFO] |  +- org.springframework:spring-jdbc:jar:3.0.7.RELEASE:compile
    [INFO] |  +- org.springframework:spring-web:jar:3.0.7.RELEASE:compile
    [INFO] |  \- org.springframework:spring-tx:jar:3.0.7.RELEASE:compile
    

    특히 처음 세 행은 봄 - 웅덩이가 봄을 가져 오는 곳입니다. 충분한 dependencyManagement 선언을 추가 한 후 다음을 얻습니다.

    [INFO] +- org.springframework.security:spring-security-core:jar:3.1.4.RELEASE:compile
    [INFO] |  +- org.springframework:spring-aop:jar:3.2.3.RELEASE:compile (version managed from 3.0.7.RELEASE)
    [INFO] |  +- org.springframework:spring-core:jar:3.2.3.RELEASE:compile (version managed from 3.0.7.RELEASE)
    [INFO] |  +- org.springframework:spring-context:jar:3.2.3.RELEASE:compile (version managed from 3.0.7.RELEASE)
    [INFO] |  +- org.springframework:spring-beans:jar:3.2.3.RELEASE:compile (version managed from 3.0.7.RELEASE)
    [INFO] |  \- org.springframework:spring-expression:jar:3.2.3.RELEASE:compile (version managed from 3.0.7.RELEASE)
    [INFO] +- org.springframework.security:spring-security-config:jar:3.1.4.RELEASE:compile
    [INFO] +- org.springframework.security:spring-security-web:jar:3.1.4.RELEASE:compile
    [INFO] |  +- org.springframework:spring-jdbc:jar:3.2.3.RELEASE:compile (version managed from 3.0.7.RELEASE)
    [INFO] |  +- org.springframework:spring-web:jar:3.2.3.RELEASE:compile (version managed from 3.0.7.RELEASE)
    [INFO] |  \- org.springframework:spring-tx:jar:3.2.3.RELEASE:compile (version managed from 3.0.7.RELEASE)
    

    새로운 스프링 에이프이 (spring-aop)가 그것을 필요로하지 않기 때문에 스프링 어샘 (spring-asm)이 더 이상 포함되지 않는 것을 주목하십시오.

    이것은 스프링 참조를 추가 할 수있는 다른 모든 타사 종속성에 적용되므로 위의 대답에서 제외 된 것보다 Spring 버전을 관리하는보다 명확한 방법입니다.

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

    3.pom.xml에 다음 종속성을 추가하십시오.

    pom.xml에 다음 종속성을 추가하십시오.

    <dependency>  
        <groupId>org.springframework</groupId>  
        <artifactId>spring-core</artifactId>  
        <version>3.2.4.RELEASE</version>  
    </dependency>  
    <dependency>  
        <groupId>org.springframework</groupId>  
        <artifactId>spring-asm</artifactId>  
        <version>3.1.4.RELEASE</version>  
    </dependency>
    
  4. from https://stackoverflow.com/questions/16801639/spring-core-3-2-2-spring-security-3-1-4-java-lang-incompatibleclasschangeerro by cc-by-sa and MIT license