Results 1 to 5 of 5

Thread: PortletOpenSessionInViewInterceptor - Spring Portlet MVC+Hibernate

  1. #1
    Join Date
    Aug 2006
    Posts
    2

    Default PortletOpenSessionInViewInterceptor - Spring Portlet MVC+Hibernate

    Hi
    I'll try to write simple WSRP portlet application (my portlet container - OC4J). The ORM is realized by Hibernate. I have problems with lazy loading (collections are not initialize, I get error "session is closed").

    I know, that this problem can be resolved by using PortletOpenSessionInViewInterceptor(my bean conf - under stack trace). I defined this bean, but I get very strange Exception in preHandle method:

    06/08/24 15:52:14 spring: An internal error has occurred in method getMarkup()
    javax.portlet.PortletException: Error occured during request processing: org.springframework.orm.hibernate3.support.Portlet OpenSessionInViewInterceptor.preHandle(Ljavax/portlet/PortletRequest;Ljavax/portlet/PortletResponse;Ljava/lang/ObjectZ
    at org.springframework.web.portlet.DispatcherPortlet. doRenderService(DispatcherPortlet.java:745)
    at org.springframework.web.portlet.FrameworkPortlet.p rocessRequest(FrameworkPortlet.java:420)
    at org.springframework.web.portlet.FrameworkPortlet.d oDispatch(FrameworkPortlet.java:391)
    at javax.portlet.GenericPortlet.render(Unknown Source)
    at oracle.webdb.wsrp.server.Server.getMarkup(Unknown Source)
    at oracle.webdb.wsrp.WSRP_v1_Markup_PortType_Tie.invo ke_getMarkup(WSRP_v1_Markup_PortType_Tie.java:224)
    at oracle.webdb.wsrp.WSRP_v1_Markup_PortType_Tie.proc essingHook(WSRP_v1_Markup_PortType_Tie.java:499)
    at com.sun.xml.rpc.server.StreamingHandler.handle(Str eamingHandler.java:230)
    at com.sun.xml.rpc.server.http.ea.JAXRPCServletDelega te.doPost(JAXRPCServletDelegate.java:153)
    at com.sun.xml.rpc.server.http.JAXRPCServlet.doPost(J AXRPCServlet.java:69)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:760)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:853)
    at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.ResourceFilterChain.doFilter(Resource FilterChain.java:65)
    at oracle.webdb.wsrp.server.ContextFilter.doFilter(Un known Source)
    at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.ServletRequestDispatcher.invoke(Servl etRequestDispatcher.java:663)
    at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.ServletRequestDispatcher.forwardInter nal(ServletRequestDispatcher.java:330)
    at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.HttpRequestHandler.processRequest(Htt pRequestHandler.java:830)
    at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.AJPRequestHandler.run(AJPRequestHandl er.java:224)
    at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.AJPRequestHandler.run(AJPRequestHandl er.java:133)
    at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].util.ReleasableResourcePooledExecutor$MyWorker.ru n(ReleasableResourcePooledExecutor.java:192)
    at java.lang.Thread.run(Thread.java:534)
    Caused by: java.lang.AbstractMethodError: org.springframework.orm.hibernate3.support.Portlet OpenSessionInViewInterceptor.preHandle(Ljavax/portlet/PortletRequest;Ljavax/portlet/PortletResponse;Ljava/lang/ObjectZ
    at org.springframework.web.portlet.DispatcherPortlet. doRenderService(DispatcherPortlet.java:695)
    ... 20 more


    This is my bean definition:

    <bean name="openSessionInViewInterceptor" class="org.springframework.orm.hibernate3.support. PortletOpenSessionInViewInterceptor">
    <property name="sessionFactory"><ref bean="sessionFactory"/></property>
    </bean>

    <bean id="portletModeParameterHandlerMapping" class="org.springframework.web.portlet.handler.Por tletModeParameterHandlerMapping">
    <property name="interceptors">
    <list><ref bean="openSessionInViewInterceptor"/></list>
    </property>
    <property name="portletModeParameterMap">
    .............
    </property>
    </bean>

    Thanks for your help

    Best regards
    mario

  2. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Seems that you are using some incompatible libraries - the code tries to use an abstract method - it's likely that you are using different libraries version. Check the spring jars and make sure you are using the same distribution.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3
    Join Date
    Aug 2006
    Posts
    2

    Default Thanks for your help

    It was my library conflict.

    Best regards
    Mario

  4. #4
    Join Date
    Mar 2005
    Posts
    5

    Default

    Note that PortletOpenSessionInViewInterceptor was removed in 2.0-rc3 in favor of a common interceptor class for both web and portlet requests (see the changelog for details). When I updated to rc3, I tried adding a OpenSessionInViewInterceptor to my PortletModeHandlerMapping object, but got an error stating that the value for my interceptors property could not be coerced to HandlerMapping[]. The current javadocs say that org.springframework.web.portlet.handler.AbstractHa ndlerMapping.setInterceptors() will accept both HandlerInterceptor and WebRequestInterceptor. In the end, I had to wrap the interceptor in a WebRequestHandlerInterceptorAdapter:

    <bean name="openSessionInViewInterceptor" class="org.springframework.web.portlet.handler.Web RequestHandlerInterceptorAdapter">
    <constructor-arg>
    <bean class="org.springframework.orm.hibernate3.support. OpenSessionInViewInterceptor">
    <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
    </constructor-arg>
    </bean>


    This appears to work fine. After the change, my JSPs have access to lazily-loaded object properties.

  5. #5
    Join Date
    Feb 2007
    Posts
    9

    Default Not able to access hibernate objects in jsps

    After reading ur post i implemented the same context configurations but it doesnt work for me. I still get the same hibernate lazy load error. Do I need to make any entry in web.xml aslo?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •