last day (20 days later) » 

5:21 AM
0
A: How to send a property as a string in RestEasy response?

leflohIf you are using Jackson as JSON Serializer you can extend the JacksonJsonProvider: @Provider public class JsonProvider extends org.codehaus.jackson.JacksonJsonProvider { public JsonProvider() { ObjectMapper objectMapper = locateMapper(ObjectMapper.class, MediaType.APPLICATION_JSON_...

 
We are not using Jackson api. Unfortunately we are not supposed to use even. Is there any other way?
 
Which JSON-Serializer do you use?
 
We use jettison serializer
 
I updated my answer.
 
Thank you. I will check this. Meanwhile I added another method in my domain class which will return id as string. So there will be two methods in my domain class. getId and getIdAsLong. The first one will be used by jettison and second one will be used by the services/classes in my application. I assumed that jettison will serialize the properties and send only id in the json. But it has sent idAsLong also in the json. But this is not a problem for me. And I will now introduce the jettison XmlAdapter which seems to be a very convincing solution. Thanks :)
 
5:21 AM
Just add @XmlTransient to getIdAsLong and Jettison should skip this field.
 
I tried the XmlAdapter but I received id as long only in the json. I included a package-info.java class in the same package where my domain class is. The adapter class is JobIdAdapter which extends XmlAdapter<String, Long>. I use jboss eap 6.x. Should I do any more configurations in some jboss xml files? Besides my domain class is not annotated with @XmlRootElement. Is it necessary to do so?
 
There should be no other configuration necessary but you need to annotate your Bean with @XmlRootElement.
 
I annotated the bean with @XmlRootElement. Its not working. Later I followed this docs.jboss.org/jbossas/javadoc/7.1.2.Final/javax/xml/bind/… where package-info.java is not necessary. But still its not working. Even @XmlTransient did not work. One thing I noticed is the domain classes are packaged in a jar(ejb) module. Should they be packed in war module for serialization to happen properly? May be I will create a dummy project and check.
 
Please check if you really use Jettison. JBoss EAP 6 ships with Jackson afaik. You can change this with adding org.jboss.resteasy.resteasy-jackson-provider or org.jboss.resteasy.resteasy-jettison-provider to your classpath.
 
Yeah, I checked my pom. Its jettison for sure.
 
5:22 AM
Is the Adapter called?
 
No, I dont see any logs
May be I will create a dummy project and check. My ear has some duplicate jars also. So I suspect the problem is with that. My war has some jars. The same jars are packed in the ear also. Others are working to clean it up. Meanwhile I will try with a sample project.
 
OK, good luck. I'll be offline the next three days. Could help on monday if it's still not working.
 
Many thanks. I really appreciate your support. Hope I should be able to fix it by EOD. Else we can discuss on monday. Have a nice week end
 
6:29 AM
I noticed there are two providers in jboss modules provider. jackson and jettison. Should it be the problem?
I tried all possible ways. Nothing is working
 
 
1 hour later…
7:49 AM
Can you please share your email id. I will send you a sample application.
 

  last day (20 days later) »