You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Tomasz Prus <to...@gmail.com> on 2008/05/07 14:24:01 UTC

OpenSessionInView and LazyInitializationException

I had such configuration:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/carpartswebsite-servlet.xml</param-value>
    </context-param>

    <listener>

<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>carpartswebsite</servlet-name>

<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
      </servlet>

      <servlet>
        <servlet-name>wicket</servlet-name>

<servlet-class>org.apache.wicket.protocol.http.WicketServlet</servlet-class>
        <init-param>
            <param-name>applicationFactoryClassName</param-name>

<param-value>org.apache.wicket.spring.SpringWebApplicationFactory</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

      <servlet-mapping>
        <servlet-name>wicket</servlet-name>
        <url-pattern>/*</url-pattern>
      </servlet-mapping>

      <servlet>
        <servlet-name>XFireSOAPServlet</servlet-name>

<servlet-class>org.codehaus.xfire.spring.XFireSpringServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>XFireSOAPServlet</servlet-name>
        <url-pattern>/services/*</url-pattern>
    </servlet-mapping>

  <filter>
    <filter-name>OpenSessionInViewFilter</filter-name>

<filter-class>pl.mainseek.car.commons.CarPartsOpenSessionInViewFilter</filter-class>
  </filter>

  <filter-mapping>
    <filter-name>OpenSessionInViewFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>index.html</welcome-file>
      </welcome-file-list>
</web-app>


.. and this was working, but when i've changed servlet mapping to filter
mapping:

<?xml version="1.0"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="
http://www.w3.org/TR/xmlschema-1/"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/carpartswebsite-servlet.xml</param-value>
    </context-param>

    <listener>

<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <!--servlet>
        <servlet-name>carpartswebsite</servlet-name>

<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
      </servlet-->

    <filter>
        <filter-name>WicketFilter</filter-name>

<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
        <init-param>
            <param-name>applicationFactoryClassName</param-name>

<param-value>org.apache.wicket.spring.SpringWebApplicationFactory</param-value>
            <param-name>applicationBean</param-name>
            <param-value>wicketApplication</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>WicketFilter</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>ERROR</dispatcher>

        <error-page>
            <error-code>404</error-code>
            <location>/404</location>
        </error-page>
    </filter-mapping>

    <!--servlet>
        <servlet-name>wicket</servlet-name>

<servlet-class>org.apache.wicket.protocol.http.WicketServlet</servlet-class>
        <init-param>
            <param-name>applicationFactoryClassName</param-name>

<param-value>org.apache.wicket.spring.SpringWebApplicationFactory</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

      <servlet-mapping>
        <servlet-name>wicket</servlet-name>
        <url-pattern>/*</url-pattern>
      </servlet-mapping-->

      <servlet>
        <servlet-name>XFireSOAPServlet</servlet-name>

<servlet-class>org.codehaus.xfire.spring.XFireSpringServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>XFireSOAPServlet</servlet-name>
        <url-pattern>/services/*</url-pattern>
    </servlet-mapping>

  <filter>
    <filter-name>OpenSessionInViewFilter</filter-name>

<filter-class>pl.mainseek.car.commons.CarPartsOpenSessionInViewFilter</filter-class>
  </filter>

  <filter-mapping>
    <filter-name>OpenSessionInViewFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>index.html</welcome-file>
      </welcome-file-list>
</web-app>

.. it doesn't work. I get the org.hibernate.LazyInitializationException.

Please, help me !!! :)

Re: OpenSessionInView and LazyInitializationException

Posted by lars vonk <la...@gmail.com>.
To be more precise: the opensessioninview filter's filter-mapping element
needs to be declared before the wicket filter's filter-mapping element.

Lars

On Wed, May 7, 2008 at 2:35 PM, Wouter Huijnink <w....@func.nl> wrote:

> You need to declare the opensessioninviewfilter *before* the wicket filter
>
> --
> Wouter Huijnink
> Func. Internet Integration
> W http://www.func.nl
> T +31 20 4230000
> F +31 20 4223500
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: OpenSessionInView and LazyInitializationException

Posted by Wouter Huijnink <w....@func.nl>.
You need to declare the opensessioninviewfilter *before* the wicket filter

-- 
Wouter Huijnink
Func. Internet Integration
W http://www.func.nl
T +31 20 4230000
F +31 20 4223500


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org