org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0' defined in ServletContext resource [/WEB-INF/web-application-config.xml]: Initialization of bean failed; nested exception is java.lang.IllegalStateException: Cannot map handler [controller2] to URL path [/someurl]: There is already handler [Controller1@1830ec7] mapped.

Spring JIRA | Mark Hopkins | 7 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    Given the following: {code:title=Controller1.java} @Controller public class Controller1 { @RequestMapping(value="/someurl", method=GET) public String doGet() { return "view"; } } {code} {code:title=Controller2.java} @Controller public class Controller2 { @RequestMapping(value="/someurl", method=POST) public String doPost() { // do something different for posts return "view"; } } {code} {code:xml|title=web-application-config.xml} .... <context:spring-configured/> <context:annotation-config/> <context:component-scan base-package="..."/> <context:component-scan base-package="..."/> .... {code} you get the following exception: {noformat} org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0' defined in ServletContext resource [/WEB-INF/web-application-config.xml]: Initialization of bean failed; nested exception is java.lang.IllegalStateException: Cannot map handler [controller2] to URL path [/someurl]: There is already handler [Controller1@1830ec7] mapped. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:557) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:416) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:443) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:459) at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:340) at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307) at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127) ... {noformat} In our specific domain it makes most sense to have the GET and POST for the same URL split over two different classes.

    Spring JIRA | 7 years ago | Mark Hopkins
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0' defined in ServletContext resource [/WEB-INF/web-application-config.xml]: Initialization of bean failed; nested exception is java.lang.IllegalStateException: Cannot map handler [controller2] to URL path [/someurl]: There is already handler [Controller1@1830ec7] mapped.
  2. 0

    Given the following: {code:title=Controller1.java} @Controller public class Controller1 { @RequestMapping(value="/someurl", method=GET) public String doGet() { return "view"; } } {code} {code:title=Controller2.java} @Controller public class Controller2 { @RequestMapping(value="/someurl", method=POST) public String doPost() { // do something different for posts return "view"; } } {code} {code:xml|title=web-application-config.xml} .... <context:spring-configured/> <context:annotation-config/> <context:component-scan base-package="..."/> <context:component-scan base-package="..."/> .... {code} you get the following exception: {noformat} org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0' defined in ServletContext resource [/WEB-INF/web-application-config.xml]: Initialization of bean failed; nested exception is java.lang.IllegalStateException: Cannot map handler [controller2] to URL path [/someurl]: There is already handler [Controller1@1830ec7] mapped. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:557) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:416) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:443) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:459) at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:340) at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307) at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127) ... {noformat} In our specific domain it makes most sense to have the GET and POST for the same URL split over two different classes.

    Spring JIRA | 7 years ago | Mark Hopkins
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0' defined in ServletContext resource [/WEB-INF/web-application-config.xml]: Initialization of bean failed; nested exception is java.lang.IllegalStateException: Cannot map handler [controller2] to URL path [/someurl]: There is already handler [Controller1@1830ec7] mapped.
  3. 0

    When I try to do this: <flex:secured access-decision-manager="accessDecisionManager"> <flex:secured-channel channel="my-amf" access="ROLE_USER"/> </flex:secured> It fails because of the access attribute. This happens on end point security as well. <flex:secured access-decision-manager="accessDecisionManager"/> works fine. Error: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_messageBrokerDefaultHandlerMapping': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_messageBroker': Cannot resolve reference to bean '_messageBrokerEndpointProcessor' while setting bean property 'configProcessors' with key [4]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_messageBrokerEndpointProcessor': Cannot resolve reference to bean 'org.springframework.flex.core.EndpointServiceMessagePointcutAdvisor#1' while setting constructor argument with key [1]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.flex.core.EndpointServiceMessagePointcutAdvisor#1': Cannot resolve reference to bean 'org.springframework.flex.core.MessageInterceptionAdvice#0' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.flex.core.MessageInterceptionAdvice#0': Cannot resolve reference to bean 'org.springframework.flex.security3.EndpointInterceptor#0' while setting bean property 'messageInterceptors' with key [2]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.flex.security3.EndpointInterceptor#0': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Unsupported configuration attributes: [ROLE_USER] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:557) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:416) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:443) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:459) at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:340) at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307) at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127) at javax.servlet.GenericServlet.init(GenericServlet.java:241)

    Spring JIRA | 7 years ago | Bjorn Harvold
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_messageBrokerDefaultHandlerMapping': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_messageBroker': Cannot resolve reference to bean '_messageBrokerEndpointProcessor' while setting bean property 'configProcessors' with key [4]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_messageBrokerEndpointProcessor': Cannot resolve reference to bean 'org.springframework.flex.core.EndpointServiceMessagePointcutAdvisor#1' while setting constructor argument with key [1]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.flex.core.EndpointServiceMessagePointcutAdvisor#1': Cannot resolve reference to bean 'org.springframework.flex.core.MessageInterceptionAdvice#0' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.flex.core.MessageInterceptionAdvice#0': Cannot resolve reference to bean 'org.springframework.flex.security3.EndpointInterceptor#0' while setting bean property 'messageInterceptors' with key [2]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.flex.security3.EndpointInterceptor#0': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Unsupported configuration attributes: [ROLE_USER]
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    When I try to do this: <flex:secured access-decision-manager="accessDecisionManager"> <flex:secured-channel channel="my-amf" access="ROLE_USER"/> </flex:secured> It fails because of the access attribute. This happens on end point security as well. <flex:secured access-decision-manager="accessDecisionManager"/> works fine. Error: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_messageBrokerDefaultHandlerMapping': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_messageBroker': Cannot resolve reference to bean '_messageBrokerEndpointProcessor' while setting bean property 'configProcessors' with key [4]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_messageBrokerEndpointProcessor': Cannot resolve reference to bean 'org.springframework.flex.core.EndpointServiceMessagePointcutAdvisor#1' while setting constructor argument with key [1]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.flex.core.EndpointServiceMessagePointcutAdvisor#1': Cannot resolve reference to bean 'org.springframework.flex.core.MessageInterceptionAdvice#0' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.flex.core.MessageInterceptionAdvice#0': Cannot resolve reference to bean 'org.springframework.flex.security3.EndpointInterceptor#0' while setting bean property 'messageInterceptors' with key [2]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.flex.security3.EndpointInterceptor#0': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Unsupported configuration attributes: [ROLE_USER] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:557) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:416) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:443) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:459) at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:340) at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307) at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127) at javax.servlet.GenericServlet.init(GenericServlet.java:241)

    Spring JIRA | 7 years ago | Bjorn Harvold
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_messageBrokerDefaultHandlerMapping': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_messageBroker': Cannot resolve reference to bean '_messageBrokerEndpointProcessor' while setting bean property 'configProcessors' with key [4]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_messageBrokerEndpointProcessor': Cannot resolve reference to bean 'org.springframework.flex.core.EndpointServiceMessagePointcutAdvisor#1' while setting constructor argument with key [1]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.flex.core.EndpointServiceMessagePointcutAdvisor#1': Cannot resolve reference to bean 'org.springframework.flex.core.MessageInterceptionAdvice#0' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.flex.core.MessageInterceptionAdvice#0': Cannot resolve reference to bean 'org.springframework.flex.security3.EndpointInterceptor#0' while setting bean property 'messageInterceptors' with key [2]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.flex.security3.EndpointInterceptor#0': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Unsupported configuration attributes: [ROLE_USER]
  6. 0

    Hessian Webservice with REST, Java Spring

    Stack Overflow | 4 years ago | Cid Immacula
    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.IllegalStateException: Ambiguous mapping found. Cannot map 'photoService' bean method public java.lang.Object mppiwebservices.photoservices.impl.photo.PhotoServicesImpl.savePhoto(javax.servlet.http.HttpServletRequest,java.lang.String,java.lang.String,mppiwebservices.photoservices.pojo.Photo,org.springframework.validation.BindingResult,org.springframework.web.bind.support.SessionStatus) to {[/{user}/{folder_name}/savephoto/],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already 'photoServicesImpl' bean method public java.lang.Object mppiwebservices.photoservices.impl.photo.PhotoServicesImpl.savePhoto(javax.servlet.http.HttpServletRequest,java.lang.String,java.lang.String,mppiwebservices.photoservices.pojo.Photo,org.springframework.validation.BindingResult,org.springframework.web.bind.support.SessionStatus) mapped.

  1. Andreas Häber 2 times, last 2 weeks ago
  2. treefolk 1 times, last 3 weeks ago
  3. mauritius 2 times, last 2 months ago
  4. jpvee 1 times, last 2 months ago
  5. rlovtangen 1 times, last 3 months ago
23 more registered users
72 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. org.springframework.beans.factory.BeanCreationException

    Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0' defined in ServletContext resource [/WEB-INF/web-application-config.xml]: Initialization of bean failed; nested exception is java.lang.IllegalStateException: Cannot map handler [controller2] to URL path [/someurl]: There is already handler [Controller1@1830ec7] mapped.

    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean()
  2. Spring Beans
    DefaultListableBeanFactory.preInstantiateSingletons
    1. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    2. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
    3. org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
    4. org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    5. org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
    6. org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
    7. org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:557)
    7 frames
  3. Spring Context
    AbstractApplicationContext.refresh
    1. org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842)
    2. org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:416)
    2 frames
  4. Spring MVC
    HttpServletBean.init
    1. org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:443)
    2. org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:459)
    3. org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:340)
    4. org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307)
    5. org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
    5 frames