9 Replies Latest reply on Mar 4, 2015 12:47 PM by Alessio Soldano

    JAXWS handler not first class citizen

    Thomas Kriechbaum Newbie



      are JAXWS-handlers not treated the same way as other managed components?


      It seems that the following features are not supported

      • @PostConstruct
      • @EJB
      • @Inject


      I thought that these features should be provided by the container, even for JAXWS-handlers. According to the JavaEE 7 specification, JAXWS handlers are component classes supporting injection (see Table EE.5-1).




        • 1. Re: JAXWS handler not first class citizen
          Frank Cornelis Apprentice

          In my application I use JAX-WS SOAP handlers with @EJB injections. So at least @EJB works.

          • 2. Re: JAXWS handler not first class citizen
            Thomas Kriechbaum Newbie

            Hello Frank,

            I have reduced my application to the bare minimum (1 Webservice + 1 JAXWS-handler + 1 stateless EJB and 1 CDI-managed singleton). With the following handler, neither the EJB (SecurityService) nor the CDI-managed bean (ServiceContextRepository) have been injected by the container. I have to admit that @PostConstruct works. I have packaged my classes into a single WAR and run it on Wildfily 8.1.0.CR1

            I will file an issue and provide my test application.



            public class ServerSideServiceContextHandler implements Handler<SOAPMessageContext> {



                private SecurityService securityService;



                private ServiceContextRepository serviceContextRepository;


                public ServerSideServiceContextHandler() {





                public void init() {





                public void close(MessageContext context) {





                public boolean handleFault(SOAPMessageContext context) {

                    return true;




                public boolean handleMessage(SOAPMessageContext context) {


                    return true;



                private void log(String operation) {


                    String msg = securityService != null ? securityService.getMessage() : "<null>";

                    System.out.println("securityService msg " + msg);


                    msg = serviceContextRepository != null ? serviceContextRepository.getMessage() : "<null>";

                    System.out.println("serviceContextRepository msg " + msg);





            21:42:46,717 INFO  [stdout] (default task-6) init

            21:42:46,718 INFO  [stdout] (default task-6) securityService msg <null>

            21:42:46,718 INFO  [stdout] (default task-6) serviceContextRepository msg <null>

            21:42:46,730 INFO  [stdout] (default task-6) handleMessage

            21:42:46,731 INFO  [stdout] (default task-6) securityService msg <null>

            21:42:46,731 INFO  [stdout] (default task-6) serviceContextRepository msg <null>

            21:42:46,748 INFO  [stdout] (default task-6) handleMessage

            21:42:46,750 INFO  [stdout] (default task-6) securityService msg <null>

            21:42:46,751 INFO  [stdout] (default task-6) serviceContextRepository msg <null>

            21:42:46,751 INFO  [stdout] (default task-6) close

            21:42:46,751 INFO  [stdout] (default task-6) securityService msg <null>

            21:42:46,752 INFO  [stdout] (default task-6) serviceContextRepository msg <null>

            • 3. Re: Re: JAXWS handler not first class citizen
              Frank Cornelis Apprentice

              Hi Thomas,


              In my WSDL-first application I implement SOAPHandler instead of Handler. Maybe the application server is only triggered for injection on SOAPHandler?

              I declare the usage of the SOAP handler on my JAX-WS endpoint implementation as follows:

              @WebService(endpointInterface = "be.e_contract.dssp.ws.jaxws.DigitalSignatureServicePortType",
                      targetNamespace = "urn:be:e_contract:dssp:ws",
                      serviceName = "DigitalSignatureService")
              @HandlerChain(file = "/dss-ws-handlers.xml")
              public class DigitalSignatureServicePortImpl implements DigitalSignatureServicePortType {

              With dss-ws-handlers.xml containing:

              <?xml version="1.0" encoding="UTF-8"?>
              <jws:handler-chains xmlns:jws="http://java.sun.com/xml/ns/javaee"
                                  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/javaee_web_services_metadata_handler_2_0.xsd">
                          <jws:handler-name>WS-Security Handler</jws:handler-name>

              And of course you declare the web service endpoint in web.xml as follows:

              • 4. Re: JAXWS handler not first class citizen
                Thomas Kriechbaum Newbie

                Hello Frank,


                thanks for your reply - I had some busy days, so I had not too much time to play with Wildfly 8.


                Now I have changed my ServerSideServiceContextHandler class to implement SOAPHandler<SOAPMessageContext>. But the injection (EJB and CDI-managed bean) still does not work - same logging output as described above.

                Maybe I should create an issue.



                • 5. Re: JAXWS handler not first class citizen
                  Frank Cornelis Apprentice

                  mmm... classloading issue?

                  If your application is a WAR, what do you have under WEB-INF/lib?

                  If your application is an EAR, what do you have under lib?

                  • 6. Re: JAXWS handler not first class citizen
                    Thomas Kriechbaum Newbie

                    reduced my sample to a minimum; I have deployed it as WAR with no libs in WEB-INF/lib.

                    • 8. Re: JAXWS handler not first class citizen
                      Sebastian Schmidt Newbie



                      wanted to post a similar question but this one seems to be related. Injection does not work in my application with JAX-RS (RESTEasy). Placing a beans.xml under WEB-INF also does not help.