Thank you for the feedback Marten. I followed your feedback, but am still observing errors. I referred to the spring docs for suggestion #3, but would like to confirm with this app-config.xml snippet that I implemented it correctly:
Code:
<context:component-scan base-package="com.company.app"
use-default-filters="false">
<context:include-filter type="annotation"
expression="org.springframework.stereotype.Controller" />
</context:component-scan>
Naturally, you could not have known that localeResolver was injected into languageSetterHandlerInterceptor. I had to move localeResolver back to app-config.xml, otherwise I observed this exception in the logs:
Code:
2010-09-26 15:50:57,818 ERROR [org.springframework.web.context.ContextLoader] (main) Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'languageSetterHandlerInterceptor': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.springframework.web.servlet.LocaleResolver com.company.app.interceptor.LanguageSetterHandlerInterceptor.localeResolver; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [org.springframework.web.servlet.LocaleResolver] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
.
.
The application then started without errors. But, once I entered a URL in the browser to request a page, I observed the following exception in my jboss logs:
Code:
2010-09-26 16:05:35,338 ERROR [org.hibernate.LazyInitializationException] (http-127.0.0.1-8080-1) failed to lazily initialize a collection of role: com.company.app.model.Page.components, no session or session was closed
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.company.app.model.Page.components, no session or session was closed
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:380)
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:372)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:365)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:108)
at org.hibernate.collection.PersistentBag.iterator(PersistentBag.java:272)
at com.company.app.ApplicationController.populatePage(ApplicationController.java:233)
at com.company.app.ApplicationController.doGet(ApplicationController.java:104)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
.
.
Here is the method within which the exception occurs. The specific line is the start of the for loop containing the call to page.getComponents()
Code:
protected void populatePage(OrderablePage page,
OrderingSession orderingSession) {
for (PageComponent pageComponent : page.getComponents()) {
IComponentService componentService = componentServiceLocator
.getComponentServiceByPageComponent(pageComponent
.getClass());
if (componentService != null) {
componentService.populatePageComponent(pageComponent,
orderingSession);
}
}
}
Any more feedback would be appreciated.