I have copied the code from the CXF manual to get access to the ServletContext of either the SOAP or REST call and it works ok. However, I naturally have more that one Service to implement, so I wanted to move this code to an abstract parent class. When the code is there, only the SOAP resource is injected, the REST variable is NULL.

Is there any reason why REST does not work in an inherited class?


   // Get the ServletContext for SOAP and REST
@javax.annotation.Resource private javax.xml.ws.WebServiceContext iSoapWebServiceContext; @javax.ws.rs.core.Context private javax.servlet.ServletContext iServletContext; private ServletContext getServletContext()
   throws javax.ws.rs.WebApplicationException
   {
       if (iSoapWebServiceContext != null)
       {
           // soap invocation
return (ServletContext)iSoapWebServiceContext.getMessageContext().get(javax.xml.ws.handler.MessageContext.SERVLET_CONTEXT);
       }
       else
       {
           // http-only jaxrs one
return iServletContext;//(ServletContext)iRestMessageContext.get(MessageContext.SERVLET_CONTEXT); } }

Reply via email to