-1

Hi in my MVC apllication i have two

contextConfigLocation  files

one for security purpose named

spring-security.xml

the other one for servlet redirection named

appServlet-servlet.xml

My question is how to add both in my

web.xml

which is

    <?xml version="1.0" encoding="UTF-8"?>
<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_3_1.xsd" 
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
                             http://java.sun.com/xml/ns/javaee/web-app_3_1.xsd" 
         id="WebApp_ID" version="2.5">

    <welcome-file-list>
        <welcome-file>/WEB-INF/enregistrer_client.jsp</welcome-file>
    </welcome-file-list>

    <!--
        - Filtre springSecurityFilterChain
    -->

    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <!--
      ContextLoaderListener : chargement fichiers de définition de beans
    -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <!--
      Fichiers XML de configuration, à charger par le ContextLoaderListener
    -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/spring-security.xml,/WEB-INF/appServlet-servlet.xml
        </param-value>
    </context-param>
</web-app>

because these lines

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        /WEB-INF/spring-security.xml,/WEB-INF/appServlet-servlet.xml
    </param-value>
</context-param>

returns

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0': Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: org.springframework.web.bind.annotation.RequestMapping.consumes()[Ljava/lang/String;
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:526)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

Thank you

chillo
  • 49
  • 3
  • 11

1 Answers1

2

You are misinterpreting stacktrace. Your real problem on this line:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0': Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: org.springframework.web.bind.annotation.RequestMapping.consumes()[Ljava/lang/String;

Most likely you put old version of Spring in classpath. Upgrade to Spring 3.1.

Vadim Ponomarev
  • 1,346
  • 9
  • 15
  • I haven't yet done such a task please how to upgrade to 3.1 – chillo May 06 '12 at 07:36
  • 1
    Download Spring 3.1 and replace old JARs "spring-*.jar" with new version. – Vadim Ponomarev May 06 '12 at 08:11
  • ok thanks how to provide a custum login page ? – chillo May 06 '12 at 10:17
  • @Achille Please don't add unrelated questions in comments. Also, this information is readily available with minimal research, for example if you search the [reference manual](http://static.springsource.org/spring-security/site/docs/3.1.x/reference/springsecurity-single.html) for "login page" – Shaun the Sheep May 08 '12 at 07:44