Guys, thanks for your help.  I finally figured it out.  I had my filters set
up all wrong, as Larry pointed out.  My previous web.xml, which worked in
2.0 was this:

<!-- Filters -->
    <filter>
        <filter-name>WicketSessionFilter</filter-name>
        <filter-class>
            wicket.protocol.http.servlet.WicketSessionFilter
        </filter-class>
        <init-param>
            <param-name>servletPath</param-name>
            <param-value>app</param-value>
        </init-param>
    </filter>

    <filter>
        <filter-name>openSessionInViewFilter</filter-name>
        <filter-class>

org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
        </filter-class>
    </filter>

    <!-- Filter Mappings -->
    <filter-mapping>
        <filter-name>WicketSessionFilter</filter-name>
        <url-pattern>/app/*</url-pattern>
    </filter-mapping>

    <filter-mapping>
        <filter-name>WicketSessionFilter</filter-name>
        <url-pattern>/report</url-pattern>
    </filter-mapping>

    <filter-mapping>
        <filter-name>openSessionInViewFilter</filter-name>
        <url-pattern>/app/*</url-pattern>
    </filter-mapping>

    <filter-mapping>
        <filter-name>openSessionInViewFilter</filter-name>
        <url-pattern>/report</url-pattern>
    </filter-mapping>

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

    <!--
    Servlet to serve up JasperReports.
    -->
    <servlet>
        <servlet-name>JasperReportServlet</servlet-name>
        <servlet-class>
            com.alliancemanaged.simis.web.jasperreport.JasperReportServlet
        </servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <!--
    Servlet to serve images for JasperReport HTML output.
    -->
    <servlet>
        <servlet-name>JasperImageServlet</servlet-name>
        <servlet-class>
            com.alliancemanaged.simis.web.jasperreport.JasperImageServlet
        </servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
        <servlet-name>WicketServlet</servlet-name>
        <servlet-class>wicket.protocol.http.WicketServlet</servlet-class>
        <init-param>
            <param-name>applicationClassName</param-name>
            <param-value>
                com.alliancemanaged.simis.web.SIMISApplication
            </param-value>
        </init-param>
        <init-param>
            <param-name>configuration</param-name>
            <param-value>development</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <!-- URL Mappings -->
    <servlet-mapping>
        <servlet-name>JasperReportServlet</servlet-name>
        <url-pattern>/report</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>JasperImageServlet</servlet-name>
        <url-pattern>/reportimage</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>WicketServlet</servlet-name>
        <url-pattern>/app/*</url-pattern>
    </servlet-mapping>

Notice I was previously using a servlet configuration, rather than a
filter.  When I migrated to 1.4, I converted to a filter.  That's where my
problem started, I guess.  I didn't read the doc carefully enough, I
suppose.

I now have the following, which works great:

    <filter>
        <filter-name>openSessionInViewFilter</filter-name>
        <filter-class>

org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
        </filter-class>
    </filter>
    <filter>
        <filter-name>ReportingApplication</filter-name>

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

<param-value>com.alliancemanaged.simis.web.SIMISApplication</param-value>
        </init-param>
    </filter>
    <filter>
        <filter-name>WicketSessionFilter</filter-name>

<filter-class>org.apache.wicket.protocol.http.servlet.WicketSessionFilter</filter-class>
        <init-param>
            <param-name>filterName</param-name>
            <param-value>ReportingApplication</param-value>
        </init-param>
    </filter>

    <!-- Filter Mappings -->
    <filter-mapping>
        <filter-name>openSessionInViewFilter</filter-name>
        <url-pattern>/app/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>openSessionInViewFilter</filter-name>
        <url-pattern>/report</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>ReportingApplication</filter-name>
        <url-pattern>/app/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
    </filter-mapping>
    <filter-mapping>
        <filter-name>WicketSessionFilter</filter-name>
        <url-pattern>/report/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
    </filter-mapping>

Thanks again for all the help.

Regards,
Matthew.

On Tue, Jun 3, 2008 at 7:05 PM, Zappaterrini, Larry <
[EMAIL PROTECTED]> wrote:

> The way the your web.xml is configured does not have the requests going to
> JasperReportServlet getting filtered by WicketSessionFilter. Change the
> filter mapping for WicketSessionFilter from /app/* to /report/* or /* and
> you should see it work the way you want.
>
> ________________________________
>
> From: Matthew Hanlon [mailto:[EMAIL PROTECTED]
> Sent: Tue 6/3/2008 6:18 PM
> To: [email protected]
> Subject: Re: Wicket Session and non-Wicket Servlet
>
>
>
> >
> > Check out the api for WicketSessionFilter, it will tell you how to make
> the
> > session available for non wicket servlets.
> >
> >
> >
> http://wicket.apache.org/docs/wicket-1.3.2/wicket/apidocs/org/apache/wicket/protocol/http/servlet/WicketSessionFilter.html
> >
>
>
> Yeah, that's how I had my filter and servlet configured originally.  But
> the
> problem was that the request never seemed to be making it to the servlet,
> instead the WicketFilter would pick it up and handle it.  Perhaps that is
> another flaw.  So I dropped the mapping of the WicketFilter to the servlet,
> and then, of course, I got my IllegalStateException.
>
> Here's my current setup in web.xml:
>
> <filter>
>  <filter-name>openSessionInViewFilter</filter-name>
>   <filter-class>
>      org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
>   </filter-class>
> </filter>
> <filter>
>  <filter-name>WicketSessionFilter</filter-name>
>  <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
>  <init-param>
>    <param-name>applicationClassName</param-name>
>
> <param-value>com.alliancemanaged.simis.web.SIMISApplication</param-value>
>  </init-param>
>  <init-param>
>    <param-name>filterName</param-name>
>    <param-value>ReportingApplication</param-value>
>  </init-param>
> </filter>
> <!-- Filter Mappings -->
> <filter-mapping>
>  <filter-name>openSessionInViewFilter</filter-name>
>  <url-pattern>/app/*</url-pattern>
> </filter-mapping>
> <filter-mapping>
>  <filter-name>openSessionInViewFilter</filter-name>
>  <url-pattern>/report</url-pattern>
> </filter-mapping>
> <filter-mapping>
>  <filter-name>WicketSessionFilter</filter-name>
>  <url-pattern>/app/*</url-pattern>
> </filter-mapping>
> <!-- Servlet to serve up JasperReports -->
> <servlet>
>  <servlet-name>JasperReportServlet</servlet-name>
>
>
> <servlet-class>com.alliancemanaged.simis.web.jasperreport.JasperReportServlet</servlet-class>
>    <load-on-startup>1</load-on-startup>
>  </servlet>
> <!-- Servlet to serve images for JasperReport HTML output -->
> <servlet>
>  <servlet-name>JasperImageServlet</servlet-name>
>
>
> <servlet-class>com.alliancemanaged.simis.web.jasperreport.JasperImageServlet</servlet-class>
>  <load-on-startup>1</load-on-startup>
> </servlet>
> <!-- Servlet Mappings -->
> <servlet-mapping>
>  <servlet-name>JasperReportServlet</servlet-name>
>  <url-pattern>/report/*</url-pattern>
> </servlet-mapping>
> <servlet-mapping>
>  <servlet-name>JasperImageServlet</servlet-name>
>  <url-pattern>/reportimage/*</url-pattern>
> </servlet-mapping>
>
> I think I got it to work correctly via the method Martijn suggested.
>  That's
> what I had been trying to do, just couldn't figure it out.  If i understand
> you correct, Martijn, this is what I'm doing:
>
> MySession session = null;
> for(Iterator<String> iter = Application.getApplicationKeys().iterator();
> iter.hasNext();) {
> String key = iter.next();
> Object sess = servletRequest.getSession().getAttribute("wicket:" + key +
> ":session");
> if (sess != null && sess instanceof MySession) {
> session = (MySession)sess;
> break;
> }
> }
>
> I'm not sure if that's the best or most robust way, but it seems to get the
> job done.  If there's a better solution, please tell!
>
> Regards,
> Matthew.
>
>
>
> >
> > On Tue, Jun 3, 2008 at 4:30 PM, Martijn Dashorst <
> > [EMAIL PROTECTED]>
> > wrote:
> >
> > > You can't access the Wicket Session from outside a Wicket request
> > > using Session.get(). It is a thread local that is maintained by the
> > > request cycle. If it was possible in 2.0, then that was a bug and most
> > > certainly a security risk.
> > >
> > > You should try to look up the Wicket session in the HttpSession of
> > > your servlet using the session id and wicket key.
> > >
> > > Or just store the report in the http session instead.
> > >
> > > Martijn
> > >
> > > On Tue, Jun 3, 2008 at 10:21 PM, Matthew R Hanlon <[EMAIL PROTECTED]>
> > > wrote:
> > > > Okay, I may have this all wrong, and then that's my problem.  I have
> an
> > > > application that was developed under the 2.0 branch that I recently
> > > migrated
> > > > to 1.4.  This application uses a servlet to handle requests for
> Jasper
> > > > Reports, and under 2.0 everything worked great.  I store the report
> > > request
> > > > in the user's Session, and retrieve it in the JasperReportServlet to
> > look
> > > up
> > > > the request.  In my JasperReportServlet I was doing:
> > > >
> > > >
> > > >
> > > > public final void doGet(final HttpServletRequest servletRequest,
> final
> > > > HttpServletResponse servletResponse) throws ServletException,
> > IOException
> > > >
> > > > {
> > > >
> > > >      String requestId =
> > > >
> > >
> >
> servletRequest.getParameter(ReportingConstants.PARAMETER_NAME_REPORT_REQUEST
> > > > );
> > > >
> > > >      ReportRequest reportReq = null;
> > > >
> > > >      MySession session = (MySession)Session.get();
> > > >
> > > >      reportReq = session.getReportRequest(requestId);
> > > >
> > > >
> > > >
> > > >      // handle report request, etc.
> > > >
> > > > }
> > > >
> > > >
> > > >
> > > > However, in 1.4 when I do Session.get() from my JasperReportServlet I
> > am
> > > > getting the error java.lang.IllegalStateException: you can only
> locate
> > or
> > > > create sessions in the context of a request cycle.
> > > >
> > > >
> > > >
> > > > So, can I no longer get an object from my wicket Session from a
> > > non-wicket
> > > > Servlet?  I've been looking all over, and can't seem to find the
> right
> > > > answer.  Thanks for any help.
> > > >
> > > >
> > > >
> > > > Regards,
> > > >
> > > > Matthew.
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Become a Wicket expert, learn from the best: http://wicketinaction.com<
> http://wicketinaction.com/>
> > > Apache Wicket 1.3.3 is released
> > > Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.3
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> >
> >
> > --
> > Ryan Gravener
> > http://twitter.com/ryangravener
> >
>
>
>
> --
> Matthew Rollins Hanlon
> http://squareoftwo.org <http://squareoftwo.org/>
> ________________________________________
> Hanlon's Razor:
> "Never attribute to malice that which can be adequately explained by
> stupidity."
> http://wikipedia.org/wiki/Hanlon's_razor<http://wikipedia.org/wiki/Hanlon%27s_razor>
>
>
> ______________
>
> The information contained in this message is proprietary and/or
> confidential. If you are not the
> intended recipient, please: (i) delete the message and all copies; (ii) do
> not disclose,
> distribute or use the message in any manner; and (iii) notify the sender
> immediately. In addition,
> please be aware that any message addressed to our domain is subject to
> archiving and review by
> persons other than the intended recipient. Thank you.
> _____________
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>



-- 
Matthew Rollins Hanlon
http://squareoftwo.org
________________________________________
Hanlon's Razor:
"Never attribute to malice that which can be adequately explained by
stupidity."
http://wikipedia.org/wiki/Hanlon's_razor

Reply via email to