Announcement Announcement Module
Collapse
No announcement yet.
Trouble mapping handler in Tomcat Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Trouble mapping handler in Tomcat

    Hi all!

    I'm testing my application in Jetty and all works fine, but when I try to test it in Tomcat, nothing works. The stacktrace :

    Code:
    org.apache.jasper.JasperException: javax.servlet.ServletException: Servlet.init() para servlet lbdPortal lanzó excepción
    	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:541)
    	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
    	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    
    causa raíz
    
    javax.servlet.ServletException: Servlet.init() para servlet lbdPortal lanzó excepción
    	org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:694)
    	org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:665)
    	org.apache.jsp.index_jsp._jspService(index_jsp.java:54)
    	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
    	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    
    causa raíz
    
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0' defined in ServletContext resource [/WEB-INF/lbdPortal-servlet.xml]: Initialization of bean failed; nested exception is java.lang.IllegalStateException: Cannot map handler [LBDPortalPublicController] to URL path [/MainPage.do]: There is already handler [es.udc.lbd.portal.http.controller.springmvc.LBDPortalPublicController@adf91] mapped.
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:478)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    	java.security.AccessController.doPrivileged(Native Method)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    	org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
    	org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:217)
    	org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    	org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
    	org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
    	org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
    	org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:354)
    	org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:292)
    	org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:262)
    	org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126)
    	javax.servlet.GenericServlet.init(GenericServlet.java:212)
    	org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:694)
    	org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:665)
    	org.apache.jsp.index_jsp._jspService(index_jsp.java:54)
    	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
    	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    
    causa raíz
    
    java.lang.IllegalStateException: Cannot map handler [LBDPortalPublicController] to URL path [/MainPage.do]: There is already handler [es.udc.lbd.portal.http.controller.springmvc.LBDPortalPublicController@adf91] mapped.
    	org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:302)
    	org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:274)
    	org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping.detectHandlers(AbstractDetectingUrlHandlerMapping.java:82)
    	org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping.initApplicationContext(AbstractDetectingUrlHandlerMapping.java:57)
    	org.springframework.context.support.ApplicationObjectSupport.initApplicationContext(ApplicationObjectSupport.java:119)
    	org.springframework.web.context.support.WebApplicationObjectSupport.initApplicationContext(WebApplicationObjectSupport.java:69)
    	org.springframework.context.support.ApplicationObjectSupport.setApplicationContext(ApplicationObjectSupport.java:73)
    	org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:70)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:350)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1329)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:471)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    	java.security.AccessController.doPrivileged(Native Method)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    	org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
    	org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:217)
    	org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    	org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
    	org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
    	org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
    	org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:354)
    	org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:292)
    	org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:262)
    	org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126)
    	javax.servlet.GenericServlet.init(GenericServlet.java:212)
    	org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:694)
    	org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:665)
    	org.apache.jsp.index_jsp._jspService(index_jsp.java:54)
    	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
    	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    As I understand the error, the handler is mapping twice the same RequestMapping, but I don't found this problem in my controller mappings. The "only" similar problem is that I have mapped "/MainPage.do" in one controller, and "/Administration/MainPage.do" in other controller, but the mapping is different. Any ideas?

    What is the reason if in Jetty all works?

    Thanks

  • #2
    Given exception says that it can't map /MainPage.do url to the bean of class es.udc.lbd.portal.http.controller.springmvc.LBDPor talPublicController (marked by @RequestMapping) because the url is already binded to the bean of class es.udc.lbd.portal.http.controller.springmvc.LBDPor talPublicController. It looks like org.springframework.web.servlet.mvc.annotation.Def aultAnnotationHandlerMapping tries to process the beans twice under Tomcat and that's the problem reason.

    Try to debug you application - set a breakpoint at LBDPortalPublicController ctor in order to see call stack for its first instantiation. That may help to understand what's happening.

    Comment


    • #3
      Changing "administrative mapping" to something like /Administration/AdminMainPage.do the error persists ... I'll continue searching for the cause.

      This is important, because I was thinking in use the indirection "/Administration/" to split the administrative part from the public one. In Firefox 2.0.0.16 all urls works, but in IE Explorer 6 , IE Explorer 7 and Firefox 3 not work. ¿Why is the reason?

      Note: I'm using the indirection to later use Spring Security and secure all URLs like the pattern "/Administration/*".
      Last edited by bLaDe00; Sep 7th, 2008, 06:15 PM.

      Comment


      • #4
        Finally works! But the reason is simply... stupid.

        Looking at the stack trace and the instanced singletons, I found this in the line:

        Code:
        LBDPortalPublicController, LBDPortalController, LBDPortalAdminController
        LBDPortalController was an old name of the controller of the public part, but this make me suspect in the class files into target folder. I removed this target folder and recompile all classes with maven (mvn compile), make war (mvn war:war), deploy in Tomcat and... got it.

        This problem is solved, but the other mentioned about the indirection continue no working in IE 7 and Firefox 3 ... but the strange is that viewing source code of the page all is there! (could be a Tiles problem or it has no relation with Spring/Tiles -- sorry in that case)

        Comment

        Working...
        X