using RESTlet, XStream annotations seem to have no effect

Using @XStreamOmitField in my POJO seems to have no effect whatsoever. the annotated field still gets exposed in the xml or json representation.

@XStreamAlias("Pojo") @Entity public class Pojo { private String name; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long key; @XStreamOmitField private String hidden; public Pojo(String name, String hidden) { = name; this.hidden = hidden; } }

and in the ServerResource

@Get public Pojo test() { Pojo pj= new Pojo("hansi","hinter"); return pj; }

gets me

<com.myComp.ORMTest.Pojo> <name>hansi</name> <hidden>hinter</hidden> </com.myComp.ORMTest.Pojo>

Any ideas why the annotations are ignored?

-------------Problems Reply------------

You have to tell XStream to explicitly process annotations:

XStream xstream = new XStream();

Or, you should add this code to tell XStream to process all annotations:


Two things come to mind:

1.) Did you tell XStream to parse the annotations?

2.) Does your web framework maybe use proxies to access the pojos and those don't delegate the annotations? (happened to a friend with Apache Tapestry)

Category:java Views:1 Time:2010-02-20

Related post

  • Basic XStream Annotations 2010-05-25

    I just started using XStream Annotations, and I am trying to figure out how to associate the annotations with the XStream object. From the documentation, it seems like this is the accepted method: XStream xstream = new XStream(new DomDriver()); xstre

  • Restlet XStream/Jackson different JSON wrapper 2012-01-17

    I would like to switch from Xstream to Jackson for serializing/deserializing objects in a Restlet server. If i use Xstream libraries for: @Get("json") public Profile retrieve() { Profile prf = new Profile (...); ... return prf; } i would get somethin

  • XStream short dynamic aliases 2009-09-03

    I want to have short names for classes, now i can do it with aliases XStream x = new XStream(); x.alias("dic", Dic.class); but i have to define alias manually for every class, is there any way to configure xstream to do it automatically? ------------

  • XStream : node with attributes and text node? 2009-11-13

    I would like to serialize an object to an XML of this form with XStream. <node att="value">text</node> The value of the node (text) is a field on the serialized object, as well as the att attribute. Is this possible without writing a conv

  • XStream: Collapsing XML hierarchy as I parse 2010-01-11

    I have an XML document (generated by Adobe XFA forms), that contains data like the following: <Position> <PositionBorder> <Title/> <StartDate/> <EndDate/> </PositionBorder> </Position> Since this file is defi

  • Warning from XStream, cannot find itemFieldName in XStreamImplicit 2010-06-30

    I'm trying to track down th source of a warning: warning: Cannot find annotation method 'itemFieldName()' in type 'com.thoughtworks.xstream.annotations.XStreamImplicit' The relevant code is: @XStreamAlias("things") @XStreamImplicit(itemFieldName = "t

  • Problem unmarshalling an attribute with name "class" with Xstream 2011-02-07

    I have a node with an attribute named class. The input XML is : <Job class="com.test.jobImplementation"> <Priority>1</Priority> ...... </Job> The Java class which represents the XML is annotated with Xstream annotations is as

  • xStream Duplicating data on retrieving from List 2011-05-30

    I'm doing a test program to write in a xml. I have 3 classes: Person, Telephone and City. And in the Person class, I have some objects like fax, cellular of type telephone. And too Cities objects. I have a 4th class named Persons... it is a class tha

  • Proguard and XStream with omitField() on Android 2011-06-20

    I was using XStream for deserialization of xml in my Android app, and now I'm struggling to add Proguard (obfuscator) to the mix. Here's the runtime exception I run into (full: pastebin): WARN/System.err(6209): net.lp.collectionista.util.a.g: XStream

  • Reading contents of tag with XStream 2011-07-25

    I think I may of "zoomed in" too much with my XStream work, but I'm trying to marshall an XML stream, which contains a variety of large complex objects, and each of these objects tends to have lots of tags such as : <name type="string">My Name

  • xStream parsing of single level XML 2011-12-02

    I have some XML that is a single level with an attribute that I can not get to move from XML to Object: <?xml version="1.0" encoding="utf-8"?> <response status="426"> You can add 15 clients with your current plan. </response> This x

  • JPA 2.0 @OrderColumn annotation in Hibernate 3.5 2010-06-02

    I'm trynig to use @OrderColumn annotation with Hibernate 3.5 @OneToMany(mappedBy = "parent",fetch=FetchType.EAGER, cascade=CascadeType.ALL) @OrderColumn(name = "pos") private List<Children> childrenCollection; When retrieving data everyting wor

  • Spring MVC Annotation Based Controller command object losing values on POST 2010-12-07

    I am loading a user object my calling a service and then store this user as a command object in the model on GET in the controller. This user object has many properties that are not mapped in the jsp page. After submitting the form, I am getting the

  • How to use Java annotations to guide Android's Proguard? 2010-12-16

    When using Proguard with Android, methods that are only invoked via reflection (e.g., callbacks defined in onClick XML attributes) are erroneously stripped out. One solution for this issue is to add each affected class and method to your proguard.cfg

  • python lock method annotation 2011-01-07

    Is there a python lock annotation which has the same effect to a python method as the "synchronized" keyword to java methods? --------------Solutions------------- I can assume that no builtin feature exist in python but you can implement it by unders

  • Annotation attributes with type parameters 2011-09-29

    When you define a Java interface, it's possible to declare a method with type parameters, for example like this: public interface ExampleInterface { <E extends Enum<E>> Class<E> options(); } The same thing does not work in an annota

  • Customizing Granite DS Actionscript code generation from Java classes 2009-12-09

    I'm using GraniteDS Actionscript code generation templates that let's me take a Java object and convert it to an Actionscript class. It's mainly used for BlazeDS Java to Flash communication but I'm adapting it to work with JSON webservices using XStr

  • Deploying a mavenised seam project, noClassdefFound org.jboss.el.util.ReflectionUtil 2010-02-02

    While deploying a mavenized application consisting of a parent project, ejb jar project and a web project I have following stack trace in Jboss As ,5.1.0.GA. I checked that I have the dependency for jboss-el-1.0_02.CR4.jar and the library also contai

  • Multiple response types with same REST GET? 2010-06-24

    I want to create a REST service that can return either JSON or XML. What request parameter do I set in the request to request a certain mime type? I know how to set it in the response, but there must be a way to request a certain one. Currently I do

Copyright (C), All Rights Reserved.

processed in 0.483 (s). 11 q(s)