• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

constructor in my controller is called twice, the setter only once

 
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have a controller which has a dao (lectureDao) in it

applicationContext:


first, the constructor ViewController() is called, then setLectureDao and then again the ViewController() constructor and i have no idea why this happens.
i tried it with lazy loading but that didnt change anything - and because of the second constructor call the lectureDao is always null when i try to access it.
it is set correctly when the constructor has been called once.

its a liferay portlet and i use the org.springframework.web.portlet.DispatcherPortlet (in portlet.xml) as my dispatcher
can someone give me any hint whats going on? how i could fix this?

 
olze oli
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i found the problem
in my MontyBrogan-portlet.xml i defined the bean with:
<bean id="viewController" class="Controller.ViewController"></bean>

so first applicationContext called the setter and then the MontyBrogan-portlet called the constructor which set lectureDao to null

 
reply
    Bookmark Topic Watch Topic
  • New Topic