users@jersey.java.net

Re: Help With Matrix Parameter Problem

From: Hien Luu <hluu_at_yahoo.com>
Date: Tue, 9 Oct 2007 14:49:33 -0700 (PDT)

Hi Martin, Jakub, Good news. Jersey 0.4 version doesn't have the problem that I reported. Thanks for your quick response. What's the estimated release date for Jersey 0.4? Now my prototype can move forward :) BTW are there any good tutorials on the binding of the returned object to JSON or XML? Thanks, Hien ----- Original Message ---- From: Martin Matula <Martin.Matula@Sun.COM> To: users@jersey.dev.java.net Cc: Hien Luu <hluu@yahoo.com> Sent: Tuesday, October 9, 2007 10:59:28 AM Subject: Re: Help With Matrix Parameter Problem Hi Hien, if you don't want to build Jersey yourself, you can download the latest nightly trunk build from here: https://jersey.dev.java.net/servlets/ProjectDocumentList?folderID=7653&expandFolder=7653&folderID=0 Martin Jakub Podlesak wrote: > Hi Hien, > > it should work with the trunk version as it works for me (please > see attached snapshot). (Tomcat 5.5.17) > > You should be able to checkout the source code from the following repo as guest: > svn checkout https://jersey.dev.java.net/svn/jersey/trunk jersey > > (then navigate to jersey/jersey subdir and run ant). > > I will be offline for the following 2-3h, but let me please know, if it works > for you. > > Thanks, > > ~Jakub > > On Tue, Oct 09, 2007 at 09:21:13AM -0700, Hien Luu wrote: > >> Hi Jakub, >> >> Thank you for email. I am using Jersey 0.3 build-id 09/21/07 and container is Tomcat 5.5.23. Can you try to your example on Tomcat 5.5? >> >> I spent sometime debugging last night and I was able to identify a suspicious section of code. Let me try to describe what I am seeing. >> >> The beginning of the ServletAdaptor.service() method converts the HttpServletRequest into HttpRequestAdaptor. The HttpRequestAdaptor.initiateUriInfo() method updates the instance variables baseUri and completeUri with the information from the original HttpServletRequest. >> >> Here is what I am seeing: >> >> Original URI: http://localhost:8080/jersey/users;fn=love >> >> path in absoluteUriBuilder variable: /jersey/users;fn=love >> >> decodedPath: users >> decodedBasePath: /jersey/ >> >> baseUri = http://localhost:8080/jersey/ >> completeUri = http://localhost:8080/jersey/users >> >> So at the end of the method HttpRequestAdaptor.initiateUriInfo(), the completeUri instance variable of HttpRequestAdaptor doesn't have the ";fn=love". That seems to be fishy to me. So I went and replaced the value of completeUri with "http://localhost:8080/jersey/users;fn=love" (while debugging) and I got the expected result. >> >> This leads me to conclude that the logic in method HttpRequestAdaptor.initiateUriInfo() is not quite right when the container is Tomcat 5.5. Can you please take a look? >> >> BTW, I don't see a lot logging going on in jersey code base. Is there any plan to do that in the future? It will make debugging easier. >> >> Thanks, >> >> Hien >> >> >> ----- Original Message ---- >> From: Jakub Podlesak <Jakub.Podlesak@Sun.COM> >> To: Hien Luu <hluu@yahoo.com> >> Sent: Tuesday, October 9, 2007 6:15:49 AM >> Subject: Re: Help With Matrix Parameter Problem >> >> >> Hi Hien, >> >> forgot to cc you... please see the attached message. >> >> ~Jakub >> >> On Mon, Oct 08, 2007 at 04:39:11PM -0700, Hien Luu wrote: >> >>> I am trying to use the MatrixParam annotation to grab the value out of a matrix parameter, but just doesn't work for me. I must be missing something. Here is my resource class: >>> >>> @UriTemplate("/users") >>> public class UsersResource { >>> public UsersResource() { >>> } >>> >>> @HttpMethod >>> public String getUsers(@MatrixParam("fn") String firstName) { >>> >>> return "first-name: '" + firstName + "'"; >>> } >>> } >>> >>> When I tried http://host:8080/jersey/users;fn=Mike and I am expecting "first-name: 'Mike'", but kept getting "first-name: 'null'". >>> >>> Thanks in advance, >>> >>> Hien >>> >> -----Inline Message Follows----- >> >> >> Hi Hien, >> >> if i try to modify the [HelloWorld] example (http container), it works for me: >> --cuthere-- >> // The Java class will be hosted at the URI path "/helloworld" >> @UriTemplate(value = "/helloworld") >> public class HelloWorldResource { >> >> // The Java method will process HTTP GET requests >> @HttpMethod("GET") >> // The Java method will produce content identified by the MIME Media >> // type "text/plain" >> @ProduceMime("text/plain") >> public String getUser(@MatrixParam("fn") String param) { >> // Return some cliched textual content >> return "param is " + param; >> } >> } >> --cuthere-- >> >> The same works fine with GlassFish ([HelloWorldWebApp] -- servlet container). >> >> I use latest jersey code from the main trunk. >> >> What version (and container) are you using? >> >> Please do not hesitate to file a bug report at [1] and attach your project files >> there as a reproducible test case. >> >> Thank you a lot! >> >> ~Jakub >> >> [1]https://jersey.dev.java.net/issues/ >> >> On Mon, Oct 08, 2007 at 04:39:11PM -0700, Hien Luu wrote: >> >>> I am trying to use the MatrixParam annotation to grab the value out of a matrix parameter, but just doesn't work for me. I must be missing something. Here is my resource class: >>> >>> @UriTemplate("/users") >>> public class UsersResource { >>> public UsersResource() { >>> } >>> >>> @HttpMethod >>> public String getUsers(@MatrixParam("fn") String firstName) { >>> >>> return "first-name: '" + firstName + "'"; >>> } >>> } >>> >>> When I tried http://host:8080/jersey/users;fn=Mike and I am expecting "first-name: 'Mike'", but kept getting "first-name: 'null'". >>> >>> Thanks in advance, >>> >>> Hien >>> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscribe@jersey.dev.java.net >> For additional commands, e-mail: users-help@jersey.dev.java.net >> >> >> >> >> -----Inline Attachment Follows----- >> >> >> Hi Hien, >> >> if i try to modify the [HelloWorld] example (http container), it works for me: >> --cuthere-- >> // The Java class will be hosted at the URI path "/helloworld" >> @UriTemplate(value = "/helloworld") >> public class HelloWorldResource { >> >> // The Java method will process HTTP GET requests >> @HttpMethod("GET") >> // The Java method will produce content identified by the MIME Media >> // type "text/plain" >> @ProduceMime("text/plain") >> public String getUser(@MatrixParam("fn") String param) { >> // Return some cliched textual content >> return "param is " + param; >> } >> } >> --cuthere-- >> >> The same works fine with GlassFish ([HelloWorldWebApp] -- servlet container). >> >> I use latest jersey code from the main trunk. >> >> What version (and container) are you using? >> >> Please do not hesitate to file a bug report at [1] and attach your project files >> there as a reproducible test case. >> >> Thank you a lot! >> >> ~Jakub >> >> [1]https://jersey.dev.java.net/issues/ >> >> On Mon, Oct 08, 2007 at 04:39:11PM -0700, Hien Luu wrote: >> >>> I am trying to use the MatrixParam annotation to grab the value out of a matrix parameter, but just doesn't work for me. I must be missing something. Here is my resource class: >>> >>> @UriTemplate("/users") >>> public class UsersResource { >>> public UsersResource() { >>> } >>> >>> @HttpMethod >>> public String getUsers(@MatrixParam("fn") String firstName) { >>> >>> return "first-name: '" + firstName + "'"; >>> } >>> } >>> >>> When I tried http://host:8080/jersey/users;fn=Mike and I am expecting "first-name: 'Mike'", but kept getting "first-name: 'null'". >>> >>> Thanks in advance, >>> >>> Hien >>> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscribe@jersey.dev.java.net >> For additional commands, e-mail: users-help@jersey.dev.java.net >> >> >> >> >> >> >> >> ------------------------------------------------------------------------ >> >> ------------------------------------------------------------------------ >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscribe@jersey.dev.java.net >> For additional commands, e-mail: users-help@jersey.dev.java.net >>