[SPRING] applicationContext.xml를 해석하면 java.lang.NoSuchMethodError가 렌더링됩니다. 이것은 종속성 문제로 인해 발생할 수 있습니까?
SPRINGapplicationContext.xml를 해석하면 java.lang.NoSuchMethodError가 렌더링됩니다. 이것은 종속성 문제로 인해 발생할 수 있습니까?
주석이 달린 응용 프로그램 컨텍스트 (@ContextConfiguration (locations = { "classpath : applicationContext.xml"}))가있는 테스트 메서드 (Junit)를 호출하고 있습니다. 다음 스택 추적으로 테스트가 실패합니다.
11:20:39.793 [main] ERROR o.s.test.context.TestContextManager - Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@28419cd] to prepare test instance [com.atrioom.TestDynamo@7fbdc7db]
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:91) ~[spring-test-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.test.context.DefaultTestContext.getApplicationContext(DefaultTestContext.java:74) ~[spring-test-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:116) ~[spring-test-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:82) ~[spring-test-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:212) ~[spring-test-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:199) [spring-test-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:251) [spring-test-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.11.jar:na]
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:253) [spring-test-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:216) [spring-test-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:82) [spring-test-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) [junit-4.11.jar:na]
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) [junit-4.11.jar:na]
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) [junit-4.11.jar:na]
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) [junit-4.11.jar:na]
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) [junit-4.11.jar:na]
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:60) [spring-test-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:67) [spring-test-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.junit.runners.ParentRunner.run(ParentRunner.java:309) [junit-4.11.jar:na]
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:162) [spring-test-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) [.cp/:na]
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) [.cp/:na]
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) [.cp/:na]
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) [.cp/:na]
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) [.cp/:na]
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) [.cp/:na]
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [applicationContext.xml]; nested exception is java.lang.NoSuchMethodError: org.springframework.beans.factory.xml.XmlReaderContext.getEnvironment()Lorg/springframework/core/env/Environment;
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:413) ~[spring-beans-4.0.7.RELEASE.jar:4.0.7.RELEASE]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335) ~[spring-beans-4.0.7.RELEASE.jar:4.0.7.RELEASE]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303) ~[spring-beans-4.0.7.RELEASE.jar:4.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180) ~[spring-beans-4.0.7.RELEASE.jar:4.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:216) ~[spring-beans-4.0.7.RELEASE.jar:4.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:187) ~[spring-beans-4.0.7.RELEASE.jar:4.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:251) ~[spring-beans-4.0.7.RELEASE.jar:4.0.7.RELEASE]
at org.springframework.test.context.support.AbstractGenericContextLoader.loadBeanDefinitions(AbstractGenericContextLoader.java:253) ~[spring-test-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:122) ~[spring-test-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60) ~[spring-test-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:108) ~[spring-test-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:260) ~[spring-test-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.test.context.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:63) ~[spring-test-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.test.context.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:83) ~[spring-test-4.1.1.RELEASE.jar:4.1.1.RELEASE]
... 25 common frames omitted
Caused by: java.lang.NoSuchMethodError: org.springframework.beans.factory.xml.XmlReaderContext.getEnvironment()Lorg/springframework/core/env/Environment;
at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:81) ~[spring-context-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:74) ~[spring-beans-4.0.7.RELEASE.jar:4.0.7.RELEASE]
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1424) ~[spring-beans-4.0.7.RELEASE.jar:4.0.7.RELEASE]
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1414) ~[spring-beans-4.0.7.RELEASE.jar:4.0.7.RELEASE]
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:187) ~[spring-beans-4.0.7.RELEASE.jar:4.0.7.RELEASE]
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:141) ~[spring-beans-4.0.7.RELEASE.jar:4.0.7.RELEASE]
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:110) ~[spring-beans-4.0.7.RELEASE.jar:4.0.7.RELEASE]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:508) ~[spring-beans-4.0.7.RELEASE.jar:4.0.7.RELEASE]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391) ~[spring-beans-4.0.7.RELEASE.jar:4.0.7.RELEASE]
... 38 common frames omitted
문제점은 누락 된 메소드 (org.springframework.beans.factory.xml.XmlReaderContext.getEnvironment ())라고 생각합니다. 라인을 올바르게 읽는 방법을 모르겠다. Lorg / springframework / core / env / Environment를 추가하면 닫힌 괄호가 혼란 스럽다. applicationContext.xml과 다른 Spring 버전에서 다른 bean 버전을 시도했습니다.
이것은 내 applicationContext입니다.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd">
<context:component-scan base-package="com.atrioom" />
<context:annotation-config />
해결법
-
==============================
1.방금 Spring 4.1.1.RELEASE, Spring Security 3.2.5.RELEASE 및 OAuth2 2.0.3.RELEASE로이 문제가 발생했습니다. getEnvironment 메소드가 필요한 것은 OAuth2입니다.
방금 Spring 4.1.1.RELEASE, Spring Security 3.2.5.RELEASE 및 OAuth2 2.0.3.RELEASE로이 문제가 발생했습니다. getEnvironment 메소드가 필요한 것은 OAuth2입니다.
스프링 보안 의존성 중 하나가 getEnvironment를 가지고 있지 않은 Spring Beans 4.0.3.RELEASE를 다운로드했습니다. Spring Bean을 명시 적으로 정의하여 수정했습니다. 4.1.1.RELEASE를 종속성으로 지정했습니다.
-
==============================
2.Jens와 Xstian이 암시 하듯이, 클래스 패스에있는 항아리의 일부 버전에 문제가있었습니다. mvn 새로 설치 -U를 수행하여 문제가 해결되었습니다. 나는이 질문을 게시하기 전에 그것을 시도했지만 때로는 단지 속임수를 사용하는 것처럼 보이지 않는 경우가 있습니다.
Jens와 Xstian이 암시 하듯이, 클래스 패스에있는 항아리의 일부 버전에 문제가있었습니다. mvn 새로 설치 -U를 수행하여 문제가 해결되었습니다. 나는이 질문을 게시하기 전에 그것을 시도했지만 때로는 단지 속임수를 사용하는 것처럼 보이지 않는 경우가 있습니다.
from https://stackoverflow.com/questions/26754982/parsing-applicationcontext-xml-renders-a-java-lang-nosuchmethoderror-could-th by cc-by-sa and MIT license
'SPRING' 카테고리의 다른 글
[SPRING] Jackson, 참조의 한 속성을 직렬화 (0) | 2019.05.09 |
---|---|
[SPRING] Spring 3 MVC 디스패처 xml 및 applicationContext xml (0) | 2019.05.09 |
[SPRING] BeanDefinitionParser를 Spring 웹 서비스 요소로 찾을 수 없다. (0) | 2019.05.09 |
[SPRING] Spring @ExceptionHandler 및 멀티 스레딩 (0) | 2019.05.09 |
[SPRING] 하나의 컨트롤러를 Spring MVC의 다른 컨트롤러 URL로 호출하는 방법은 무엇입니까? (0) | 2019.05.09 |