5 Replies Latest reply: Dec 6, 2011 8:41 AM by Paul Robinson RSS

    add context-handlers.xml

    Pavlos Polianidis Newbie

      As i read in the development guide about ws-atomic tramsaction, i have ti register the JAX-WS server-side context handler with the deployed web services. As i understand, i have to include the context-handler.xml file into the project and then use the javax.jws.HandlerChain annotation.


      I develop my servives following the WSDL to java approach and build the project with maven in eclipse. How can i accomplish this task. I have been searching but could not find anything.


      I managed to register my client for the transaction (following the example provided with jbossTS), however i am strugling to do the same for the service.


      When the clients calls the service, i get the following exception:



      javax.xml.ws.soap.SOAPFaultException: MustUnderstand headers: [{http://docs.oasis-open.org/ws-tx/wscoor/2006/06}CoordinationContext] are not understood.
           $Proxy572.checkFlightAvailability(Unknown Source)
        • 1. Re: add context-handlers.xml
          Paul Robinson Master



          Take a look at this example service implementation:




          Here you will see the following class-level annotation:


           @HandlerChain(file = "/context-handlers.xml", name = "Context Handlers")


          This is how you specify which handler chain to use on the client side. You need to ensure that the context-handlers.xml file is available inside your deployment archive at the classpath location, specified in the annotation. For a war, the file should be located under  /WEB-INF/classes.


          Here's an example of the context-handlers.xml file:





          • 2. Re: add context-handlers.xml
            Pavlos Polianidis Newbie

            Hi Paul,


            Actually i have examined the examples provided in the jbossts demo. The issue in my case is that i use the wsdl to java approach, where i cannot insert the @HandlerChain(file = "/context-handlers.xml", name = "Context Handlers") annotation in my code. Is there a way to register the service-side handler chain, inside my code, like i did in my client?


            As i noticed, the SOAP handler is the class com.arjuna.mw.wst11.client.JaxWSHeaderContextProcessor, which obviously will integrate the coordination context into the soap messages. My question is how to explicitely add this handler without using the @handlerchain annotation.

            • 3. Re: add context-handlers.xml
              Pavlos Polianidis Newbie

              Hi paul,


              Again me. I followed your instructions. I added the @HandlerChain(file = "/context-handlers.xml", name = "Context Handlers") annotation. But know i get the following exception

              when i try to deploy the service:



              21:45:12,790 ERROR [ContextLoader] Context initialization failed
              org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'FlightService': Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.util.ArrayList] to required type [java.util.List] for property 'handlers'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [com.arjuna.mw.wst11.service.JaxWSHeaderContextProcessor] to required type [javax.xml.ws.handler.Handler] for property 'handlers[0]': no matching editors or conversion strategy found


              what is wrong with that. I understand what the exception means but i don't to know how to solve it.

              • 4. Re: add context-handlers.xml
                Pavlos Polianidis Newbie

                To be honest, the error that i mentioned above appeared when i tried to add the hadler chain via the appcontext.xml file of the Spring framework. I followed the instructions from this link: http://cxf.apache.org/docs/jax-ws-configuration.html


                Then i tried to do the same task, but using the annotation approach now(the one you suggested). However i get the following exception:


                Caused by: java.lang.ClassCastException: class com.arjuna.mw.wst11.service.JaxWSHeaderContextProcessor
                     at java.lang.Class.asSubclass(Class.java:3018)
                     at org.apache.cxf.jaxws.handler.HandlerChainBuilder.buildHandlerChain(HandlerChainBuilder.java:121)

                this is the root of the exception.

                • 5. Re: add context-handlers.xml
                  Paul Robinson Master



                  This is a known issue:





                  This is one of the issues that I was referring to when I said you would have problems if you used a version of JBoss AS 7, prior to 7.1.0.beta1b.


                  You should upgrade to JbossAS 7.1.0.beta1b to fix this problem and a number of other issues with XTS.