users@jersey.java.net

Re: Help With Matrix Parameter Problem

From: Jakub Podlesak <Jakub.Podlesak_at_Sun.COM>
Date: Tue, 09 Oct 2007 18:51:04 +0200

Hi Hien,

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 am going to download Tomcat 5.5 and will give it a try.

>
> 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?

Sure. Btw. I have recently updated the method and it might work better now.
Anyway, i am going to test it and then will get back to you.

And thank you for pointing out the exact method which causes the issue. Great job!

>
> 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.

We were discussing it. IMHO we need some more logging to happen in Jersey. On the other hand it means
worse understandability of the code (more code to read) and also (given that Jersey is
an early access code, which keeps changing) a danger of obsolete log messages,
which in fact could make such a diagnostic really painfull.

~Jakub

 
>
> Thanks,
>
> Hien
>
>
> ----- Original Message ----
> From: Jakub Podlesak <Jakub.Podlesak_at_Sun.COM>
> To: Hien Luu <hluu_at_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_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_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_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>
>
>
>