1

I have created a jax-ws Webservice using netbeans and jboss 4.0.5.

I'm trying to load some files right after deployment.

I have read that I have to use the Annotation @PostConstruct with the method public void init().

The issue here is that I'm trying to print some String to test if its working, but it never get to that init function.

Can somebody give some advice?

Peter O.
  • 32,158
  • 14
  • 82
  • 96
Fernando Cuervo
  • 99
  • 1
  • 1
  • 6
  • Are you sure you deploy your WS as EJB3? Well, it should not be EJB, but AS should support JSR-181: [JBossWS](https://docs.jboss.org/author/display/JBWS/JAX-WS+User+Guide) [supports that](https://issues.jboss.org/browse/JBWS-195). – dma_k Mar 19 '12 at 00:18
  • Hi, Thanks. I have created the webservice via Netbeans(using jax-ws), also i have my jboss 4.0.5 with JBossWS. The thing is that I have created a very simple webservice that has one method "init", with the @PostCOnstruct annotation and its purpose is to print "WS from init method". I think Im not deploying as EJB3. Can you give me more advice please. Also would you like me to post the full code. Thanks – Fernando Cuervo Mar 20 '12 at 19:40
  • Perhaps I have mislead you: these annotations is JSR-109. I know that [`@PostConstruct` can be handled by Spring](http://stackoverflow.com/questions/3434377) and in your case the relative functionality was implemented in [JBWS-2268](https://issues.jboss.org/browse/JBWS-2268). – dma_k Mar 22 '12 at 08:06
  • I have Solved it. I have just added com.sun.xml.ws.transport.http.servlet.WSServlet and com.sun.xml.ws.transport.http.servlet.WSServletContextListener to web.xml, also i have created the archive sun-jaxws.xml Havin all that in order, now whenever I deploy the webservice, it runs the method with the @PostConstruct annotation Heres the link http://tundidor.com/blog/?p=78 Sorry is in spanish – Fernando Cuervo Mar 22 '12 at 17:25

1 Answers1

0

You could also create a new class like this:

@WebListener
public class Init implements ServletContextListener {

    @Override
    public final void contextInitialized(final ServletContextEvent sce) {
         System.out.println("Printed only on deployment");
    }

    @Override
    public final void contextDestroyed(final ServletContextEvent sce) {

    }
}
EVrpg
  • 27
  • 2