title: Spring MVC 4.2 - An issue with Class and Method Level Mapping
body: <p>I have an issue when try to access URL defined using class + method level mappings. Only method level works BUT NOT when class + method both have mappings defined.</p>
  
  <p>I meant below URL works which are on METHOD level mapping only.
  <a href="http://localhost:7001/SpringMVCFirstApp/hi" rel="nofollow noreferrer">http://localhost:7001/SpringMVCFirstApp/hi</a></p>
  
  <p><a href="http://localhost:7001/SpringMVCFirstApp/hello" rel="nofollow noreferrer">http://localhost:7001/SpringMVCFirstApp/hello</a></p>
  
  <p>But if I try to access CLASS + METHOD level mapping URL it does NOT work.
  <a href="http://localhost:7001/SpringMVCFirstApp/greet/hi" rel="nofollow noreferrer">http://localhost:7001/SpringMVCFirstApp/greet/hi</a></p>
  
  <p><a href="http://localhost:7001/SpringMVCFirstApp/greet/hello" rel="nofollow noreferrer">http://localhost:7001/SpringMVCFirstApp/greet/hello</a> ......... where /greet is defined on the class level as below.</p>
  
  <p>I use Spring 4.2.0, Weblogic 10.3.6 (11gR1) and Eclipse IDE.</p>
  
  <p>Following .jar files added under <strong>/WEB-INF/lib</strong> folder.</p>
  
  <pre><code>commons-logging-1.2.jar
  spring-beans-4.2.0.RELEASE.jar
  spring-context-4.2.0.RELEASE.jar
  spring-context-support-4.2.0.RELEASE.jar
  spring-core-4.2.0.RELEASE.jar
  spring-expression-4.2.0.RELEASE.jar
  spring-web-4.2.0.RELEASE.jar
  spring-webmvc-4.2.0.RELEASE.jar
  </code></pre>
  
  <p><strong>My controller</strong></p>
  
  <pre><code>package au.com.snh.controllers;
  
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.servlet.ModelAndView;;
  
  @Controller
  @RequestMapping("/greet")
  public class HelloController {
  
      @RequestMapping(value = "/hello", method = RequestMethod.GET)
      public ModelAndView sayHello(){
          ModelAndView model = new ModelAndView("hello");
          model.addObject("msg","Hello Spring MVC");
  
          return model;
      }
  
      @RequestMapping("/hi")
      public ModelAndView sayHi(){
          ModelAndView model = new ModelAndView("hi");
          model.addObject("msg","Hi Spring MVC");
  
          return model;
      }   
  
  }
  </code></pre>
  
  <p><strong>My web.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
   &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
      id="WebApp_ID" version="2.5"&gt;
      &lt;display-name&gt;SpringMVCFirstApp&lt;/display-name&gt;
  
      &lt;servlet&gt;
          &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;    
          &lt;init-param&gt;
              &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
              &lt;param-value&gt;/WEB-INF/spring-servlet.xml&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p><strong>My servlet config file</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="
         http://www.springframework.org/schema/beans
         http://www.springframework.org/schema/beans/spring-beans.xsd
         http://www.springframework.org/schema/context
         http://www.springframework.org/schema/context/spring-context.xsd"&gt;
  
      &lt;!-- scan for controller --&gt;
      &lt;context:component-scan base-package="au.com.snh.controllers" /&gt;
  
      &lt;!-- bean configuration --&gt;
      &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
          &lt;property name="prefix"&gt;
              &lt;value&gt;/WEB-INF/pages/&lt;/value&gt;
          &lt;/property&gt;
          &lt;property name="suffix"&gt;
              &lt;value&gt;.jsp&lt;/value&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>My JSP files (hi.jsp &amp; hello.jsp) are created under <strong>/WEB-INF/pages</strong> folder.</p>
  
  <p>Now as defined above when I try to access <a href="http://localhost:7001/SpringMVCFirstApp/greet/hello" rel="nofollow noreferrer">http://localhost:7001/SpringMVCFirstApp/greet/hello</a> then I see as below in the browser.</p>
  
  <p><a href="https://i.stack.imgur.com/FseJC.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FseJC.jpg" alt="This is seen in the browser"></a></p>
  
  <p>And in the CONSOLE I could just see as below.</p>
  
  <pre><code>&lt;11/08/2015 4:57:48 PM EST&gt; &lt;Warning&gt; &lt;Socket&gt; &lt;BEA-000449&gt; &lt;Closing socket as no data read from it on 127.0.0.1:64,771 during the configured idle timeout of 5 secs&gt; 
  &lt;11/08/2015 4:57:48 PM EST&gt; &lt;Warning&gt; &lt;Socket&gt; &lt;BEA-000449&gt; &lt;Closing socket as no data read from it on 127.0.0.1:64,772 during the configured idle timeout of 5 secs&gt;
  </code></pre>
  
  <p>Can someone please tell me why works on METHOD LEVEL but not when I try with CLASS+METHOD level mapping annotation.</p>
  
  <p>Looking forward to getting reply.</p>
  
  <p>Thanks - Hitesh</p>
  
  <p>----- <strong>Original question updated on 12/Aug/2015</strong> -----
  Dear  M. Deinum,
  As you suggested my **servlet config ** file is changed to:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:mvc="http://www.springframework.org/schema/mvc"
      xsi:schemaLocation="
         http://www.springframework.org/schema/beans
         http://www.springframework.org/schema/beans/spring-beans.xsd
         http://www.springframework.org/schema/context
         http://www.springframework.org/schema/context/spring-context.xsd
         http://www.springframework.org/schema/mvc
         http://www.springframework.org/schema/mvc/spring-mvc.xsd"&gt;
  
      &lt;!-- scan for controller --&gt;
      &lt;context:component-scan base-package="au.com.snh.controllers" /&gt;
  
      &lt;!-- bean configuration --&gt;
      &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
          &lt;property name="prefix"&gt;
              &lt;value&gt;/WEB-INF/pages/&lt;/value&gt;
          &lt;/property&gt;
          &lt;property name="suffix"&gt;
              &lt;value&gt;.jsp&lt;/value&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;mvc:annotation-driven /&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>Still it's not working and when I try to deploy from Eclipse it gives below error.</p>
  
  <pre><code>[ERROR] DispatcherServlet - Context initialization failed &lt;org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/spring-servlet.xml]; nested exception is java.lang.NoSuchMethodError: org.springframework.beans.MutablePropertyValues.add(Ljava/lang/String;Ljava/lang/Object;)Lorg/springframework/beans/MutablePropertyValues;&gt;org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/spring-servlet.xml]; nested exception is java.lang.NoSuchMethodError: org.springframework.beans.MutablePropertyValues.add(Ljava/lang/String;Ljava/lang/Object;)Lorg/springframework/beans/MutablePropertyValues;
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:420)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
      at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
      at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)
      at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
      at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
      at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:402)
      at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:316)
      at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:282)
      at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126)
      at javax.servlet.GenericServlet.init(GenericServlet.java:241)
      at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:283)
      at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
      at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
      at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:64)
      at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58)
      at weblogic.servlet.internal.StubLifecycleHelper.&lt;init&gt;(StubLifecycleHelper.java:48)
      at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:539)
      at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1981)
      at weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1955)
      at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1874)
      at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3154)
      at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1518)
      at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:484)
      at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
      at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
      at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
      at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
      at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:247)
      at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
      at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
      at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
      at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)
      at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:671)
      at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
      at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:212)
      at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:59)
      at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161)
      at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)
      at weblogic.deploy.internal.targetserver.BasicDeployment.activate(BasicDeployment.java:184)
      at weblogic.deploy.internal.targetserver.BasicDeployment.activateFromServerLifecycle(BasicDeployment.java:361)
      at weblogic.management.deploy.internal.DeploymentAdapter$1.doActivate(DeploymentAdapter.java:51)
      at weblogic.management.deploy.internal.DeploymentAdapter.activate(DeploymentAdapter.java:200)
      at weblogic.management.deploy.internal.AppTransition$2.transitionApp(AppTransition.java:30)
      at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:240)
      at weblogic.management.deploy.internal.ConfiguredDeployments.activate(ConfiguredDeployments.java:169)
      at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:123)
      at weblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:180)
      at weblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:96)
      at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
      at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
      at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
  Caused by: java.lang.NoSuchMethodError: org.springframework.beans.MutablePropertyValues.add(Ljava/lang/String;Ljava/lang/Object;)Lorg/springframework/beans/MutablePropertyValues;
      at org.springframework.web.servlet.config.AnnotationDrivenBeanDefinitionParser.getContentNegotiationManager(AnnotationDrivenBeanDefinitionParser.java:373)
      at org.springframework.web.servlet.config.AnnotationDrivenBeanDefinitionParser.parse(AnnotationDrivenBeanDefinitionParser.java:180)
      at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:69)
      at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1297)
      at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1287)
      at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:135)
      at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:92)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:507)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:398)
      ... 56 more
  </code></pre>
  
  <p>Does anyone have idea what is wrong?</p>
  
  <p>Thanks - Hitesh</p>