users@jersey.java.net

Re: Help With Matrix Parameter Problem

From: Jakub Podlesak <Jakub.Podlesak_at_Sun.COM>
Date: Wed, 10 Oct 2007 00:16:41 +0200

Hi Hien,

I am glad it works for you!

On Tue, Oct 09, 2007 at 02:49:33PM -0700, Hien Luu wrote:
> 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?

It should be sometime around November 2nd.
>
> Now my prototype can move forward :)
>
> BTW are there any good tutorials on the binding of the returned object to JSON or XML?

You can look at blog entries at [1], [2], [3], [4].
Also studying [JsonFromJaxb] and [Bookmark] example in [jersey/exmaples] subdirectory
should help.

Please let me know if you have further questions.

Cheers,

~Jakub


[1]http://blogs.sun.com/japod/entry/json_representation_of_jaxb_object
[2]http://weblogs.java.net/blog/arungupta/archive/2007/10/totd_10_consumi.html
[3]http://blogs.sun.com/japod/entry/json_entity_providers_in_jersey
[4]http://weblogs.java.net/blog/arungupta/archive/2007/09/totd_8_generati.html

>
> Thanks,
>
> Hien
>
>
>
> ----- Original Message ----
> From: Martin Matula <Martin.Matula_at_Sun.COM>
> To: users_at_jersey.dev.java.net
> Cc: Hien Luu <hluu_at_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_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
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> ------------------------------------------------------------------------
> >>
> >> ------------------------------------------------------------------------
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> >> For additional commands, e-mail: users-help_at_jersey.dev.java.net
> >>
>
>
>
>