Resource code snippet:
--------------------------------
@Path ("/customer")
public class CustomerResource {
@GET
@Produces ("application/xml")
public Customer getAccount(@QueryParam("customerId") String custId)
throws Exception{
Customer act = null;
....
return act;
}
}
Java class:
-----------
@XmlRootElement(name = "Customer", namespace ="
http://foo.com")
public class Customer implements Serializable{
public Customer(){}
@XmlElement(name = "name", namespace ="
http://foo.com")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@XmlElement(name = "id", namespace ="
http://foo.com")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@XmlElement(name = "emailId", namespace ="
http://foo.com")
public String getEmailId() {
return emailId;
}
public void setEmailId(String emailId) {
this.emailId = emailId;
}
@XmlElement(name = "address", namespace ="
http://foo.com")
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
private String emailId;
private String address;
private String name;
private String id;
}
I get following exception...
EVERE: A message body writer for Java type, class Customer_$$_javassist_0,
and MIME media type, application/xml, was not found
Aug 14, 2009 11:39:39 PM
com.sun.jersey.server.impl.application.WebApplicationImpl onEx
ception
SEVERE: Internal server errorjavax.ws.rs.WebApplicationException
at
com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:241)
at
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:693)
at
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:616)
at
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:607)
at
com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:309)
Troubleshooting ideas?
Thanks.