Results 1 to 2 of 2

Thread: Exception NoSuchMethod XmlWebApplicationContext.getEnvironment() exception

  1. #1
    Join Date
    May 2011
    Posts
    16

    Default Exception NoSuchMethod XmlWebApplicationContext.getEnvironment() exception

    I am using Spring 3.1.0.M1 and deploying my sample application to Tomcat 7.0.14. When I add a listener web.xml such as:

    Code:
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    I get the following exception:

    Code:
    Jun 7, 2011 9:38:18 PM org.apache.catalina.core.StandardContext listenerStart
    SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
    java.lang.NoSuchMethodError: org.springframework.web.context.support.XmlWebApplicationContext.getEnvironment()Lorg/springframework/core/env/ConfigurableEnvironment;
    	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:87)
    	at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
    	at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:397)
    	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:294)
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:215)
    	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
    	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
    	at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
    	at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
    	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    	at java.lang.Thread.run(Thread.java:662)
    I also have context config location setup in web.xml as:

    Code:
      <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
          classpath:appctx-printer-webapp-printer-selector.xml
        </param-value>
      </context-param>
    The appctx-printer-webapp-printer-selector.xml is in .war\WEB-INF\classes directory and currently does not contain any beans.

    Can someone hint as to what the solution may be?

    Thanks.
    -AP_

  2. #2
    Join Date
    May 2011
    Posts
    16

    Default

    Looks like it was a conflict with some different versions of Spring dependencies. Somehow old versions got into the target build directory, and so they were being included in my final .war regardless of what my dependency section stated. This was resolved by mvn clean and package.

    -AP_

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •