NoSuchMethodError: org.springframework.beans.factory.xml.XmlReaderContext.getEnvironment()Lorg/springframework/core/env/Environment; With zkoss

前端 未结 5 1128
囚心锁ツ
囚心锁ツ 2021-01-17 10:13

I am facing following error,

java.lang.NoSuchMethodError: org.springframework.beans.factory.xml.XmlReaderContext.getEnvironment()Lorg/springframework/core/e         


        
相关标签:
5条回答
  • 2021-01-17 10:45
    if using spring 3.17 
    use 
    <dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-jpa</artifactId>
    <version>1.6.6.RELEASE</version>
    </dependency>
    
    0 讨论(0)
  • 2021-01-17 10:49

    I had the same problem as you. Two hours finding was going wrong... After found your question and saw that probably it's a dependency problem.

    It is, I solved this issue just adding spring beans dependency

      <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>4.1.6.RELEASE</version>
      </dependency>
    
    0 讨论(0)
  • 2021-01-17 10:53

    This was for me a dependency compatibility problem between the spring jars and spring data.

    The versions before the error (no errors) :

    <spring.version>4.1.0.RELEASE</spring.version>
    <springdata.version>1.6.1.RELEASE</springdata.version> 
    

    After updating spring data to 1.10.2.RELEASE the error appends, resolved by upgrading spring version to 4.3.2.RELEASE :

    <spring.version>4.3.2.RELEASE</spring.version>
    <springdata.version>1.10.2.RELEASE</springdata.version>
    

    To ensure you use the correct spring version you can skip the maven declaration of the spring dependencies and keep only the spring data dependency. Or you can check in the maven repository which spring version is used by your spring data version and update consequentely.

    0 讨论(0)
  • 2021-01-17 11:06

    This error is pretty clear, The class

    org.springframework.beans.factory.xml.XmlReaderContext
    

    does not contain the method getEnvironment (java method notation)

    .getEnvironment()Lorg/springframework/core/env/Environment
    

    If you look at the Spring bean library that is included in you application, and run a javap -l on the class, you will probably notice that this method really does not exist...

    **javap.exe c:\XmlReaderContext.class** -l
    Compiled from "XmlReaderContext.java"
    public class org.springframework.beans.factory.xml.XmlReaderContext extends org.springframework.beans.factory.parsing.ReaderContext {
      public org.springframework.beans.factory.xml.XmlReaderContext(org.springframework.core.io.Resource, org.springframework.beans.factory.parsing.ProblemReporter, org.springframework.beans.factory.par
    aderEventListener, org.springframework.beans.factory.parsing.SourceExtractor, org.springframework.beans.factory.xml.XmlBeanDefinitionReader, org.springframework.beans.factory.xml.NamespaceHandlerRes
    
      public final org.springframework.beans.factory.xml.XmlBeanDefinitionReader getReader();
      public final org.springframework.beans.factory.support.BeanDefinitionRegistry getRegistry();
      public final org.springframework.core.io.ResourceLoader getResourceLoader();
      public final java.lang.ClassLoader getBeanClassLoader();
      public final org.springframework.beans.factory.xml.NamespaceHandlerResolver getNamespaceHandlerResolver();
      public java.lang.String generateBeanName(org.springframework.beans.factory.config.BeanDefinition);
      public java.lang.String registerWithGeneratedName(org.springframework.beans.factory.config.BeanDefinition);
      public org.w3c.dom.Document readDocumentFromString(java.lang.String);
    }
    

    Just upgrade to a later version that contains the method for this Spring bean dependency > 4.3.2

    Regards

    Sahi

    0 讨论(0)
  • 2021-01-17 11:06

    If this error is thrown at server during starting/deploying web application, then

    1. Find jar which contains mentioned class in your project org.springframework.beans.factory.xml.XmlReaderContext

    2. Try find the same jar at the server in common lib folder.

    3. Set the same version of jar or put provided scope in pom.xml file

    0 讨论(0)
提交回复
热议问题