users@jersey.java.net

Re: [Lift] Re: [Jersey] jersey as filter

From: Meredith Gregory <lgreg.meredith_at_gmail.com>
Date: Mon, 9 Mar 2009 07:30:18 -0800

Paul,

Many thanks for your note. i've been endeavoring to run Jersey and Lift in a
filter chain. i was not seeing the requests passed on into Lift. Your
explanation fits. What i really need is

httpreq --> jersey --> lift --> jersey --> httpresp

i can just hack this up myself, or i can log an issue (or both).

Best wishes,

--greg

On Mon, Mar 9, 2009 at 1:39 AM, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:

> Hi Greg,
> I hope you have resolved things. I have been away on holiday, hence
> my silence.
>
> For Jersey 1.0.2 the Jersey filter support requires that the filter
> be configured at the end of the filter chain, see:
>
>
> https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/jersey-1.0.2/api/jersey/com/sun/jersey/spi/container/servlet/ServletContainer.html
>
> This is somewhat limited because we added this feature very close to the
> Jersey release.
>
> For Jersey 1.0.3-SNAPSHOT one can declare a regex that if matched defers to
> the next filter in the chain. See the Bookstore sample for more details on
> such a configuration:
>
>
> http://download.java.net/maven/2/com/sun/jersey/samples/bookstore/1.0.3-SNAPSHOT/bookstore-1.0.3-SNAPSHOT-project.zip
>
> We do not currently support a filter that passes things through to the next
> filter in the chain if Jersey does not match the URI. If you require this
> functionality please log an issue.
>
> Hope that helps,
> Paul.
>
> On Mar 3, 2009, at 3:32 AM, Meredith Gregory wrote:
>
> Lifted,
>
> Well, at least i've got jetty launching and running with both filters. See
> the web.xml that worked below.
>
> Best wishes,
>
> --greg
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <!DOCTYPE web-app
> PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> "http://java.sun.com/dtd/web-app_2_3.dtd">
>
> <web-app>
> <filter>
> <filter-name>JerseyFilter</filter-name>
> <display-name>Jersey Filter</display-name>
> <description>Attempting to use Jersey as a Filter</description>
>
> <filter-class>com.sun.jersey.spi.container.servlet.ServletContainer</filter-class>
> <init-param>
> <param-name>com.sun.jersey.config.property.packages</param-name>
> <param-value>com.sap.dspace.model.constellation.resources</param-value>
> </init-param>
> </filter>
> <filter>
> <filter-name>LiftFilter</filter-name>
> <display-name>Lift Filter</display-name>
> <description>The Filter that intercepts lift calls</description>
> <filter-class>net.liftweb.http.LiftFilter</filter-class>
> </filter>
>
> <filter-mapping>
> <filter-name>JerseyFilter</filter-name>
> <url-pattern>/*</url-pattern>
> </filter-mapping>
> <filter-mapping>
> <filter-name>LiftFilter</filter-name>
> <url-pattern>/*</url-pattern>
> </filter-mapping>
>
> </web-app>
>
>
> On Mon, Mar 2, 2009 at 6:25 PM, Meredith Gregory <lgreg.meredith_at_gmail.com
> > wrote:
>
>> Alex,
>>
>> Thanks for all your help. i switched versions in the pom.xml (to 1.0.2
>> which is the most recent on the sun repo that is not labeled SNAPSHOT) and i
>> get the right values from reflecting (BTW -- has anybody written a little
>> lift browser app that hooks into reflection so that one can graphically
>> browse the class/instances in memory?). Now i just need to figure out how to
>> pass the resources context to Jersey. It's got a config for the
>> ServletContainer class, but i don't see anything if i'm just using it as a
>> filter.
>>
>> Best wishes,
>>
>> --greg
>>
>> On Mon, Mar 2, 2009 at 6:13 PM, Alex Boisvert <boisvert_at_intalio.com>wrote:
>>
>>> No, sorry, I've grown allergic to mvn.
>>>
>>> If you must know, I wrote a 5-line ruby script that bootstraps the scala
>>> interpreter with a given classpath.
>>>
>>> #!/usr/bin/env scalarun
>>> classpath << artifact("com.sun.jersey:jersey-server:jar:1.02")
>>> classpath << artifact("javax.servlet:servlet-api:jar:2.5")
>>> classpath << artifact("javax.ws.rs:jsr311-api:jar:1.0")
>>> interactive = true
>>> !#
>>>
>>> So we're down to two main possibilities... 1) something is wrong with
>>> your Maven pom.xml or 2) your local artifacts are inconsistent with what's
>>> in the repos.
>>>
>>> alex
>>>
>>>
>>>
>>> On Mon, Mar 2, 2009 at 6:05 PM, Meredith Gregory <
>>> lgreg.meredith_at_gmail.com> wrote:
>>>
>>>> Alex,
>>>>
>>>> Interesting. Did you build with mvn? If so, what were your
>>>> plugins/dependencies?
>>>>
>>>> Best wishes,
>>>>
>>>> --greg
>>>>
>>>>
>>>> On Mon, Mar 2, 2009 at 6:01 PM, Alex Boisvert <boisvert_at_intalio.com>wrote:
>>>>
>>>>> Greg,
>>>>>
>>>>> Something must be messed up in your configuration.... Here's what I
>>>>> get:
>>>>>
>>>>> Welcome to Scala version 2.7.3.final (Java HotSpot(TM) Server VM, Java
>>>>> 1.6.0_10).
>>>>> Type in expressions to have them evaluated.
>>>>> Type :help for more information.
>>>>>
>>>>> scala> new com.sun.jersey.spi.container.servlet.ServletContainer()
>>>>> res0: com.sun.jersey.spi.container.servlet.ServletContainer =
>>>>> com.sun.jersey.spi.container.servlet.ServletContainer_at_15cd9a
>>>>>
>>>>> scala> res0.getClass.getInterfaces
>>>>> res2: Array[java.lang.Class[_]] = Array(interface
>>>>> javax.servlet.Servlet, interface javax.servlet.ServletConfig, interface
>>>>> javax.servlet.Filter, interface java.io.Serializable)
>>>>>
>>>>> (I'm using jersey-server-1.0.2.jar)
>>>>>
>>>>> alex
>>>>>
>>>>>
>>>>> On Mon, Mar 2, 2009 at 5:47 PM, Meredith Gregory <
>>>>> lgreg.meredith_at_gmail.com> wrote:
>>>>>
>>>>>> Alex,
>>>>>>
>>>>>> i was coming to the same conclusion. OTOH, reflecting on
>>>>>> com.sun.jersey.spi.container.servlet.ServletContainer i see different stuff
>>>>>> than what's declared in the sources. See below.
>>>>>>
>>>>>> Best wishes,
>>>>>>
>>>>>> --greg
>>>>>>
>>>>>> scala> new com.sun.jersey.spi.container.servlet.ServletContainer()
>>>>>> new com.sun.jersey.spi.container.servlet.ServletContainer()
>>>>>> new com.sun.jersey.spi.container.servlet.ServletContainer()
>>>>>> res0: com.sun.jersey.spi.container.servlet.ServletContainer =
>>>>>> com.sun.jersey.spi.container.servlet.ServletContainer_at_50b410
>>>>>>
>>>>>> scala> res0.getClass
>>>>>> res0.getClass
>>>>>> res0.getClass
>>>>>> res1: java.lang.Class[_ <: java.lang.Object] = class
>>>>>> com.sun.jersey.spi.container.servlet.ServletContainer
>>>>>>
>>>>>> scala> res0.getClass.getSuperclass
>>>>>> res0.getClass.getSuperclass
>>>>>> res0.getClass.getSuperclass
>>>>>> res7: java.lang.Class[_ >: ?0] = class javax.servlet.http.HttpServlet
>>>>>>
>>>>>> // i was expecting to see WebComponent here
>>>>>>
>>>>>> scala> res0.getClass.getInterfaces
>>>>>> res0.getClass.getInterfaces
>>>>>> res0.getClass.getInterfaces
>>>>>> res8: Array[java.lang.Class[_]] = Array(interface
>>>>>> com.sun.jersey.spi.container.ContainerListener)
>>>>>>
>>>>>> // i was expecting to see Servlet, ServletConfig, Filter, Serializable
>>>>>> in this list.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Mon, Mar 2, 2009 at 5:13 PM, Alex Boisvert <boisvert_at_intalio.com>wrote:
>>>>>>
>>>>>>> My guess would be that you have duplicate servlet-api-2.x.jar in your
>>>>>>> classloading hierarchy... can you check and remove any servlet.jar under
>>>>>>> your webapp WEB-INF/lib directory?
>>>>>>>
>>>>>>> alex
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Mon, Mar 2, 2009 at 4:45 PM, Meredith Gregory <
>>>>>>> lgreg.meredith_at_gmail.com> wrote:
>>>>>>>
>>>>>>>> Alex,
>>>>>>>>
>>>>>>>> Thanks for the interest. See below.
>>>>>>>>
>>>>>>>> Best wishes,
>>>>>>>>
>>>>>>>> --greg
>>>>>>>>
>>>>>>>> <?xml version="1.0" encoding="ISO-8859-1"?>
>>>>>>>>
>>>>>>>> <!DOCTYPE web-app
>>>>>>>> PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
>>>>>>>> "http://java.sun.com/dtd/web-app_2_3.dtd">
>>>>>>>>
>>>>>>>> <web-app>
>>>>>>>> <filter>
>>>>>>>> <filter-name>JerseyFilter</filter-name>
>>>>>>>> <display-name>Jersey Filter</display-name>
>>>>>>>> <description>Attempting to use Jersey as a Filter</description>
>>>>>>>>
>>>>>>>> <filter-class>com.sun.jersey.spi.container.servlet.ServletContainer</filter-class>
>>>>>>>> </filter>
>>>>>>>> <filter>
>>>>>>>> <filter-name>LiftFilter</filter-name>
>>>>>>>> <display-name>Lift Filter</display-name>
>>>>>>>> <description>The Filter that intercepts lift calls</description>
>>>>>>>> <filter-class>net.liftweb.http.LiftFilter</filter-class>
>>>>>>>> </filter>
>>>>>>>>
>>>>>>>> <filter-mapping>
>>>>>>>> <filter-name>JerseyFilter</filter-name>
>>>>>>>> <url-pattern>/*</url-pattern>
>>>>>>>> </filter-mapping>
>>>>>>>> <filter-mapping>
>>>>>>>> <filter-name>LiftFilter</filter-name>
>>>>>>>> <url-pattern>/*</url-pattern>
>>>>>>>> </filter-mapping>
>>>>>>>>
>>>>>>>> </web-app>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Mon, Mar 2, 2009 at 4:43 PM, Alex Boisvert <boisvert_at_intalio.com
>>>>>>>> > wrote:
>>>>>>>>
>>>>>>>>> Can you post your web.xml?
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Mon, Mar 2, 2009 at 3:50 PM, Meredith Gregory <
>>>>>>>>> lgreg.meredith_at_gmail.com> wrote:
>>>>>>>>>
>>>>>>>>>> Marc,
>>>>>>>>>>
>>>>>>>>>> Thanks for the link! BTW, i'm looking at that sources from the
>>>>>>>>>> Jersey jar and it appears that
>>>>>>>>>> com.sun.jersey.spi.container.servlet.ServletContainer implements Filter. And
>>>>>>>>>> yet, when i launch with jetty i get:
>>>>>>>>>>
>>>>>>>>>> 2009-03-02 15:46:18.043::WARN: failed JerseyFilter
>>>>>>>>>> java.lang.IllegalStateException: class
>>>>>>>>>> com.sun.jersey.spi.container.servlet.ServletContainer is not a
>>>>>>>>>> javax.servlet.Filter
>>>>>>>>>> at
>>>>>>>>>> org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:88)
>>>>>>>>>>
>>>>>>>>>> Best wishes,
>>>>>>>>>>
>>>>>>>>>> --greg
>>>>>>>>>>
>>>>>>>>>> On Mon, Mar 2, 2009 at 2:16 PM, Marc Hadley <Marc.Hadley_at_sun.com>wrote:
>>>>>>>>>>
>>>>>>>>>>> Apache Camel uses Jersey as a filter:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> https://svn.apache.org/repos/asf/camel/trunk/components/camel-web/src/main/webapp/WEB-INF/web.xml
>>>>>>>>>>>
>>>>>>>>>>> Marc.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Mar 2, 2009, at 4:46 PM, Meredith Gregory wrote:
>>>>>>>>>>>
>>>>>>>>>>> Jerseyans,
>>>>>>>>>>>>
>>>>>>>>>>>> Does anyone have any experience with using Jersey as a filter?
>>>>>>>>>>>> i'd like to take advantage of some of Jersey's Request/Response rendering as
>>>>>>>>>>>> well as some of Lift's cool stuff. The Lift servlet is a filter and deployed
>>>>>>>>>>>> as such. i note that the
>>>>>>>>>>>> com/sun/jersey/spi/container/servlet/ServletContainer implements Filter.
>>>>>>>>>>>> However, i have yet to find an example of Jersey deployed in a filter
>>>>>>>>>>>> capacity. If anyone has used Jersey this way, please let me know.
>>>>>>>>>>>>
>>>>>>>>>>>> Best wishes,
>>>>>>>>>>>>
>>>>>>>>>>>> --greg
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>> L.G. Meredith
>>>>>>>>>>>> Managing Partner
>>>>>>>>>>>> Biosimilarity LLC
>>>>>>>>>>>> 806 55th St NE
>>>>>>>>>>>> Seattle, WA 98105
>>>>>>>>>>>>
>>>>>>>>>>>> +1 206.650.3740
>>>>>>>>>>>>
>>>>>>>>>>>> http://biosimilarity.blogspot.com
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>>>>>>>>>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> L.G. Meredith
>>>>>>>>>> Managing Partner
>>>>>>>>>> Biosimilarity LLC
>>>>>>>>>> 806 55th St NE
>>>>>>>>>> Seattle, WA 98105
>>>>>>>>>>
>>>>>>>>>> +1 206.650.3740
>>>>>>>>>>
>>>>>>>>>> http://biosimilarity.blogspot.com
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> L.G. Meredith
>>>>>>>> Managing Partner
>>>>>>>> Biosimilarity LLC
>>>>>>>> 806 55th St NE
>>>>>>>> Seattle, WA 98105
>>>>>>>>
>>>>>>>> +1 206.650.3740
>>>>>>>>
>>>>>>>> http://biosimilarity.blogspot.com
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> L.G. Meredith
>>>>>> Managing Partner
>>>>>> Biosimilarity LLC
>>>>>> 806 55th St NE
>>>>>> Seattle, WA 98105
>>>>>>
>>>>>> +1 206.650.3740
>>>>>>
>>>>>> http://biosimilarity.blogspot.com
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> L.G. Meredith
>>>> Managing Partner
>>>> Biosimilarity LLC
>>>> 806 55th St NE
>>>> Seattle, WA 98105
>>>>
>>>> +1 206.650.3740
>>>>
>>>> http://biosimilarity.blogspot.com
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>> --
>> L.G. Meredith
>> Managing Partner
>> Biosimilarity LLC
>> 806 55th St NE
>> Seattle, WA 98105
>>
>> +1 206.650.3740
>>
>> http://biosimilarity.blogspot.com
>>
>
>
>
> --
> L.G. Meredith
> Managing Partner
> Biosimilarity LLC
> 806 55th St NE
> Seattle, WA 98105
>
> +1 206.650.3740
>
> http://biosimilarity.blogspot.com
>
>
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To post to this group, send email to liftweb_at_googlegroups.com
> To unsubscribe from this group, send email to
> liftweb+unsubscribe_at_googlegroups.com<liftweb%2Bunsubscribe_at_googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/liftweb?hl=en
> -~----------~----~----~----~------~----~------~--~---
>
>


-- 
L.G. Meredith
Managing Partner
Biosimilarity LLC
806 55th St NE
Seattle, WA 98105
+1 206.650.3740
http://biosimilarity.blogspot.com