spent much time here search for the answer but could not find. Would really appreciate if someone will suggest a solution. My challenge is the following - with Spring 3.0.5 and annotated controllers I'm trying to implement more than one portlet in single war file. There's a substantial application context which should be used by both the portlets. And of course I want to share it to avoid double load.
So code-wise, my global shared application context:
I want my individual portlet context to look like this
...bunch of various beans, including AnnotationMethodHandlerAdapter,
DefaultAnnotationHandlerMapping and InternalResourceViewResolver
The following options don't work:
<context:component-scan base-package="com.mytest.controller.portlet1controller" />
- Adding <import "main-context"> to my individual portlet context file - it loads main application context twice (in case of two portlets). The same effect is achieved when I specify two context files in portlet definition in portlet.xml
- Specifying ContextLoaderListener and contextConfigLocation in web.xml and not mentioning it in portlet.xml file - in this case each individual portlet controller cannot autowire beans that are defined in global application context
- Not adding anything at all assuming it should work like this - Spring cannot find handler for portlet render request.
I have seen many similar questions over internet but they are either unanswered or answered in a way that doesn't work.
My opinion is that this pattern is quite common - please any suggestions welcome.