# Caused by: java.lang.NoSuchMethodError: org.springframework.beans.factory.xml.XmlReaderContext.getEnvironment()Lorg/springframework/c

**URL:** <https://discuss.elastic.co/t/caused-by-java-lang-nosuchmethoderror-org-springframework-beans-factory-xml-xmlreadercontext-getenvironment-lorg-springframework-c/43999>\
**Category:** Elasticsearch\
**Created:** [March 10, 2016, 9:51am UTC](https://discuss.elastic.co/t/caused-by-java-lang-nosuchmethoderror-org-springframework-beans-factory-xml-xmlreadercontext-getenvironment-lorg-springframework-c/43999 "2016-03-10T09:51:40Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![prashanthrd](https://avatars.discourse-cdn.com/v4/letter/p/50afbb/32.png) [@prashanthrd](https://discuss.elastic.co/u/prashanthrd)\
**Post date:** [March 10, 2016, 9:51am UTC](https://discuss.elastic.co/t/caused-by-java-lang-nosuchmethoderror-org-springframework-beans-factory-xml-xmlreadercontext-getenvironment-lorg-springframework-c/43999/1 "2016-03-10T09:51:40Z")

</div>

Hi,

I am trying to load an XML file consisting of elasticsearch properties. In the jave spring web application, I am trying to load the xml file using the below line -  
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");

applicationContext.xml is located under src/main/reosurces.

Below errors I am getting when I run the application from UI.

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;  
Caused by: java.lang.NoSuchMethodError: org.springframework.beans.factory.xml.XmlReaderContext.getEnvironment()Lorg/springframework/core/env/Environment;

Can anyone please suggest on this.

Thanks in advance...

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 10, 2016, 10:12am UTC](https://discuss.elastic.co/t/caused-by-java-lang-nosuchmethoderror-org-springframework-beans-factory-xml-xmlreadercontext-getenvironment-lorg-springframework-c/43999/2 "2016-03-10T10:12:39Z")

</div>

Wrong mailing list I guess. Not related to elasticsearch here.

---

<div class="post-metadata">

**Author:** ![prashanthrd](https://avatars.discourse-cdn.com/v4/letter/p/50afbb/32.png) [@prashanthrd](https://discuss.elastic.co/u/prashanthrd)\
**Post date:** [March 10, 2016, 12:44pm UTC](https://discuss.elastic.co/t/caused-by-java-lang-nosuchmethoderror-org-springframework-beans-factory-xml-xmlreadercontext-getenvironment-lorg-springframework-c/43999/3 "2016-03-10T12:44:31Z")

</div>

Yes this is related to spring framework, but I get the error in my XML also when I add the following line -

xmlns:elasticsearch="[http://www.springframework.org/schema/data/elasticsearch](http://www.springframework.org/schema/data/elasticsearch)"

\<elasticsearch:repositories base-package="com.xx.daos.elasticsearch.report"/\>

Error occured processing XML 'org.springframework.beans.factory.xml.XmlReaderContext.getEnvironment()Lorg/springframework/  
core/env/Environment;'.

could you please suggest.

---

<div class="post-metadata">

**Author:** ![prashanthrd](https://avatars.discourse-cdn.com/v4/letter/p/50afbb/32.png) [@prashanthrd](https://discuss.elastic.co/u/prashanthrd)\
**Post date:** [March 10, 2016, 12:45pm UTC](https://discuss.elastic.co/t/caused-by-java-lang-nosuchmethoderror-org-springframework-beans-factory-xml-xmlreadercontext-getenvironment-lorg-springframework-c/43999/4 "2016-03-10T12:45:43Z")

</div>

One more line is missing in my previous message. This is the line where we get error.

\<elasticsearch:repositories base-package="com.pn.daos.elasticsearch.report"/\>

---

<div class="post-metadata">

**Author:** ![prashanthrd](https://avatars.discourse-cdn.com/v4/letter/p/50afbb/32.png) [@prashanthrd](https://discuss.elastic.co/u/prashanthrd)\
**Post date:** [March 10, 2016, 12:46pm UTC](https://discuss.elastic.co/t/caused-by-java-lang-nosuchmethoderror-org-springframework-beans-factory-xml-xmlreadercontext-getenvironment-lorg-springframework-c/43999/5 "2016-03-10T12:46:46Z")

</div>

"\<elasticsearch:repositories base-package="com.pn.daos.elasticsearch.report"/\>"

---

<div class="post-metadata">

**Author:** ![prashanthrd](https://avatars.discourse-cdn.com/v4/letter/p/50afbb/32.png) [@prashanthrd](https://discuss.elastic.co/u/prashanthrd)\
**Post date:** [March 10, 2016, 12:48pm UTC](https://discuss.elastic.co/t/caused-by-java-lang-nosuchmethoderror-org-springframework-beans-factory-xml-xmlreadercontext-getenvironment-lorg-springframework-c/43999/6 "2016-03-10T12:48:02Z")

</div>

Sorry, I was trying to send one line containing \<\> brackets, it is not posted. Therefore, I had to post so many times. I removed the brackets and posting it.  
elasticsearch:repositories base-package="com.pn.daos.elasticsearch.report"

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 10, 2016, 1:00pm UTC](https://discuss.elastic.co/t/caused-by-java-lang-nosuchmethoderror-org-springframework-beans-factory-xml-xmlreadercontext-getenvironment-lorg-springframework-c/43999/7 "2016-03-10T13:00:27Z")

</div>

It's because you are not formatting your code before posting.

```auto
<test></test>

```

Works well...

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 10, 2016, 1:01pm UTC](https://discuss.elastic.co/t/caused-by-java-lang-nosuchmethoderror-org-springframework-beans-factory-xml-xmlreadercontext-getenvironment-lorg-springframework-c/43999/8 "2016-03-10T13:01:29Z")

</div>

Here probably your `applicationContext.xml` is wrong or you are missing some libs or you are using an incompatible version of Spring...

Well. Hard to know without details.

---

<div class="post-metadata">

**Author:** ![prashanthrd](https://avatars.discourse-cdn.com/v4/letter/p/50afbb/32.png) [@prashanthrd](https://discuss.elastic.co/u/prashanthrd)\
**Post date:** [March 10, 2016, 1:17pm UTC](https://discuss.elastic.co/t/caused-by-java-lang-nosuchmethoderror-org-springframework-beans-factory-xml-xmlreadercontext-getenvironment-lorg-springframework-c/43999/9 "2016-03-10T13:17:52Z")

</div>

I am using  
spring-data-elasticsearch-1.3.2.RELEASE.jar  
spring-data-commons-1.11.2.RELEASE.jar

And all other spring jars like spring-beans, spring-context, spring-core, ...etc of 4.0.2 version.  
Are these versions compatible with spring-data-elasticsearch ?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 10, 2016, 1:36pm UTC](https://discuss.elastic.co/t/caused-by-java-lang-nosuchmethoderror-org-springframework-beans-factory-xml-xmlreadercontext-getenvironment-lorg-springframework-c/43999/10 "2016-03-10T13:36:43Z")

</div>

I don't know.

I'd try to locate where class `org.springframework.beans.factory.xml.XmlReaderContext` lives and if the method `getEnvironment()` method exists in this jar.

But I think you'd better ask this in Spring forums.

---

<div class="post-metadata">

**Author:** ![prashanthrd](https://avatars.discourse-cdn.com/v4/letter/p/50afbb/32.png) [@prashanthrd](https://discuss.elastic.co/u/prashanthrd)\
**Post date:** [March 10, 2016, 2:41pm UTC](https://discuss.elastic.co/t/caused-by-java-lang-nosuchmethoderror-org-springframework-beans-factory-xml-xmlreadercontext-getenvironment-lorg-springframework-c/43999/11 "2016-03-10T14:41:40Z")

</div>

> [@dadoonet](#):
>
> XmlReaderContext

Thanks, will do it..

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:09pm UTC](https://discuss.elastic.co/t/caused-by-java-lang-nosuchmethoderror-org-springframework-beans-factory-xml-xmlreadercontext-getenvironment-lorg-springframework-c/43999/12 "2017-07-05T23:09:28Z")

</div>


