users@jersey.java.net

[Jersey] Re: How to get more error/logging/debug info

From: Pavel Bucek <pavel.bucek_at_oracle.com>
Date: Mon, 04 Jun 2012 09:15:41 +0200

Hello Daniel,

you can use ContainerRequest/ResponseLogging filters [1] or tracing
support [2] which would produce more info about matching process.

However, it might not be exactly what you need; your problem is clearly
with requests entity and there is no suggestion I can make with given
details. You can try create JAXBElement<MyBean> yourself someplace else,
return it and compare to what you are sending to mentioned resource method.

We also have lots of examples in our codebase, so if you want, you can
look there (I'm sure there is something almost identical to described
usecase) [3]. And our user guide [4] should be helpful as well.

Hope it helps (feel free to ask again with more details, like MyBean
sources and incoming http request dump)..
Pavel

[1]
http://jersey.java.net/nonav/apidocs/1.12/jersey/com/sun/jersey/api/container/filter/LoggingFilter.html
[2]
http://jersey.java.net/nonav/apidocs/1.12/jersey/com/sun/jersey/api/core/ResourceConfig.html#FEATURE_TRACE
[3] http://search.maven.org/#search|ga|1|com.sun.jersey.samples
[4] http://jersey.java.net/nonav/documentation/latest/index.html

On 6/4/12 7:11 AM, daniel.cklam_at_gmail.com wrote:
> Hi there,
>
> Please help! I'm new to using GlassFish/Jersey.. had more experience
> with PHP.
>
> I have a method like the following to handle web service request:
>
> @POST
> public Response createNewRecord(JAXBElement<MyBean> beanJaxb) {
>
> MyBean newBean = beanJaxb.getValue();
> em.persist(newBean);
>
> // According to REST-ful convention, the URI of the new entry
> will be returned.
> URI beanUri= uriInfo.getAbsolutePathBuilder().path(newBean
> .getId().toString()).build();
>
> return Response.created(beanUri).build();
> }
>
> All's well. However, let's say the service request sender made a
> mistake when writing the request body, e.g. some incorrect parameter
> type, then the request will fail.
>
> My question is, when the request fails, currently it would only give me
> generic messages like,
>
> [#|2012-06-04T14:14:30.059+1000|WARNING|glassfish3.1.2|javax.enterprise
> .system.container.web.com.sun.enterprise.web|_ThreadID=25;_ThreadName=T
> hread-2;|StandardWrapperValve[com.rockableapps.lamophone.ApplicationCon
> fig]: PWC1406: Servlet.service() for servlet
> com.rockableapps.lamophone.ApplicationConfig threw exception
> java.lang.Error: Error: could not match input
> at
> com.sun.jersey.json.impl.reader.JsonLexer.zzScanError(JsonLexer.java:49
> 1)
> at com.sun.jersey.json.impl.reader.JsonLexer.yylex(JsonLexer.java:751)
> at
> com.sun.jersey.json.impl.reader.JsonXmlStreamReader.nextToken(JsonXmlSt
> reamReader.java:160)
> at
> com.sun.jersey.json.impl.reader.JsonXmlStreamReader.readNext(JsonXmlStr
> eamReader.java:187)
> at ...
>
> ...which doesn't give me a clue where to start looking to fix the
> error (e.g. the field/param that caused this). Is there a way to change
> the error/logging/debug settings so that I would get that info?
>
> Tried searching the net for 1/2 hour and ended no where as well.
>
> We're just starting to prototype and want to use GlassFish/Jersery for
> our dev/prod environment, however if it's giving us too much pain we'll
> have to switch..
>
>