« Return to Thread: jruby-rack issues and doubts

Re: jruby-rack issues and doubts

by David Calavera :: Rate this Message:

Reply to Author | View in Thread

Thank you Nick,

it works fine with the RackServlet, I hadn't seen it.

But the behavior with the filter is actually annoying. I'm using two different versions of tomcat, 6.0.18 standalone and 6.0.20 embedded and the behavior is the same. These are my filter defs, the last one there is just to test the order:

   <filter>
    <filter-name>OpenSessionInView</filter-name>
    <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
    <init-param>
      <param-name>sessionFactoryBeanName</param-name>
      <param-value>sessionFactoryXmas</param-value>
    </init-param>
  </filter>

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

<filter>
    <filter-name>WebRackFilter</filter-name>
    <filter-class>org.jruby.rack.RackFilter</filter-class>
  </filter>

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

  <filter>
    <filter-name>HelloFilter</filter-name>
    <filter-class>com.miraiespana.filters.HelloFilter</filter-class>
  </filter>

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

On Wed, Jun 24, 2009 at 5:32 PM, Nick Sieger <nicksieger@...> wrote:
On Wed, Jun 24, 2009 at 8:28 AM, David Calavera <david.calavera@...> wrote:
Hi, I'm trying to configure a jruby on rails app on tomcat and jruby-rack and I found an issue that I don't understand.

The problem is that I have two more filters defined into my web.xml and I want that RackFilter will be executed the second one, so, the order I've declared them and their mappings in the file is this:

     - MyFilter1
     - RackFilter
     - MyFilter2

But, when I start tomcat, the order that it executes filters' chain is this:

    - RackFilter
    - MyFilter2
    - MyFilter1

No matters where I'll declare RackFilter and it's mapping but it's always executed first.

That's odd. Can you share how you define the filters in web.xml?
 


By the way, I've read this in the jruby-rack wiki:

   The application can also be configured to dispatch through a servlet instead of a filter if it suits your environment better.

But I can't find any example of how to do it so because the DefaultServletDispatcher needs a ServletRackContext to be initilized and I can't define it in the web.xml

Sure, there's a servlet org.jruby.rack.RackServlet, just go ahead and use it instead of RackFilter in web.xml like you would any servlet with <servlet> and <servlet-mapping> elements.

By the way, thanks for working on Tomcat-Rails -- looking forward to trying it out.

/Nick




--
David Calavera
http://www.thinkincode.net

 « Return to Thread: jruby-rack issues and doubts