users@jersey.java.net

Re: [Jersey] How to activate the Jersey log?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 28 May 2009 14:22:06 -0700

Hi Fabio,

Perhaps you could try the following:

     @PUT
     @Consumes(MediaType.TEXT_XML)
     public SmartGWTResponse putAtividade(@Context HttpContext hc) {
         Object o =
hc.getRequest().getEntity(AtividadeSmartGWTRequest.class);
     }

and see what is returned.

I am wondering if the XmlRootElement on SmartGWTRequest is confusing
JAXB, or maybe the generic aspect of that class.

Paul.

On May 28, 2009, at 1:50 PM, Fabio Oliveira wrote:

> Hi Paul,
>
> thanks for your answer. The AtividadeSmartGWTRequest is one of my
> types, with JAXB annotations:
>
> @XmlRootElement(name="request")
> @XmlSeeAlso(AtividadeTO.class)
> public class AtividadeSmartGWTRequest extends
> SmartGWTRequest<AtividadeTO> {
>
> protected AtividadeSmartGWTRequest() {
> }
>
> public AtividadeSmartGWTRequest(AtividadeTO d) {
> super(d);
> }
>
> }
>
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlRootElement(name = "request")
> public abstract class SmartGWTRequest<T> {
>
> private Data<T> data;
>
> private String dataSource;
> private String operationType;
> private String operationId;
> private Integer startRow;
> private Integer endRow;
> private String sortBy;
> private String textMatchStyle;
> private String oldValues;
>
>
> public SmartGWTRequest(T d) {
> this.data = new Data(d);
> }
>
> protected SmartGWTRequest() {
> }
>
> public T getData() {
> return data.getData();
> }
>
> public String getDataSource() {
> return dataSource;
> }
>
> public Integer getEndRow() {
> return endRow;
> }
>
> public String getOldValues() {
> return oldValues;
> }
>
> public String getOperationId() {
> return operationId;
> }
>
> public String getOperationType() {
> return operationType;
> }
>
> public String getSortBy() {
> return sortBy;
> }
>
> public Integer getStartRow() {
> return startRow;
> }
>
> public String getTextMatchStyle() {
> return textMatchStyle;
> }
>
> @XmlAccessorType(XmlAccessType.FIELD)
> protected static class Data<T> {
> @XmlAnyElement(lax=true)
> private T data;
>
> protected Data() {
> }
>
> public Data(T data) {
> this.data = data;
> }
>
> public T getData() {
> return data;
> }
>
>
> }
> }
>
> @XmlRootElement(name = "record")
> public class AtividadeTO {
>
> private int id;
> private PapelTO papel;
> private Duration duracao;
> private long diametroBobina;
> private long larguraBobina;
> private long tubete;
> private String grupos;
> private int camadas;
> private DistribuicaoCamadas distribuicao;
> private int cortadeiraPrincipal;
> private int sequencia;
>
> protected AtividadeTO() {
> }
>
> public AtividadeTO(Atividade a) {
> this.id = a.getId();
> this.papel = new PapelTO(a.getPapel());
> this.duracao = a.getDuracao();
> this.diametroBobina =
> a.getGeometriaEntrada().getDiametro().longValue(SI.MILLIMETER);
> this.larguraBobina =
> a.getGeometriaEntrada().getLargura().longValue(SI.MILLIMETER);
> this.tubete =
> a.getGeometriaEntrada().getDiametroInterno().longValue(SI.MILLIMETER);
> this.grupos = format(a.getGrupos());
> this.camadas = a.getCamadas();
> this.distribuicao = a.getDistribuicao();
> this.cortadeiraPrincipal = a.getCortadeiraPrincipal().getId();
> this.sequencia = a.getSequencia();
> }
>
> // And a lot of getters and setters...
>
> }
>
> The message sent to server is:
>
> <request>
> <data>
> <record>
> <id>16757</id>
> <papel>
>
> <descricao>PASTA LINTER ALGODAO/F 1,50 MM 2300 MM</
> descricao>
> <id>1050</id>
> </papel>
> <duracao>00:00</duracao>
> <larguraBobina>766</larguraBobina>
>
> <diametroBobina>1000</diametroBobina>
> <tubete>76</tubete>
> <grupos>1: 700 x 1200&lt;br /&gt;2: 200 x 1100</grupos>
> <camadas>1</camadas>
>
> <distribuicao>20x1</distribuicao>
> <sequencia>0</sequencia>
> <cortadeiraPrincipal>2</cortadeiraPrincipal>
> </record>
> </data>
>
> <dataSource>filaAtividadeDS</dataSource>
> <operationType>update</operationType>
> <operationId></operationId>
> <startRow></startRow>
> <endRow></endRow>
>
> <sortBy></sortBy>
> <textMatchStyle></textMatchStyle>
> <oldValues></oldValues>
> </request>
>
>
> I don't know if it looks familiar for anyone, but I'm using the
> SmartGWT widget toolkit (http://www.smartclient.com/smartgwt) and
> trying to integrate with the Jersey, with a Restful architecture.
>
> I can't figure out where I'm missing the point, everything worked
> well until now, but I'm already working against this problem for 2
> days, without clues...
>
> Any help will be appreciated....
>
>
> On Thu, May 28, 2009 at 4:35 PM, Paul Sandoz <Paul.Sandoz_at_sun.com>
> wrote:
> Hi Fabio,
>
> Unfortunately there is no logging statements in the code. I want to
> enable a much more dynamic approach with the concept of a developer
> mode that adapts classes with logging information rather than
> "polluting" the runtime code with logging statements.
>
> What is AtividadeSmartGWTRequest? a JAXB object or your own type? if
> the latter i presume you have message body reader for that type, are
> you sure the reader is returning an instance compatible with that
> type?
>
> Paul.
>
> On May 28, 2009, at 11:06 AM, Fabio Oliveira wrote:
>
>> Hi list!
>>
>> Is there any way to log the Jersey activity? I'm having problems
>> while sending a msg and parsing using Jersey, and I'm receiving the
>> message:
>>
>> java.lang.IllegalArgumentException: argument type mismatch
>> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>
>> sun
>> .reflect
>> .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>
>> sun
>> .reflect
>> .DelegatingMethodAccessorImpl
>> .invoke(DelegatingMethodAccessorImpl.java:25)
>> java.lang.reflect.Method.invoke(Method.java:597)
>>
>> com
>> .sun
>> .jersey
>> .server
>> .impl.model.method.dispatch.AbstractResourceMethodDispatchProvider
>> $
>> TypeOutInvoker
>> ._dispatch(AbstractResourceMethodDispatchProvider.java:156)
>>
>> com
>> .sun
>> .jersey
>> .server
>> .impl
>> .model
>> .method
>> .dispatch
>> .ResourceJavaMethodDispatcher
>> .dispatch(ResourceJavaMethodDispatcher.java:67)
>>
>> com
>> .sun
>> .jersey
>> .server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:166)
>>
>> com
>> .sun
>> .jersey
>> .server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:108)
>>
>> com
>> .sun
>> .jersey
>> .server
>> .impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:114)
>>
>> com
>> .sun
>> .jersey
>> .server
>> .impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:74)
>>
>> com
>> .sun
>> .jersey
>> .server
>> .impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:114)
>>
>> com
>> .sun
>> .jersey
>> .server
>> .impl
>> .uri
>> .rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:
>> 66)
>>
>> com
>> .sun
>> .jersey
>> .server
>> .impl
>> .application
>> .WebApplicationImpl._handleRequest(WebApplicationImpl.java:658)
>>
>> com
>> .sun
>> .jersey
>> .server
>> .impl
>> .application
>> .WebApplicationImpl.handleRequest(WebApplicationImpl.java:616)
>>
>> com
>> .sun
>> .jersey
>> .server
>> .impl
>> .application
>> .WebApplicationImpl.handleRequest(WebApplicationImpl.java:607)
>>
>> com
>> .sun
>> .jersey
>> .spi.container.servlet.WebComponent.service(WebComponent.java:309)
>>
>> com
>> .sun
>> .jersey
>> .spi
>> .container.servlet.ServletContainer.service(ServletContainer.java:
>> 425)
>>
>> com
>> .sun
>> .jersey
>> .spi
>> .container.servlet.ServletContainer.service(ServletContainer.java:
>> 590)
>> javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>
>> org
>> .springframework
>> .orm
>> .jpa
>> .support
>> .OpenEntityManagerInViewFilter
>> .doFilterInternal(OpenEntityManagerInViewFilter.java:112)
>>
>> org
>> .springframework
>> .web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:
>> 76)
>>
>> javawebparts
>> .filter.CompressionFilter.doFilter(CompressionFilter.java:309)
>>
>> My method signature:
>>
>> @PUT
>> @Consumes(MediaType.TEXT_XML)
>> public SmartGWTResponse putAtividade(AtividadeSmartGWTRequest
>> request) {
>> ...
>> }
>>
>>
>> Thanks!
>>
>> --
>>
>> Fábio Braga de Oliveira
>> ArchitecTeam Consulting
>> http://www.linkedin.com/in/fabiobragaoliveira
>> E-mail: fabio.braga_at_gmail.com
>> Mobile: +55 19 9270-6574
>>
>
>
>
>
> --
>
> Fábio Braga de Oliveira
> ArchitecTeam Consulting
> http://www.linkedin.com/in/fabiobragaoliveira
> E-mail: fabio.braga_at_gmail.com
> Mobile: +55 19 9270-6574
>