Skip to main content

Web Service Return Complex Object Type - JAXBContent error

1 reply [Last post]
antoniojsg
Offline
Joined: 2007-01-04
Points: 0

I have written a simple web service, it returns a Complex Type Class defined by me.
Here is the simplified Web Service (for the sake of the readers):

*************************************************************************
@WebService()
@Stateless()
public class SyncMovProductoDet {

@WebMethod(operationName = "getAllTest")
public ProductoDetalle getAllProdDet(wsSecurityToken securityToken) {

return null;
}
}
**************************************************************

The class ProductoDetalle is:

***************************************************************
public class ProductoDetalle {

public Integer codigoProducto;
public String tipoMaterial;
public Integer codigoPapel;

public ProductoDetalle() {
}
public ProductoDetalle(Integer codigoProducto) {
this.codigoProducto = codigoProducto;
}

getter/setter methods ......
}
************************************************************************

When I deploy in GlassFish - Sun Java System Application Server 9.1_02 (build b04-fcs)
It returns the following error:

Exception occured in the wsgen process javax.xml.ws.WebServiceException: Unable to create JAXBContext at com.sun.enterprise.webservice.WsUtil.runWsGen(WsUtil.java:1848) at com.sun.enterprise.webservice.WsUtil.genWSInfo(WsUtil.java:2249)

If I change the return type of the method to String, int, long, etc, it deploys ok.

What I am missing to declare on this Web Service ??

Thank you,

Antonio

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
antoniojsg
Offline
Joined: 2007-01-04
Points: 0

I feel really silly, because it was my fault.

The problem is that the custom class has public access for the properties and also it has getter/setter methods.

I discover because you can use Netbeans to generate the WSDL files for the Webservice to inspect them. Doing so it returned the detailed error.

If you want to use it, write your Web Service, then go to "Web Services" node, select your Web Service, right click it and select "Generate and Copy WSDL".