Announcement Announcement Module
Collapse
No announcement yet.
Error init tomcat in STS Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error init tomcat in STS

    Hello i'm new at spring. I'm developing a STS app to learn, i've created a Template Project - Spring MVC Project, i have several controllers, but the problem is that when i try to access to a folder with two different controllers (for example trial1.jsp and another trial2.jsp (@RequestMapping) and both JSP are in the same folder) i get an error message and i have to put the JSP in different folders (then it works) but i need them in the same folder

    The error message that is dispayed is the following, occurs when you run the tomcat.


    ******

    ERROR: org.springframework.web.context.ContextLoader - Context initialization failed
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annota tion.RequestMappingHandlerMapping#0': Initialization of bean failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping found. Cannot map 'trampsSameController' bean method
    public java.lang.String com.duckranger.goodproject.controllers.TrampsSameC ontroller.listSame(org.springframework.ui.Model)
    to {[/populate],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already 'trampsController' bean method
    public java.lang.String com.duckranger.goodproject.controllers.TrampsContr oller.listMap(org.springframework.ui.Model) mapped.
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:527)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 94)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:225)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:291 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:585)
    at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:913)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:464)
    at org.springframework.web.context.ContextLoader.conf igureAndRefreshWebApplicationContext(ContextLoader .java:384)
    at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:283)
    at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 111)
    at org.apache.catalina.core.StandardContext.listenerS tart(StandardContext.java:4779)
    at org.apache.catalina.core.StandardContext.startInte rnal(StandardContext.java:5273)
    at org.apache.catalina.util.LifecycleBase.start(Lifec ycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild. call(ContainerBase.java:1566)
    at org.apache.catalina.core.ContainerBase$StartChild. call(ContainerBase.java:1556)
    at java.util.concurrent.FutureTask$Sync.innerRun(Futu reTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.jav a:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
    Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot map 'trampsSameController' bean method
    public java.lang.String com.duckranger.goodproject.controllers.TrampsSameC ontroller.listSame(org.springframework.ui.Model)
    to {[/populate],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already 'trampsController' bean method
    public java.lang.String com.duckranger.goodproject.controllers.TrampsContr oller.listMap(org.springframework.ui.Model) mapped.
    at org.springframework.web.servlet.handler.AbstractHa ndlerMethodMapping.registerHandlerMethod(AbstractH andlerMethodMapping.java:181)
    at org.springframework.web.servlet.handler.AbstractHa ndlerMethodMapping.detectHandlerMethods(AbstractHa ndlerMethodMapping.java:145)
    at org.springframework.web.servlet.handler.AbstractHa ndlerMethodMapping.initHandlerMethods(AbstractHand lerMethodMapping.java:107)
    at org.springframework.web.servlet.handler.AbstractHa ndlerMethodMapping.initApplicationContext(Abstract HandlerMethodMapping.java:87)
    at org.springframework.context.support.ApplicationObj ectSupport.initApplicationContext(ApplicationObjec tSupport.java:119)
    at org.springframework.web.context.support.WebApplica tionObjectSupport.initApplicationContext(WebApplic ationObjectSupport.java:72)
    at org.springframework.context.support.ApplicationObj ectSupport.setApplicationContext(ApplicationObject Support.java:73)
    at org.springframework.context.support.ApplicationCon textAwareProcessor.invokeAwareInterfaces(Applicati onContextAwareProcessor.java:117)
    at org.springframework.context.support.ApplicationCon textAwareProcessor.postProcessBeforeInitialization (ApplicationContextAwareProcessor.java:92)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyBeanPostProcessors BeforeInitialization(AbstractAutowireCapableBeanFa ctory.java:394)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1448)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:519)
    ... 21 more


    ******

    Thanks for your help

  • #2
    You have two methods very sameless in order to request mapping:

    Ambiguous mapping found. Cannot map 'trampsSameController' bean method

    See your RequestMapping annotations ...

    Comment


    • #3
      This I can not do it?

      /**
      * List all tramps map
      */
      @RequestMapping(value = "/populate", method = RequestMethod.GET)
      public String listMap(Model model) {
      logger.info("Listing Walks in MAP");
      model.addAttribute("tramps",trampsService.findMapA ll());
      return "populate/list";
      }

      /**
      * List all tramps map same source
      */
      @RequestMapping(value = "/populate", method = RequestMethod.GET)
      public String listSame(Model model) {
      logger.info("Listing Walks in the street");
      model.addAttribute("tramps",trampsService.findAll( ));
      return "populate/samesource";
      }

      Thanks

      Comment


      • #4
        Originally posted by eladerezador View Post
        This I can not do it?
        You can't do it because this two methods have the same mapping defined.
        There is no way to decide which one to invoke when "/populate" URL is called.

        Comment


        • #5
          Hello,

          one more question, then how do I access the same folder with different jsp using RequestMapping?, or I have to do differently?, sorry for my ignorance

          Thank you,

          Comment


          • #6
            Originally posted by eladerezador View Post
            how do I access the same folder with different jsp using RequestMapping?
            You can use same folder with different parameters, different HTTP modes (put, get, post, delete), different subfolders, etc.
            Please, visit Spring MVC documentation.

            Regards !

            Comment


            • #7
              Solved, thank you very much

              Comment

              Working...
              X