kolorobot / spring-mvc-quickstart-archetype

The project is a Maven archetype for Spring MVC web application.
http://blog.codeleak.pl
1.05k stars 478 forks source link

Why does Root context and dispatcher context both instantiate @Service's, @Component's, etc? #44

Closed johnlauer closed 10 years ago

johnlauer commented 10 years ago

Hi Kolorobot, with the way you have setup the WebAppInitializer and WebMvcConfig it seems that everything is getting instantiated twice--once under the Root context and once as the dispatcher context. This means all database connections for Jpa and Mongo, but it also means all of your @Services, etc get instantiated twice. Why is that?

Here's my output of Tomcat7 starting up with your archetype. I added a bunch of System.out.println()'s for the overriden methods in WebAppInitializer and WebMvcConfig to watch how Tomcat goes through them.

I also added two services called MyServiceOne and MyServiceTwo to the base project just to see how/when they get instantiated. Am I doing something wrong? Or is the config not setup correctly?

INFO: Starting Servlet Engine: Apache Tomcat/7.0.26 Dec 09, 2013 4:17:44 PM org.apache.catalina.core.ApplicationContext log INFO: Spring WebApplicationInitializers detected on classpath: [com.zipwhip.testSpring4.config.WebAppSecurityInitializer@2d9272f8, com.zipwhip.testSpring4.config.WebAppInitializer@69ba0f27] Inside init getRootConfigClasses Inside init getServletConfigClasses Inside init getServletMappings Inside init getServletFilters Inside init customizeRegistration Dec 09, 2013 4:17:44 PM org.apache.catalina.core.ApplicationContext log INFO: Initializing Spring root WebApplicationContext 2013-12-09 16:17:44.963 [pool-2-thread-1] WARN o.s.s.c.SpringSecurityCoreVersion - *\ Spring Major version '3' expected, but you are running with version: 4.0.0.RC2. Please check your classpath for unwanted jar files. Inside JpaConfig annotationDrivenTransactionManager Inside JpaConfig configureEntityManagerFactory Inside JpaConfig configureDataSource Inside WebMvcConfig messageSource MyServiceOne just got created. MyServiceTwo just got created. 2013-12-09 16:17:47.269 [pool-2-thread-1] WARN o.h.e.j.i.JdbcCoordinatorImpl - HHH000386: ResultSet had no statement associated with it, but was not yet registered 2013-12-09 16:17:47.281 [pool-2-thread-1] WARN o.h.e.j.i.JdbcCoordinatorImpl - HHH000386: ResultSet had no statement associated with it, but was not yet registered Inside WebMvcConfig templateResolver Inside WebMvcConfig templateEngine Inside WebMvcConfig viewResolver Inside WebMvcConfig requestMappingHandlerMapping Inside WebMvcConfig addResourceHandlers Inside WebMvcConfig configureDefaultServletHandling Inside WebMvcConfig getValidator Dec 09, 2013 4:17:48 PM org.apache.catalina.core.ApplicationContext log INFO: Initializing Spring FrameworkServlet 'dispatcher' Inside JpaConfig annotationDrivenTransactionManager Inside JpaConfig configureEntityManagerFactory Inside JpaConfig configureDataSource 2013-12-09 16:17:48.567 [pool-2-thread-1] WARN o.h.e.i.EntityManagerFactoryRegistry - HHH000436: Entity manager factory name (default) is already registered. If entity manager will be clustered or passivated, specify a unique value for property 'hibernate.ejb.entitymanager_factory_name' Inside WebMvcConfig messageSource MyServiceOne just got created. MyServiceTwo just got created. 2013-12-09 16:17:48.620 [pool-2-thread-1] WARN o.h.e.j.i.JdbcCoordinatorImpl - HHH000386: ResultSet had no statement associated with it, but was not yet registered 2013-12-09 16:17:48.625 [pool-2-thread-1] WARN o.h.e.j.i.JdbcCoordinatorImpl - HHH000386: ResultSet had no statement associated with it, but was not yet registered Inside WebMvcConfig viewResolver Inside WebMvcConfig templateEngine Inside WebMvcConfig templateResolver Inside WebMvcConfig getValidator Inside WebMvcConfig requestMappingHandlerMapping Inside WebMvcConfig addResourceHandlers Inside WebMvcConfig configureDefaultServletHandling Dec 09, 2013 4:17:48 PM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["http-bio-8080"] Dec 09, 2013 4:17:48 PM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["ajp-bio-8009"] Dec 09, 2013 4:17:48 PM org.apache.catalina.startup.Catalina start INFO: Server startup in 6948 ms

You can see it goes through the WebAppInitializer once, which is expected, however it would seem the Root context should not instantiate all of the WebMvcConfig stuff. What's the best way to fix this?

Thanks, John

johnlauer commented 10 years ago

What if you isolate the Root app context from the WebMvcConfig context by placing all root elements into a deeper package name like I've done here.

image

Then, in the ApplicationConfig do something like this:

image

That makes only your Root elements load and the WebMvcConfig stuff load on the dispatcher servlet. You then don't end up instantiating @Services more than once. Of course you could always configure your @Service's to load like you setup the JpaConfig, MongoConfig, etc.into the Root.

kolorobot commented 10 years ago

Hi,

Thanks for the comment. I have recently changed the config, before it was single context, but with new WebAppInitializer I couldnot get it to work, so I seperated the context. Probably with a mistake. Will check this. Thanks for suggestions. I will have a look at them. 10 gru 2013 06:29 "John Lauer" notifications@github.com napisał(a):

What if you isolate the Root app context from the WebMvcConfig context by placing all root elements into a deeper package name like I've done here.

[image: image]https://f.cloud.github.com/assets/992149/1711754/98fe67dc-615b-11e3-954a-a844e4f20d6e.png

Then, in the ApplicationConfig do something like this:

[image: image]https://f.cloud.github.com/assets/992149/1711764/d06a3624-615b-11e3-81b3-630c0e8fa9c5.png

That makes only your Root elements load and the WebMvcConfig stuff load on the dispatcher servlet. You then don't end up instantiating @Services more than once. Of course you could always configure your @Servicehttps://github.com/Service's to load like you setup the JpaConfig, MongoConfig, etc.into the Root.

— Reply to this email directly or view it on GitHubhttps://github.com/kolorobot/spring-mvc-quickstart-archetype/issues/44#issuecomment-30200801 .

johnlauer commented 10 years ago

Hi Rafal,

I’m also finding that your archetype loses the ability to get resources. It seems that in the

class WebMvcConfig extends WebMvcConfigurationSupport

I don’t get any calls to the overridden method of

@Override public void addResourceHandlers(ResourceHandlerRegistry registry) { System.out.println("Inside webmvcconfig addResourceHandlers"); registry.addResourceHandler(RESOURCES_HANDLER).addResourceLocations(RESOURCES_LOCATION); System.out.println("Just added resource handlers."); }

I don’t get calls to any of the other overridden methods either except setApplicationContext and setServletContext. I only get the Beans instantiated. It’s very odd.

I actually found this problem on your older Spring 3.2 archetype as well. It would work fine on a Windows PC with Tomcat7, but then I’d move it to an Ubuntu server and it would no longer load resources anymore.

I seem to see similar behavior on this version. It seems to work and then eventually stops working. I’m not sure why.

Why would I not get any overridden methods called in the WebMvcConfigurationSupport?

From: Rafal Borowiec [mailto:notifications@github.com] Sent: Monday, December 9, 2013 10:48 PM To: kolorobot/spring-mvc-quickstart-archetype Cc: John Lauer Subject: Re: [spring-mvc-quickstart-archetype] Why does Root context and dispatcher context both instantiate @Service's, @Component's, etc? (#44)

Hi,

Thanks for the comment. I have recently changed the config, before it was single context, but with new WebAppInitializer I couldnot get it to work, so I seperated the context. Probably with a mistake. Will check this. Thanks for suggestions. I will have a look at them. 10 gru 2013 06:29 "John Lauer" notifications@github.com<mailto:notifications@github.com> napisał(a):

What if you isolate the Root app context from the WebMvcConfig context by placing all root elements into a deeper package name like I've done here.

[image: image]https://f.cloud.github.com/assets/992149/1711754/98fe67dc-615b-11e3-954a-a844e4f20d6e.png

Then, in the ApplicationConfig do something like this:

[image: image]https://f.cloud.github.com/assets/992149/1711764/d06a3624-615b-11e3-81b3-630c0e8fa9c5.png

That makes only your Root elements load and the WebMvcConfig stuff load on the dispatcher servlet. You then don't end up instantiating @Services more than once. Of course you could always configure your @Servicehttps://github.com/Service's to load like you setup the JpaConfig, MongoConfig, etc.into the Root.

— Reply to this email directly or view it on GitHubhttps://github.com/kolorobot/spring-mvc-quickstart-archetype/issues/44#issuecomment-30200801 .

— Reply to this email directly or view it on GitHubhttps://github.com/kolorobot/spring-mvc-quickstart-archetype/issues/44#issuecomment-30203369.

kolorobot commented 10 years ago

2013/12/10 John Lauer notifications@github.com

WebMvcConfigurationSupport

Hi John,

That is in fact odd. Let me come back on this somewhere this week. I will investigate the issue. In case you have any other suggestions, please let me know.

Rafał.

skype: kolorobot80 blog: http://blog.codeleak.pl | http://blog.goyello.comhttp://blog.goyello.com/author/rborowiec/ twitter: http://twitter.com/#!/kolorobot https://twitter.com/#!/kolorobot github: http://github.com/kolorobot https://github.com/kolorobot

kolorobot commented 10 years ago

Hi John,

Configuration was scanned via component scan, therefore context was initialized twice. This is strange, because previously @Configuration was not auto-scanned, I think. See the results now:

[2013-12-10 07:46:04,038] Artifact archetype-testing:war exploded: Artifact is being deployed, please wait... 2013-12-10 19:46:06.350 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.web.context.ContextLoader - Root WebApplicationContext: initialization started 2013-12-10 19:46:06.353 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Tue Dec 10 19:46:06 CET 2013]; root of context hierarchy 2013-12-10 19:46:06.424 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - Registering annotated classes: [class pl.codeleak.testing.config.ApplicationConfig,interface pl.codeleak.testing.config.DataSourceConfig,class pl.codeleak.testing.config.JpaConfig,class pl.codeleak.testing.config.SecurityConfig] 2013-12-10 19:46:06.641 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.b.f.x.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [spring-security-context.xml] 2013-12-10 19:46:06.741 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.SpringSecurityCoreVersion - You are running with Spring Security Core 3.2.0.RC2 2013-12-10 19:46:06.741 [RMI TCP Connection(3)-127.0.0.1] WARN o.s.s.c.SpringSecurityCoreVersion - * Spring Major version '3' expected, but you are running with version: 4.0.0.RC2. Please check your classpath for unwanted jar files. 2013-12-10 19:46:06.741 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.SecurityNamespaceHandler - Spring Security 'config' module version is 3.2.0.RC2 2013-12-10 19:46:06.775 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.h.FilterInvocationSecurityMetadataSourceParser - Creating access control expression attribute 'permitAll' for / 2013-12-10 19:46:06.775 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.h.FilterInvocationSecurityMetadataSourceParser - Creating access control expression attribute 'permitAll' for /favicon.ico 2013-12-10 19:46:06.775 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.h.FilterInvocationSecurityMetadataSourceParser - Creating access control expression attribute 'permitAll' for /resources/ 2013-12-10 19:46:06.775 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.h.FilterInvocationSecurityMetadataSourceParser - Creating access control expression attribute 'permitAll' for /signin 2013-12-10 19:46:06.775 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.h.FilterInvocationSecurityMetadataSourceParser - Creating access control expression attribute 'permitAll' for /signup 2013-12-10 19:46:06.776 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.h.FilterInvocationSecurityMetadataSourceParser - Creating access control expression attribute 'isAuthenticated()' for /** 2013-12-10 19:46:06.797 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.h.HttpSecurityBeanDefinitionParser - Checking sorted filter chain: [Root bean: class [org.springframework.security.web.context.SecurityContextPersistenceFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 200, Root bean: class [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 400, Root bean: class [org.springframework.security.web.authentication.logout.LogoutFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 700, <org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0>, order = 1100, Root bean: class [org.springframework.security.web.authentication.www.BasicAuthenticationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1500, Root bean: class [org.springframework.security.web.savedrequest.RequestCacheAwareFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1600, Root bean: class [org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1700, Root bean: class [org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1900, Root bean: class [org.springframework.security.web.authentication.AnonymousAuthenticationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 2000, Root bean: class [org.springframework.security.web.session.SessionManagementFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 2100, Root bean: class [org.springframework.security.web.access.ExceptionTranslationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 2200, <org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0>, order = 2300] 2013-12-10 19:46:06.895 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.b.f.c.PropertyPlaceholderConfigurer - Loading properties file from class path resource [persistence.properties] 2013-12-10 19:46:06.905 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.b.f.a.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring 2013-12-10 19:46:07.032 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.j.d.DriverManagerDataSource - Loaded JDBC driver: org.hsqldb.jdbcDriver 2013-12-10 19:46:07.079 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.o.j.LocalContainerEntityManagerFactoryBean - Building JPA container EntityManagerFactory for persistence unit 'default' 2013-12-10 19:46:07.200 [RMI TCP Connection(3)-127.0.0.1] INFO o.h.annotations.common.Version - HCANN000001: Hibernate Commons Annotations {4.0.2.Final} 2013-12-10 19:46:07.206 [RMI TCP Connection(3)-127.0.0.1] INFO org.hibernate.Version - HHH000412: Hibernate Core {4.2.5.Final} 2013-12-10 19:46:07.208 [RMI TCP Connection(3)-127.0.0.1] INFO org.hibernate.cfg.Environment - HHH000206: hibernate.properties not found 2013-12-10 19:46:07.209 [RMI TCP Connection(3)-127.0.0.1] INFO org.hibernate.cfg.Environment - HHH000021: Bytecode provider name : javassist 2013-12-10 19:46:07.228 [RMI TCP Connection(3)-127.0.0.1] INFO o.h.ejb.Ejb3Configuration - HHH000204: Processing PersistenceUnitInfo [ name: default ...] 2013-12-10 19:46:07.323 [RMI TCP Connection(3)-127.0.0.1] INFO o.h.s.j.c.i.ConnectionProviderInitiator - HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider 2013-12-10 19:46:07.564 [RMI TCP Connection(3)-127.0.0.1] INFO org.hibernate.dialect.Dialect - HHH000400: Using dialect: org.hibernate.dialect.HSQLDialect 2013-12-10 19:46:07.675 [RMI TCP Connection(3)-127.0.0.1] INFO o.h.e.t.i.TransactionFactoryInitiator - HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory 2013-12-10 19:46:07.679 [RMI TCP Connection(3)-127.0.0.1] INFO o.h.h.i.a.ASTQueryTranslatorFactory - HHH000397: Using ASTQueryTranslatorFactory 2013-12-10 19:46:07.715 [RMI TCP Connection(3)-127.0.0.1] INFO o.h.v.internal.util.Version - HV000001: Hibernate Validator 4.3.0.Final 2013-12-10 19:46:07.928 [RMI TCP Connection(3)-127.0.0.1] INFO o.h.tool.hbm2ddl.SchemaExport - HHH000227: Running hbm2ddl schema export 2013-12-10 19:46:07.930 [RMI TCP Connection(3)-127.0.0.1] INFO o.h.tool.hbm2ddl.SchemaExport - HHH000230: Schema export complete 2013-12-10 19:46:08.262 [RMI TCP Connection(3)-127.0.0.1] WARN o.h.e.j.i.JdbcCoordinatorImpl - HHH000386: ResultSet had no statement associated with it, but was not yet registered 2013-12-10 19:46:08.275 [RMI TCP Connection(3)-127.0.0.1] WARN o.h.e.j.i.JdbcCoordinatorImpl - HHH000386: ResultSet had no statement associated with it, but was not yet registered 2013-12-10 19:46:08.556 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.w.DefaultSecurityFilterChain - Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher@1, [org.springframework.security.web.context.SecurityContextPersistenceFilter@55f21a07, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@98aeda6, org.springframework.security.web.authentication.logout.LogoutFilter@7ff8322e, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@7fa6aba4, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@174edd75, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@3aad3847, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@4249db69, org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter@7ee3ec7e, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@25bb8547, org.springframework.security.web.session.SessionManagementFilter@3a2b0bab, org.springframework.security.web.access.ExceptionTranslationFilter@600b2562, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@7bc37630] 2013-12-10 19:46:08.570 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.h.DefaultFilterChainValidator - Checking whether login URL '/signin' is accessible with your configuration 2013-12-10 19:46:08.591 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 2238 ms 2013-12-10 19:46:08.606 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.servlet.DispatcherServlet - FrameworkServlet 'dispatcher': initialization started 2013-12-10 19:46:08.610 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - Refreshing WebApplicationContext for namespace 'dispatcher-servlet': startup date [Tue Dec 10 19:46:08 CET 2013]; parent: Root WebApplicationContext 2013-12-10 19:46:08.612 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - Registering annotated classes: [class pl.codeleak.testing.config.WebMvcConfig] 2013-12-10 19:46:08.693 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.b.f.a.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring 2013-12-10 19:46:08.902 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/account/current],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public pl.codeleak.testing.account.Account pl.codeleak.testing.account.AccountController.accounts(java.security.Principal) 2013-12-10 19:46:08.903 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/generalError],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String pl.codeleak.testing.error.CustomErrorController.generalError(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,org.springframework.ui.Model) 2013-12-10 19:46:08.903 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String pl.codeleak.testing.home.HomeController.index(java.security.Principal) 2013-12-10 19:46:08.903 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/signin],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String pl.codeleak.testing.signin.SigninController.signin() 2013-12-10 19:46:08.903 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/signup],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String pl.codeleak.testing.signup.SignupController.signup(org.springframework.ui.Model) 2013-12-10 19:46:08.904 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/signup],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String pl.codeleak.testing.signup.SignupController.signup(pl.codeleak.testing.signup.SignupForm,org.springframework.validation.Errors,org.springframework.web.servlet.mvc.support.RedirectAttributes) 2013-12-10 19:46:08.915 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.h.SimpleUrlHandlerMapping - Mapped URL path [/resources/] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2013-12-10 19:46:09.169 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.h.SimpleUrlHandlerMapping - Mapped URL path [/*] onto handler of type [class org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler] 2013-12-10 19:46:09.218 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.servlet.DispatcherServlet - FrameworkServlet 'dispatcher': initialization completed in 612 ms [2013-12-10 07:46:09,229] Artifact archetype-testing:war exploded: Artifact is deployed successfully [2013-12-10 07:46:09,230] Artifact archetype-testing:war exploded: Deploy took 5 192 milliseconds 2013-12-10 19:46:09.618 [http-apr-8080-exec-2] INFO org.thymeleaf.TemplateEngine - [THYMELEAF] INITIALIZING TEMPLATE ENGINE 2013-12-10 19:46:09.667 [http-apr-8080-exec-2] INFO o.t.t.AbstractTemplateResolver - [THYMELEAF] INITIALIZING TEMPLATE RESOLVER: org.thymeleaf.templateresolver.ServletContextTemplateResolver 2013-12-10 19:46:09.667 [http-apr-8080-exec-2] INFO o.t.t.AbstractTemplateResolver - [THYMELEAF] TEMPLATE RESOLVER INITIALIZED OK 2013-12-10 19:46:09.667 [http-apr-8080-exec-2] INFO o.t.m.AbstractMessageResolver - [THYMELEAF] INITIALIZING MESSAGE RESOLVER: org.thymeleaf.spring3.messageresolver.SpringMessageResolver 2013-12-10 19:46:09.668 [http-apr-8080-exec-2] INFO o.t.m.AbstractMessageResolver - [THYMELEAF] MESSAGE RESOLVER INITIALIZED OK 2013-12-10 19:46:09.671 [http-apr-8080-exec-2] INFO o.t.TemplateEngine.CONFIG - [THYMELEAF] TEMPLATE ENGINE CONFIGURATION: [THYMELEAF] * Cache Factory implementation: org.thymeleaf.cache.StandardCacheManager [THYMELEAF] * Template modes: [THYMELEAF] * XHTML [THYMELEAF] * VALIDXML [THYMELEAF] * HTML5 [THYMELEAF] * XML [THYMELEAF] * VALIDXHTML [THYMELEAF] * LEGACYHTML5 [THYMELEAF] * Template resolvers (in order): [THYMELEAF] * org.thymeleaf.templateresolver.ServletContextTemplateResolver [THYMELEAF] * Message resolvers (in order): [THYMELEAF] \ org.thymeleaf.spring3.messageresolver.SpringMessageResolver

[THYMELEAF] * Prefix: "th"

[THYMELEAF] * Prefix: "sec" [THYMELEAF] TEMPLATE ENGINE CONFIGURED OK 2013-12-10 19:46:09.671 [http-apr-8080-exec-2] INFO org.thymeleaf.TemplateEngine - [THYMELEAF] TEMPLATE ENGINE INITIALIZED

The change is rather easy:

@Configuration @ComponentScan(basePackageClasses = Application.class, excludeFilters = @Filter({Controller.class, Configuration.class})) class ApplicationConfig {}

@Configuration @ComponentScan(basePackageClasses = Application.class, includeFilters = @Filter(Controller.class), useDefaultFilters = false) class WebMvcConfig extends WebMvcConfigurationSupport {}

Could you please verify that and let me know?

BTW. As it goes to resources I will have a look.

johnlauer commented 10 years ago

Ok, I will try that.

BTW, I made some progress on the resources.

If you use public class WebMvcConfigurer extends WebMvcConfigurerAdapter {

Instead of public class WebMvcConfig extends WebMvcConfigurationSupport {

You get all of the overrides to be called, thus your @Override public void addResourceHandlers(ResourceHandlerRegistry registry) {

Gets correctly called when using WebMvcConfigurerAdapter. Otherwise it just never calls any overrides inside WebMvcConfigurationSupport and no resources get set.

From: Rafal Borowiec [mailto:notifications@github.com] Sent: Tuesday, December 10, 2013 10:50 AM To: kolorobot/spring-mvc-quickstart-archetype Cc: John Lauer Subject: Re: [spring-mvc-quickstart-archetype] Why does Root context and dispatcher context both instantiate @Service's, @Component's, etc? (#44)

Hi John,

Configuration was scanned via component scan, therefore context was initialized twice. This is strange, because previously @Configurationhttps://github.com/Configuration was not auto-scanned, I think. See the results now:

[2013-12-10 07:46:04,038] Artifact archetype-testing:war exploded: Artifact is being deployed, please wait... 2013-12-10 19:46:06.350 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.web.context.ContextLoader - Root WebApplicationContext: initialization started 2013-12-10 19:46:06.353 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Tue Dec 10 19:46:06 CET 2013]; root of context hierarchy 2013-12-10 19:46:06.424 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - Registering annotated classes: [class pl.codeleak.testing.config.ApplicationConfig,interface pl.codeleak.testing.config.DataSourceConfig,class pl.codeleak.testing.config.JpaConfig,class pl.codeleak.testing.config.SecurityConfig] 2013-12-10 19:46:06.641 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.b.f.x.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [spring-security-context.xml] 2013-12-10 19:46:06.741 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.SpringSecurityCoreVersion - You are running with Spring Security Core 3.2.0.RC2 2013-12-10 19:46:06.741 [RMI TCP Connection(3)-127.0.0.1] WARN o.s.s.c.SpringSecurityCoreVersion - * Spring Major version '3' expected, but you are running with version: 4.0.0.RC2. Please check your classpath for unwanted jar files. 2013-12-10 19:46:06.741 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.SecurityNamespaceHandler - Spring Security 'config' module version is 3.2.0.RC2 2013-12-10 19:46:06.775 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.h.FilterInvocationSecurityMetadataSourceParser - Creating access control expression attribute 'permitAll' for / 2013-12-10 19:46:06.775 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.h.FilterInvocationSecurityMetadataSourceParser - Creating access control expression attribute 'permitAll' for /favicon.ico 2013-12-10 19:46:06.775 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.h.FilterInvocationSecurityMetadataSourceParser - Creating access control expression attribute 'permitAll' for /resources/ 2013-12-10 19:46:06.775 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.h.FilterInvocationSecurityMetadataSourceParser - Creating access control expression attribute 'permitAll' for /signin 2013-12-10 19:46:06.775 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.h.FilterInvocationSecurityMetadataSourceParser - Creating access control expression attribute 'permitAll' for /signup 2013-12-10 19:46:06.776 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.h.FilterInvocationSecurityMetadataSourceParser - Creating access control expression attribute 'isAuthenticated()' for /** 2013-12-10 19:46:06.797 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.h.HttpSecurityBeanDefinitionParser - Checking sorted filter chain: [Root bean: class [org.springframework.security.web.context.SecurityContextPersistenceFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 200, Root bean: class [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 400, Root bean: class [org.springframework.security.web.authentication.logout.LogoutFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 700, , order = 1100, Root bean: class [org.springframework.security.web.authentication.www.BasicAuthenticationFilterhttp://www.BasicAuthenticationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1500, Root bean: class [org.springframework.security.web.savedrequest.RequestCacheAwareFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1600, Root bean: class [org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1700, Root bean: class [org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1900, Root bean: class [org.springframework.security.web.authentication.AnonymousAuthenticationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 2000, Root bean: class [org.springframework.security.web.session.SessionManagementFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 2100, Root bean: class [org.springframework.security.web.access.ExceptionTranslationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 2200, , order = 2300] 2013-12-10 19:46:06.895 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.b.f.c.PropertyPlaceholderConfigurer - Loading properties file from class path resource [persistence.properties] 2013-12-10 19:46:06.905 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.b.f.a.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring 2013-12-10 19:46:07.032 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.j.d.DriverManagerDataSource - Loaded JDBC driver: org.hsqldb.jdbcDriver 2013-12-10 19:46:07.079 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.o.j.LocalContainerEntityManagerFactoryBean - Building JPA container EntityManagerFactory for persistence unit 'default' 2013-12-10 19:46:07.200 [RMI TCP Connection(3)-127.0.0.1] INFO o.h.annotations.common.Version - HCANN000001: Hibernate Commons Annotations {4.0.2.Final} 2013-12-10 19:46:07.206 [RMI TCP Connection(3)-127.0.0.1] INFO org.hibernate.Version - HHH000412: Hibernate Core {4.2.5.Final} 2013-12-10 19:46:07.208 [RMI TCP Connection(3)-127.0.0.1] INFO org.hibernate.cfg.Environment - HHH000206: hibernate.properties not found 2013-12-10 19:46:07.209 [RMI TCP Connection(3)-127.0.0.1] INFO org.hibernate.cfg.Environment - HHH000021: Bytecode provider name : javassist 2013-12-10 19:46:07.228 [RMI TCP Connection(3)-127.0.0.1] INFO o.h.ejb.Ejb3Configuration - HHH000204: Processing PersistenceUnitInfo [ name: default ...] 2013-12-10 19:46:07.323 [RMI TCP Connection(3)-127.0.0.1] INFO o.h.s.j.c.i.ConnectionProviderInitiator - HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider 2013-12-10 19:46:07.564 [RMI TCP Connection(3)-127.0.0.1] INFO org.hibernate.dialect.Dialect - HHH000400: Using dialect: org.hibernate.dialect.HSQLDialect 2013-12-10 19:46:07.675 [RMI TCP Connection(3)-127.0.0.1] INFO o.h.e.t.i.TransactionFactoryInitiator - HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory 2013-12-10 19:46:07.679 [RMI TCP Connection(3)-127.0.0.1] INFO o.h.h.i.a.ASTQueryTranslatorFactory - HHH000397: Using ASTQueryTranslatorFactory 2013-12-10 19:46:07.715 [RMI TCP Connection(3)-127.0.0.1] INFO o.h.v.internal.util.Version - HV000001: Hibernate Validator 4.3.0.Final 2013-12-10 19:46:07.928 [RMI TCP Connection(3)-127.0.0.1] INFO o.h.tool.hbm2ddl.SchemaExport - HHH000227: Running hbm2ddl schema export 2013-12-10 19:46:07.930 [RMI TCP Connection(3)-127.0.0.1] INFO o.h.tool.hbm2ddl.SchemaExport - HHH000230: Schema export complete 2013-12-10 19:46:08.262 [RMI TCP Connection(3)-127.0.0.1] WARN o.h.e.j.i.JdbcCoordinatorImpl - HHH000386: ResultSet had no statement associated with it, but was not yet registered 2013-12-10 19:46:08.275 [RMI TCP Connection(3)-127.0.0.1] WARN o.h.e.j.i.JdbcCoordinatorImpl - HHH000386: ResultSet had no statement associated with it, but was not yet registered 2013-12-10 19:46:08.556 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.w.DefaultSecurityFilterChain - Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher@1mailto:org.springframework.security.web.util.matcher.AnyRequestMatcher@1, [org.springframework.security.web.context.SecurityContextPersistenceFilter@55f21a0https://github.com/org.springframework.security.web.context.SecurityContextPersistenceFilter/spring-mvc-quickstart-archetype/commit/55f21a07, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@98aeda6https://github.com/org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter/spring-mvc-quickstart-archetype/commit/98aeda6, org.springframework.security.web.authentication.logout.LogoutFilter@7ff8322https://github.com/org.springframework.security.web.authentication.logout.LogoutFilter/spring-mvc-quickstart-archetype/commit/7ff8322e, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@7fa6abahttps://github.com/org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter/spring-mvc-quickstart-archetype/commit/7fa6aba4, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@174edd75http://www.BasicAuthenticationFilter@174edd75, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@3aad384https://github.com/org.springframework.security.web.savedrequest.RequestCacheAwareFilter/spring-mvc-quickstart-archetype/commit/3aad3847, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@4249db6https://github.com/org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter/spring-mvc-quickstart-archetype/commit/4249db69, org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter@7ee3ec7https://github.com/org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter/spring-mvc-quickstart-archetype/commit/7ee3ec7e, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@25bb854https://github.com/org.springframework.security.web.authentication.AnonymousAuthenticationFilter/spring-mvc-quickstart-archetype/commit/25bb8547, org.springframework.security.web.session.SessionManagementFilter@3a2b0bahttps://github.com/org.springframework.security.web.session.SessionManagementFilter/spring-mvc-quickstart-archetype/commit/3a2b0bab, org.springframework.security.web.access.ExceptionTranslationFilter@600b256https://github.com/org.springframework.security.web.access.ExceptionTranslationFilter/spring-mvc-quickstart-archetype/commit/600b2562, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@7bc3763https://github.com/org.springframework.security.web.access.intercept.FilterSecurityInterceptor/spring-mvc-quickstart-archetype/commit/7bc37630] 2013-12-10 19:46:08.570 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.h.DefaultFilterChainValidator - Checking whether login URL '/signin' is accessible with your configuration 2013-12-10 19:46:08.591 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 2238 ms 2013-12-10 19:46:08.606 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.servlet.DispatcherServlet - FrameworkServlet 'dispatcher': initialization started 2013-12-10 19:46:08.610 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - Refreshing WebApplicationContext for namespace 'dispatcher-servlet': startup date [Tue Dec 10 19:46:08 CET 2013]; parent: Root WebApplicationContext 2013-12-10 19:46:08.612 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - Registering annotated classes: [class pl.codeleak.testing.config.WebMvcConfig] 2013-12-10 19:46:08.693 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.b.f.a.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring 2013-12-10 19:46:08.902 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/account/current],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public pl.codeleak.testing.account.Account pl.codeleak.testing.account.AccountController.accounts(java.security.Principal) 2013-12-10 19:46:08.903 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/generalError],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String pl.codeleak.testing.error.CustomErrorController.generalError(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,org.springframework.ui.Model) 2013-12-10 19:46:08.903 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String pl.codeleak.testing.home.HomeController.index(java.security.Principal) 2013-12-10 19:46:08.903 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/signin],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String pl.codeleak.testing.signin.SigninController.signin() 2013-12-10 19:46:08.903 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/signup],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String pl.codeleak.testing.signup.SignupController.signup(org.springframework.ui.Model) 2013-12-10 19:46:08.904 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/signup],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String pl.codeleak.testing.signup.SignupController.signup(pl.codeleak.testing.signup.SignupForm,org.springframework.validation.Errors,org.springframework.web.servlet.mvc.support.RedirectAttributes) 2013-12-10 19:46:08.915 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.h.SimpleUrlHandlerMapping - Mapped URL path [/resources/] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2013-12-10 19:46:09.169 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.h.SimpleUrlHandlerMapping - Mapped URL path [/*] onto handler of type [class org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler] 2013-12-10 19:46:09.218 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.servlet.DispatcherServlet - FrameworkServlet 'dispatcher': initialization completed in 612 ms [2013-12-10 07:46:09,229] Artifact archetype-testing:war exploded: Artifact is deployed successfully [2013-12-10 07:46:09,230] Artifact archetype-testing:war exploded: Deploy took 5 192 milliseconds 2013-12-10 19:46:09.618 [http-apr-8080-exec-2] INFO org.thymeleaf.TemplateEngine - [THYMELEAF] INITIALIZING TEMPLATE ENGINE 2013-12-10 19:46:09.667 [http-apr-8080-exec-2] INFO o.t.t.AbstractTemplateResolver - [THYMELEAF] INITIALIZING TEMPLATE RESOLVER: org.thymeleaf.templateresolver.ServletContextTemplateResolver 2013-12-10 19:46:09.667 [http-apr-8080-exec-2] INFO o.t.t.AbstractTemplateResolver - [THYMELEAF] TEMPLATE RESOLVER INITIALIZED OK 2013-12-10 19:46:09.667 [http-apr-8080-exec-2] INFO o.t.m.AbstractMessageResolver - [THYMELEAF] INITIALIZING MESSAGE RESOLVER: org.thymeleaf.spring3.messageresolver.SpringMessageResolver 2013-12-10 19:46:09.668 [http-apr-8080-exec-2] INFO o.t.m.AbstractMessageResolver - [THYMELEAF] MESSAGE RESOLVER INITIALIZED OK 2013-12-10 19:46:09.671 [http-apr-8080-exec-2] INFO o.t.TemplateEngine.CONFIG - [THYMELEAF] TEMPLATE ENGINE CONFIGURATION: [THYMELEAF] * Cache Factory implementation: org.thymeleaf.cache.StandardCacheManager [THYMELEAF] * Template modes: [THYMELEAF] * XHTML [THYMELEAF] * VALIDXML [THYMELEAF] * HTML5 [THYMELEAF] * XML [THYMELEAF] * VALIDXHTML [THYMELEAF] * LEGACYHTML5 [THYMELEAF] * Template resolvers (in order): [THYMELEAF] * org.thymeleaf.templateresolver.ServletContextTemplateResolver [THYMELEAF] * Message resolvers (in order): [THYMELEAF] \ org.thymeleaf.spring3.messageresolver.SpringMessageResolver

[THYMELEAF] * Prefix: "th"

[THYMELEAF] * Prefix: "sec" [THYMELEAF] TEMPLATE ENGINE CONFIGURED OK 2013-12-10 19:46:09.671 [http-apr-8080-exec-2] INFO org.thymeleaf.TemplateEngine - [THYMELEAF] TEMPLATE ENGINE INITIALIZED

The change is rather easy:

@Configurationhttps://github.com/Configuration @ComponentScan(basePackageClasses = Application.class, excludeFilters = @Filterhttps://github.com/Filter({Controller.class, Configuration.class})) class ApplicationConfig {}

@Configurationhttps://github.com/Configuration @ComponentScan(basePackageClasses = Application.class, includeFilters = @Filterhttps://github.com/Filter(Controller.class), useDefaultFilters = false) class WebMvcConfig extends WebMvcConfigurationSupport {}

Could you please verify that and let me know?

BTW. As it goes to resources I will have a look.

— Reply to this email directly or view it on GitHubhttps://github.com/kolorobot/spring-mvc-quickstart-archetype/issues/44#issuecomment-30255872.

kolorobot commented 10 years ago

Hi John,

I have just checked the WebMvcConfigurationSupport on startup and all the inherited methods were executed. As you mentioned, I am using Windows and Tomcat 7 (in IntelliJ). But what you write sounds pretty odd in fact.

I checked this with both JDK7 and JDK8 on Windows.

johnlauer commented 10 years ago

Ok, tried it. It worked great. Nice work. That was easier than my approach.

I did have to move to public class WebMvcConfigurer extends WebMvcConfigurerAdapter {

to get all of the overrides to work. I tried both approaches. Only this one worked.

From: Rafal Borowiec [mailto:notifications@github.com] Sent: Tuesday, December 10, 2013 10:50 AM To: kolorobot/spring-mvc-quickstart-archetype Cc: John Lauer Subject: Re: [spring-mvc-quickstart-archetype] Why does Root context and dispatcher context both instantiate @Service's, @Component's, etc? (#44)

Hi John,

Configuration was scanned via component scan, therefore context was initialized twice. This is strange, because previously @Configurationhttps://github.com/Configuration was not auto-scanned, I think. See the results now:

[2013-12-10 07:46:04,038] Artifact archetype-testing:war exploded: Artifact is being deployed, please wait... 2013-12-10 19:46:06.350 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.web.context.ContextLoader - Root WebApplicationContext: initialization started 2013-12-10 19:46:06.353 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Tue Dec 10 19:46:06 CET 2013]; root of context hierarchy 2013-12-10 19:46:06.424 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - Registering annotated classes: [class pl.codeleak.testing.config.ApplicationConfig,interface pl.codeleak.testing.config.DataSourceConfig,class pl.codeleak.testing.config.JpaConfig,class pl.codeleak.testing.config.SecurityConfig] 2013-12-10 19:46:06.641 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.b.f.x.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [spring-security-context.xml] 2013-12-10 19:46:06.741 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.SpringSecurityCoreVersion - You are running with Spring Security Core 3.2.0.RC2 2013-12-10 19:46:06.741 [RMI TCP Connection(3)-127.0.0.1] WARN o.s.s.c.SpringSecurityCoreVersion - * Spring Major version '3' expected, but you are running with version: 4.0.0.RC2. Please check your classpath for unwanted jar files. 2013-12-10 19:46:06.741 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.SecurityNamespaceHandler - Spring Security 'config' module version is 3.2.0.RC2 2013-12-10 19:46:06.775 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.h.FilterInvocationSecurityMetadataSourceParser - Creating access control expression attribute 'permitAll' for / 2013-12-10 19:46:06.775 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.h.FilterInvocationSecurityMetadataSourceParser - Creating access control expression attribute 'permitAll' for /favicon.ico 2013-12-10 19:46:06.775 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.h.FilterInvocationSecurityMetadataSourceParser - Creating access control expression attribute 'permitAll' for /resources/ 2013-12-10 19:46:06.775 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.h.FilterInvocationSecurityMetadataSourceParser - Creating access control expression attribute 'permitAll' for /signin 2013-12-10 19:46:06.775 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.h.FilterInvocationSecurityMetadataSourceParser - Creating access control expression attribute 'permitAll' for /signup 2013-12-10 19:46:06.776 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.h.FilterInvocationSecurityMetadataSourceParser - Creating access control expression attribute 'isAuthenticated()' for /** 2013-12-10 19:46:06.797 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.h.HttpSecurityBeanDefinitionParser - Checking sorted filter chain: [Root bean: class [org.springframework.security.web.context.SecurityContextPersistenceFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 200, Root bean: class [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 400, Root bean: class [org.springframework.security.web.authentication.logout.LogoutFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 700, , order = 1100, Root bean: class [org.springframework.security.web.authentication.www.BasicAuthenticationFilterhttp://www.BasicAuthenticationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1500, Root bean: class [org.springframework.security.web.savedrequest.RequestCacheAwareFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1600, Root bean: class [org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1700, Root bean: class [org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1900, Root bean: class [org.springframework.security.web.authentication.AnonymousAuthenticationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 2000, Root bean: class [org.springframework.security.web.session.SessionManagementFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 2100, Root bean: class [org.springframework.security.web.access.ExceptionTranslationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 2200, , order = 2300] 2013-12-10 19:46:06.895 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.b.f.c.PropertyPlaceholderConfigurer - Loading properties file from class path resource [persistence.properties] 2013-12-10 19:46:06.905 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.b.f.a.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring 2013-12-10 19:46:07.032 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.j.d.DriverManagerDataSource - Loaded JDBC driver: org.hsqldb.jdbcDriver 2013-12-10 19:46:07.079 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.o.j.LocalContainerEntityManagerFactoryBean - Building JPA container EntityManagerFactory for persistence unit 'default' 2013-12-10 19:46:07.200 [RMI TCP Connection(3)-127.0.0.1] INFO o.h.annotations.common.Version - HCANN000001: Hibernate Commons Annotations {4.0.2.Final} 2013-12-10 19:46:07.206 [RMI TCP Connection(3)-127.0.0.1] INFO org.hibernate.Version - HHH000412: Hibernate Core {4.2.5.Final} 2013-12-10 19:46:07.208 [RMI TCP Connection(3)-127.0.0.1] INFO org.hibernate.cfg.Environment - HHH000206: hibernate.properties not found 2013-12-10 19:46:07.209 [RMI TCP Connection(3)-127.0.0.1] INFO org.hibernate.cfg.Environment - HHH000021: Bytecode provider name : javassist 2013-12-10 19:46:07.228 [RMI TCP Connection(3)-127.0.0.1] INFO o.h.ejb.Ejb3Configuration - HHH000204: Processing PersistenceUnitInfo [ name: default ...] 2013-12-10 19:46:07.323 [RMI TCP Connection(3)-127.0.0.1] INFO o.h.s.j.c.i.ConnectionProviderInitiator - HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider 2013-12-10 19:46:07.564 [RMI TCP Connection(3)-127.0.0.1] INFO org.hibernate.dialect.Dialect - HHH000400: Using dialect: org.hibernate.dialect.HSQLDialect 2013-12-10 19:46:07.675 [RMI TCP Connection(3)-127.0.0.1] INFO o.h.e.t.i.TransactionFactoryInitiator - HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory 2013-12-10 19:46:07.679 [RMI TCP Connection(3)-127.0.0.1] INFO o.h.h.i.a.ASTQueryTranslatorFactory - HHH000397: Using ASTQueryTranslatorFactory 2013-12-10 19:46:07.715 [RMI TCP Connection(3)-127.0.0.1] INFO o.h.v.internal.util.Version - HV000001: Hibernate Validator 4.3.0.Final 2013-12-10 19:46:07.928 [RMI TCP Connection(3)-127.0.0.1] INFO o.h.tool.hbm2ddl.SchemaExport - HHH000227: Running hbm2ddl schema export 2013-12-10 19:46:07.930 [RMI TCP Connection(3)-127.0.0.1] INFO o.h.tool.hbm2ddl.SchemaExport - HHH000230: Schema export complete 2013-12-10 19:46:08.262 [RMI TCP Connection(3)-127.0.0.1] WARN o.h.e.j.i.JdbcCoordinatorImpl - HHH000386: ResultSet had no statement associated with it, but was not yet registered 2013-12-10 19:46:08.275 [RMI TCP Connection(3)-127.0.0.1] WARN o.h.e.j.i.JdbcCoordinatorImpl - HHH000386: ResultSet had no statement associated with it, but was not yet registered 2013-12-10 19:46:08.556 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.w.DefaultSecurityFilterChain - Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher@1mailto:org.springframework.security.web.util.matcher.AnyRequestMatcher@1, [org.springframework.security.web.context.SecurityContextPersistenceFilter@55f21a0https://github.com/org.springframework.security.web.context.SecurityContextPersistenceFilter/spring-mvc-quickstart-archetype/commit/55f21a07, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@98aeda6https://github.com/org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter/spring-mvc-quickstart-archetype/commit/98aeda6, org.springframework.security.web.authentication.logout.LogoutFilter@7ff8322https://github.com/org.springframework.security.web.authentication.logout.LogoutFilter/spring-mvc-quickstart-archetype/commit/7ff8322e, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@7fa6abahttps://github.com/org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter/spring-mvc-quickstart-archetype/commit/7fa6aba4, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@174edd75http://www.BasicAuthenticationFilter@174edd75, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@3aad384https://github.com/org.springframework.security.web.savedrequest.RequestCacheAwareFilter/spring-mvc-quickstart-archetype/commit/3aad3847, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@4249db6https://github.com/org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter/spring-mvc-quickstart-archetype/commit/4249db69, org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter@7ee3ec7https://github.com/org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter/spring-mvc-quickstart-archetype/commit/7ee3ec7e, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@25bb854https://github.com/org.springframework.security.web.authentication.AnonymousAuthenticationFilter/spring-mvc-quickstart-archetype/commit/25bb8547, org.springframework.security.web.session.SessionManagementFilter@3a2b0bahttps://github.com/org.springframework.security.web.session.SessionManagementFilter/spring-mvc-quickstart-archetype/commit/3a2b0bab, org.springframework.security.web.access.ExceptionTranslationFilter@600b256https://github.com/org.springframework.security.web.access.ExceptionTranslationFilter/spring-mvc-quickstart-archetype/commit/600b2562, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@7bc3763https://github.com/org.springframework.security.web.access.intercept.FilterSecurityInterceptor/spring-mvc-quickstart-archetype/commit/7bc37630] 2013-12-10 19:46:08.570 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.s.c.h.DefaultFilterChainValidator - Checking whether login URL '/signin' is accessible with your configuration 2013-12-10 19:46:08.591 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 2238 ms 2013-12-10 19:46:08.606 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.servlet.DispatcherServlet - FrameworkServlet 'dispatcher': initialization started 2013-12-10 19:46:08.610 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - Refreshing WebApplicationContext for namespace 'dispatcher-servlet': startup date [Tue Dec 10 19:46:08 CET 2013]; parent: Root WebApplicationContext 2013-12-10 19:46:08.612 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - Registering annotated classes: [class pl.codeleak.testing.config.WebMvcConfig] 2013-12-10 19:46:08.693 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.b.f.a.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring 2013-12-10 19:46:08.902 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/account/current],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public pl.codeleak.testing.account.Account pl.codeleak.testing.account.AccountController.accounts(java.security.Principal) 2013-12-10 19:46:08.903 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/generalError],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String pl.codeleak.testing.error.CustomErrorController.generalError(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,org.springframework.ui.Model) 2013-12-10 19:46:08.903 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String pl.codeleak.testing.home.HomeController.index(java.security.Principal) 2013-12-10 19:46:08.903 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/signin],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String pl.codeleak.testing.signin.SigninController.signin() 2013-12-10 19:46:08.903 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/signup],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String pl.codeleak.testing.signup.SignupController.signup(org.springframework.ui.Model) 2013-12-10 19:46:08.904 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/signup],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String pl.codeleak.testing.signup.SignupController.signup(pl.codeleak.testing.signup.SignupForm,org.springframework.validation.Errors,org.springframework.web.servlet.mvc.support.RedirectAttributes) 2013-12-10 19:46:08.915 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.h.SimpleUrlHandlerMapping - Mapped URL path [/resources/] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2013-12-10 19:46:09.169 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.h.SimpleUrlHandlerMapping - Mapped URL path [/*] onto handler of type [class org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler] 2013-12-10 19:46:09.218 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.servlet.DispatcherServlet - FrameworkServlet 'dispatcher': initialization completed in 612 ms [2013-12-10 07:46:09,229] Artifact archetype-testing:war exploded: Artifact is deployed successfully [2013-12-10 07:46:09,230] Artifact archetype-testing:war exploded: Deploy took 5 192 milliseconds 2013-12-10 19:46:09.618 [http-apr-8080-exec-2] INFO org.thymeleaf.TemplateEngine - [THYMELEAF] INITIALIZING TEMPLATE ENGINE 2013-12-10 19:46:09.667 [http-apr-8080-exec-2] INFO o.t.t.AbstractTemplateResolver - [THYMELEAF] INITIALIZING TEMPLATE RESOLVER: org.thymeleaf.templateresolver.ServletContextTemplateResolver 2013-12-10 19:46:09.667 [http-apr-8080-exec-2] INFO o.t.t.AbstractTemplateResolver - [THYMELEAF] TEMPLATE RESOLVER INITIALIZED OK 2013-12-10 19:46:09.667 [http-apr-8080-exec-2] INFO o.t.m.AbstractMessageResolver - [THYMELEAF] INITIALIZING MESSAGE RESOLVER: org.thymeleaf.spring3.messageresolver.SpringMessageResolver 2013-12-10 19:46:09.668 [http-apr-8080-exec-2] INFO o.t.m.AbstractMessageResolver - [THYMELEAF] MESSAGE RESOLVER INITIALIZED OK 2013-12-10 19:46:09.671 [http-apr-8080-exec-2] INFO o.t.TemplateEngine.CONFIG - [THYMELEAF] TEMPLATE ENGINE CONFIGURATION: [THYMELEAF] * Cache Factory implementation: org.thymeleaf.cache.StandardCacheManager [THYMELEAF] * Template modes: [THYMELEAF] * XHTML [THYMELEAF] * VALIDXML [THYMELEAF] * HTML5 [THYMELEAF] * XML [THYMELEAF] * VALIDXHTML [THYMELEAF] * LEGACYHTML5 [THYMELEAF] * Template resolvers (in order): [THYMELEAF] * org.thymeleaf.templateresolver.ServletContextTemplateResolver [THYMELEAF] * Message resolvers (in order): [THYMELEAF] \ org.thymeleaf.spring3.messageresolver.SpringMessageResolver

[THYMELEAF] * Prefix: "th"

[THYMELEAF] * Prefix: "sec" [THYMELEAF] TEMPLATE ENGINE CONFIGURED OK 2013-12-10 19:46:09.671 [http-apr-8080-exec-2] INFO org.thymeleaf.TemplateEngine - [THYMELEAF] TEMPLATE ENGINE INITIALIZED

The change is rather easy:

@Configurationhttps://github.com/Configuration @ComponentScan(basePackageClasses = Application.class, excludeFilters = @Filterhttps://github.com/Filter({Controller.class, Configuration.class})) class ApplicationConfig {}

@Configurationhttps://github.com/Configuration @ComponentScan(basePackageClasses = Application.class, includeFilters = @Filterhttps://github.com/Filter(Controller.class), useDefaultFilters = false) class WebMvcConfig extends WebMvcConfigurationSupport {}

Could you please verify that and let me know?

BTW. As it goes to resources I will have a look.

— Reply to this email directly or view it on GitHubhttps://github.com/kolorobot/spring-mvc-quickstart-archetype/issues/44#issuecomment-30255872.

kolorobot commented 10 years ago

But, have you checked the tests? They seem to fail after this change. And why the hell it runs on Windows correctly (without any change?)

johnlauer commented 10 years ago

Well, I am running this on Windows and I’m seeing it fail. I’m using Java 7. Seeing consistent behavior on Ubuntu as well.

Just not sure.

From: Rafal Borowiec [mailto:notifications@github.com] Sent: Tuesday, December 10, 2013 11:10 AM To: kolorobot/spring-mvc-quickstart-archetype Cc: John Lauer Subject: Re: [spring-mvc-quickstart-archetype] Why does Root context and dispatcher context both instantiate @Service's, @Component's, etc? (#44)

But, have you checked the tests? They seem to fail after this change. And why the hell it runs on Windows correctly (without any change?)

— Reply to this email directly or view it on GitHubhttps://github.com/kolorobot/spring-mvc-quickstart-archetype/issues/44#issuecomment-30257751.

kolorobot commented 10 years ago

I debugged the original code with IJ couple of times already and to be honest it just works fine. Pretty annoying.

johnlauer commented 10 years ago

That helps to know. It makes me think perhaps it’s something in my pom.xml that is throwing off the behavior of Spring on the load sequence. The only thing is, in your older version using Spring 3.2 I saw this occur with just the basic archetype and nothing really new added except a couple of new JSP’s.

From: Rafal Borowiec [mailto:notifications@github.com] Sent: Tuesday, December 10, 2013 11:28 AM To: kolorobot/spring-mvc-quickstart-archetype Cc: John Lauer Subject: Re: [spring-mvc-quickstart-archetype] Why does Root context and dispatcher context both instantiate @Service's, @Component's, etc? (#44)

I debugged the original code with IJ couple of times already and to be honest it just works fine. Pretty annoying.

— Reply to this email directly or view it on GitHubhttps://github.com/kolorobot/spring-mvc-quickstart-archetype/issues/44#issuecomment-30259313.

johnlauer commented 10 years ago

BTW, to get my @EnableScheduling to work I had to tweak your includeFilters.

@Configuration @EnableScheduling @ComponentScan(basePackageClasses = Application.class, includeFilters = {@Filter(Controller.class), @Filter(Service.class)}, useDefaultFilters = false) public class WebMvcConfigurer extends WebMvcConfigurerAdapter {

From: Rafal Borowiec [mailto:notifications@github.com] Sent: Tuesday, December 10, 2013 11:28 AM To: kolorobot/spring-mvc-quickstart-archetype Cc: John Lauer Subject: Re: [spring-mvc-quickstart-archetype] Why does Root context and dispatcher context both instantiate @Service's, @Component's, etc? (#44)

I debugged the original code with IJ couple of times already and to be honest it just works fine. Pretty annoying.

— Reply to this email directly or view it on GitHubhttps://github.com/kolorobot/spring-mvc-quickstart-archetype/issues/44#issuecomment-30259313.

kolorobot commented 10 years ago

Why dont you put scheduled services to root context. I believe this is more Root than Web. Dont u think?

johnlauer commented 10 years ago

Ahh. Good point.

From: Rafal Borowiec [mailto:notifications@github.com] Sent: Tuesday, December 10, 2013 11:43 AM To: kolorobot/spring-mvc-quickstart-archetype Cc: John Lauer Subject: Re: [spring-mvc-quickstart-archetype] Why does Root context and dispatcher context both instantiate @Service's, @Component's, etc? (#44)

Why dont you put scheduled services to root context. I believe this is more Root than Web. Dont u think?

— Reply to this email directly or view it on GitHubhttps://github.com/kolorobot/spring-mvc-quickstart-archetype/issues/44#issuecomment-30260697.