JBoss Community

Re: Load on startup is ignored - JaxWS webservice is always initialized first

created by Jim Ma in JBoss AS7 Development - View the full discussion

If you do not have to call the custom initialization before the webservice constructor , this could help:

  • call custom environment initialization in a ServletContextListener
  • Get servletContext from injected webServiceContext like:

@WebService

public class HelloServletImpl implements HelloServlet {

    @Resource

    public WebServiceContext wsContext;

   

    public HelloServletImpl() {

        System.out.println("HelloServlet is instantiated!");

    }

   

    @Override 

    public String newOperation(final String in) {

        // TODO Auto-generated method stub

        ServletContext servletContext =

            (ServletContext) wsContext.getMessageContext().get(MessageContext.SERVLET_CONTEXT);

        System.out.println(servletContext.getAttribute("TEST"));

        return (String)servletContext.getAttribute("TEST");

    }

 

}

Reply to this message by going to Community

Start a new discussion in JBoss AS7 Development at Community