Spring and Portlet 2.0

Hi I am using spring and I am moving on Portlet 2.0. I have problem how to get services to application class. I am new to spring and portlets overall. Here is my configuration from spring.

<bean id="'applicationBean" class="com.example.demo.DemoApplication" scope="prototype">
		<property name="demoService" ref="demoBean"></property>

<bean id="demoBean" class="service.impl.DemoServiceImpl"></bean>

When I was using portlet 1.0, I just called application url in Portlet.xml. But now I have to call
the DemoApplication class.

    <display-name>Demo Portlet </display-name>
<!-- Map portlet to a servlet. -->

Is there good solution where I could set my services in spring config, without that autowire?

Thanks for your help

Hello Petteri,

Maybe you could subclass AbstractApplicationPortlet and look up the application instance from Spring?


I used this kind of solution for the problem

context = PortletApplicationContextUtils.getRequiredWebApplicationContext(portletContext);


old thread, but relevant for my specific situation.

@Petteri: How do you get your ‘portletContext’ needed as a parameter in the “PortletApplicationContextUtils.getRequiredWebApplicationContext(portletContext)” call?

The reason I’m asking is that I have an issue where the context I’m getting when I do a ‘getContext’ in my application, is not of type PortletApplicationContext, nor PortletApplicationContext2. It is in fact of type ‘WebApplicationContext’ which is really REALLY weird and very disturbing to me…

so ehm, any idea?