spring java configuration issue: Rejected bean name 'requestMappingHandlerMapping': no URL paths identified -
i using spring java configs create web app.
when run on tomcat says resource /myapp/myapp not found
in console output noticed following. not sure whether causing issue.
i showing log lines odd. log big
info: validatejarfile(c:\libraries\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\myapp\web-inf\lib\javax.servlet-api-3.0.1.jar) - jar not loaded. see servlet spec 2.3, section 9.7.2. offending class: javax/servlet/servlet.class creating instance of bean 'beannamehandlermapping' returning cached instance of singleton bean 'delegatingwebmvcconfiguration' eagerly caching bean 'beannamehandlermapping' allow resolving potential circular references looking url mappings in application context: root webapplicationcontext: startup date [mon j un 04 13:28:33 edt 2012]; root of context hierarchy rejected bean name 'org.springframework.context.annotation.internalconfigurationannotationprocessor': no url paths identified rejected bean name 'org.springframework.context.annotation.internalautowiredannotationprocessor': no url paths identified rejected bean name 'org.springframework.context.annotation.internalrequiredannotationprocessor': no url paths identified rejected bean name 'org.springframework.context.annotation.internalcommonannotationprocessor': no url paths identified rejected bean name 'webappcontextconfig': no url paths identified rejected bean name 'org.springframework.context.annotation.configurationclasspostprocessor$importawarebeanpostprocessor#0': no url paths identified rejected bean name 'delegatingwebmvcconfiguration': no url paths identified rejected bean name 'requestmappinghandlermapping': no url paths identified rejected bean name 'viewcontrollerhandlermapping': no url paths identified rejected bean name 'beannamehandlermapping': no url paths identified rejected bean name 'resourcehandlermapping': no url paths identified rejected bean name 'defaultservlethandlermapping': no url paths identified rejected bean name 'requestmappinghandleradapter': no url paths identified rejected bean name 'mvcconversionservice': no url paths identified rejected bean name 'mvcvalidator': no url paths identified rejected bean name 'httprequesthandleradapter': no url paths identified rejected bean name 'simplecontrollerhandleradapter': no url paths identified rejected bean name 'handlerexceptionresolver': no url paths identified rejected bean name 'configureinternalresourceviewresolver': no url paths identified rejected bean name 'environment': no url paths identified rejected bean name 'systemproperties': no url paths identified rejected bean name 'systemenvironment': no url paths identified rejected bean name 'servletcontext': no url paths identified rejected bean name 'contextparameters': no url paths identified rejected bean name 'contextattributes': no url paths identified rejected bean name 'importregistry': no url paths identified rejected bean name 'messagesource': no url paths identified rejected bean name 'applicationeventmulticaster': no url paths identified finished creating instance of bean 'beannamehandlermapping' creating shared instance of singleton bean 'resourcehandlermapping' creating instance of bean 'resourcehandlermapping' returning cached instance of singleton bean 'delegatingwebmvcconfiguration' eagerly caching bean 'resourcehandlermapping' allow resolving potential circular references mapped url path [/css/**] onto handler of type [class org.springframework.web.servlet.resource.resourcehttprequesthandler] mapped url path [/scripts/**] onto handler of type [class org.springframework.web.servlet.resource.resourcehttprequesthandler] mapped url path [/images/**] onto handler of type [class org.springframework.web.servlet.resource.resourcehttprequesthandler] finished creating instance of bean 'resourcehandlermapping' here webappcontextconfig.java
package com.example; import org.springframework.context.annotation.bean; import org.springframework.context.annotation.componentscan; import org.springframework.context.annotation.configuration; import org.springframework.web.servlet.config.annotation.enablewebmvc; import org.springframework.web.servlet.config.annotation.resourcehandlerregistry; import org.springframework.web.servlet.config.annotation.webmvcconfigureradapter; import org.springframework.web.servlet.view.internalresourceviewresolver; @configuration @enablewebmvc @componentscan(basepackages = "com.example") public class webappcontextconfig extends webmvcconfigureradapter{ //resolve logical view names .jsp resources in /web-inf/views directory @bean public internalresourceviewresolver configureinternalresourceviewresolver() { internalresourceviewresolver resolver = new internalresourceviewresolver(); resolver.setprefix("web-inf/jsp/"); resolver.setsuffix(".jsp"); return resolver; } @override public void addresourcehandlers(resourcehandlerregistry registry) { registry.addresourcehandler("/scripts/**").addresourcelocations("/scripts/"); registry.addresourcehandler("/css/**").addresourcelocations("/css/"); registry.addresourcehandler("/images/**").addresourcelocations("/images/"); } } here webappinitializer.java
package com.example; import javax.servlet.servletcontext; import javax.servlet.servletexception; import javax.servlet.servletregistration; import org.springframework.context.annotation.componentscan; import org.springframework.web.webapplicationinitializer; import org.springframework.web.context.contextloaderlistener; import org.springframework.web.context.support.annotationconfigwebapplicationcontext; import org.springframework.web.servlet.dispatcherservlet; import org.springframework.web.servlet.config.annotation.defaultservlethandlerconfigurer; public class webappinitializer implements webapplicationinitializer { /* (non-javadoc) * @see org.springframework.web.webapplicationinitializer#onstartup(javax.servlet.servletcontext) */ @override public void onstartup(servletcontext servletcontext) throws servletexception { annotationconfigwebapplicationcontext rootcontext = new annotationconfigwebapplicationcontext(); rootcontext.register(webappcontextconfig.class); servletcontext.addlistener(new contextloaderlistener(rootcontext)); annotationconfigwebapplicationcontext dispatchercontext = new annotationconfigwebapplicationcontext(); dispatchercontext.register(webappcontextconfig.class); servletregistration.dynamic dispatcher = servletcontext.addservlet("dispatcher", new dispatcherservlet(rootcontext)); dispatcher.setloadonstartup(1); dispatcher.addmapping("/"); defaultservlethandlerconfigurer defaultconfig = new defaultservlethandlerconfigurer(servletcontext); defaultconfig.enable(); } } also there place java based spring mvc configuration?
thanks
this not root cause @ravi, see few issues wanted highlight start with:
a. seem loading spring java config file twice, through contextloaderlistener , dispatcher servlet, through contextloaderlistener, can define dispatcherservlet way - load empty context(ideally have 2 java configs - 1 core application , 1 web configuration):
servletregistration.dynamic dispatcher = servletcontext.addservlet("dispatcher", new genericwebapplicationcontext()); dispatcher.setloadonstartup(1); dispatcher.addmapping("/"); b. can enable debug mode log4j , see else logged - if not sufficient information, log @ trace level.
c. internal view resolver path looks little wrong - missing forward "/":
resolver.setprefix("/web-inf/jsp/"); can please try these , see see now.
Comments
Post a Comment