Announcement Announcement Module
No announcement yet.
Spring Portlet MVC and bean scopes Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Portlet MVC and bean scopes

    Developing a spring portlet using Spring Portlet MVC to be used in liferay.
    Using Liferay version 5.1.1.
    Spring version 2.5.3 in portlet web-inf/lib
    To make a clear and reproducible example i restarted with petportal sample portlet from spring.

    Trying to add session or globalSession scoped beans to petsites-portlet controller (PetSitesRedirectController). In this case (example) I would like to add a favourite petsite bean backed by spring:

    from petsites-portlet.xml

      <bean id="fav" class="org.springframework.samples.petportal.domain.PetSite" scope="session">
      <bean class="org.springframework.samples.petportal.portlet.PetSitesRedirectController">
        <property name="petSites" ref="petSites"/>
        <property name="favourite" ref="fav"/>
    In the PetSitesRedirectController I only added getter and setter for favourite property.

    In web.xml i have tried the following things in separatley and in combination:

    1. add a listener:
    2. add a filter:
    3. Filter with diffrent mapping
    In all above cases I get the following error:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.portlet.mvc.annotation.DefaultAnnotati
    onHandlerMapping#0' defined in PortletContext resource [/WEB-INF/context/petsites-portlet.xml]: Initialization of bean failed; nested exception is org
    .springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.samples.petportal.portlet.PetSitesRedirectCon
    troller#0' defined in PortletContext resource [/WEB-INF/context/petsites-portlet.xml]: Error setting property values; nested exception is org.springfr
    amework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
    PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'favourite' threw exception; nested exception is org.springfr
    amework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.fav': Scope 'session' is not active for the current thread; c
    onsider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No t
    hread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally
     receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of Dispatc
    herServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
    What am I missing?

    Best Regards
    Erik Mellegård

  • #2
    Well, I've nearly the same problem with my globalSession in WebSphere Portal. Did anyone find a solution?


    • #3

      Have you found the solution for this?