Question

I'm attempting to create a JAX-WS service that uses JAXB databinding of objects generated from the very large (900+ classes) set of Opentravel Alliance schemas.

I am able to successfully deploy a war (with proper web.xml and sun-jaxws.xml) containing my JAX-WS service on various servlet containers (Jetty, Tomcat6/7, etc.) as long as my web method does not reference any of my JAXB objects. For example, this works:

@WebService(serviceName = "OTAService", 
targetNamespace = "http://www.opentravel.org/OTA/2003/05")
@Addressing
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public class OTAService {
    public String sayHello(final String name) {
        return "Hello " + name + "!";
    }
}

However, if I change the web method to use JAXB databinding by adding a @XmlSeeAlso annotation or by referencing the objects directly, all of the servlet containers I have tried hang indefinitely (1+ hours), without error, and never start:

@WebService(serviceName = "OTAService", 
targetNamespace = "http://www.opentravel.org/OTA/2003/05")
@Addressing
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@XmlSeeAlso({OTAHotelResNotifRQ.class, OTAHotelResNotifRS.class})
public class OTAService {
    @Action(input = "OTA_HotelResNotif")
    @WebMethod(operationName = "OTA_HotelResNotif", action = "OTA_HotelResNotif")
    public @WebResult OTAHotelResNotifRQ tokenizeOtaHotelResNotifRq(
    @WebParam(partName = "OTA_HotelResNotifRQ", name = "OTA_HotelResNotifRQ", 
    targetNamespace = "http://www.opentravel.org/OTA/2003/05") 
    final OTAHotelResNotifRQ request) {
        return request;
    }
}

I have verified that all of the necessary jars, including the JAXB and JAX-WS APIs and runtime jars, are present in the war's /lib directory.

The jar containing my JAXB objects, which is a required dependency for my JAX-WS project, can be created and installed to your local repo by running mvn clean install on this project.

My JAX-WS project, which is available here, can be run in Jetty by invoking mvn clean package jetty:run-war.

You will notice that Jetty starts right up if only the simple sayHello method is present. However, if you uncomment the JAXB method, Jetty and every other servlet container that I've tried will hang forever while attempting to instantiate the JAX-WS servlet. Can someone explain why web methods with JAXB databinding prevent my war from deploying? Since the freezing behavior is identical on a variety of servlet containers, I feel that there must be some crucial step that I'm missing; however, since no errors are reported and the container startup just hangs, I do not know how to proceed.

Était-ce utile?

La solution

It seems that this was due to the large number of JAXB objects in my opentravel project. When I connected VisualVM to the launcher process and sampled the memory, it looked as if JAXB was walking and preloading/caching the entire object tree for some reason (perhaps to reconstruct the schema for inclusion in the WSDL?).

Setting -Dcom.sun.xml.bind.v2.runtime.JAXBContextImpl.fastBoot=true as described in the answer to this question and bumping up the memory with -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m got Jetty to start up quickly.

I am not yet sure if the runtime performance hit will be an acceptable trade-off.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top