tags:

views:

132

answers:

1

Hello,

I'm trying to get my Portlets work with some DAO Objects which I configured as spring beans. I've included an application.xml to my WEB-INF, added it to my web.xml, configured hibernater support, a datasource. Everything seems fine, after deployment I see the context loaded message from spring. Now I'm trying to get one dao object injected in my regular portlet (extends GenericPortlet) with the

[at]Autowired

Annonation. But the object is still null. Isn't it possible to use spring managed DAO objects without a regular spring mvc controller?

Thanks for reading

+2  A: 

The classes that the DAO is to be injected into must be also inside ths spring context. You can either take a look at this, or get the DAO by accessing the ApplicationContext, rather than have the beans injected. The ApplicationContext can be obtained with:

PortletApplicationContextUtils.getRequiredWebApplicationContext(portletContext)
Bozho
Well I was excepting such thing. I don't want to refactor all my portlets to spring mvc portlet. Do you have an example to get the DAO by the ApplicationContext
asrijaal
check my update
Bozho
I'll check this out tomorrow and report here - maybe it could work through the portletcontext. thanks Bozho!
asrijaal
PortletApplicationContextUtils.getRequiredWebApplicationContext(portletContext) - this is it.
asrijaal