2 Replies Latest reply on Mar 24, 2009 9:56 AM by Richard Opalka

    Using Threads inside Web Services

    Joshua Tree Newbie

      Dear all,

      According to the EJB specification using threads inside EJB applications is disallowed because Thread management should be managed by the EJB container. Please find the reference below:

      What about Web Services? Can we use threads inside Web Services? Should we do it? Is there any kind of restrictions regarding the use of threads inside web services?


        • 1. Re: Using Threads inside Web Services
          Louis Burton Newbie

          I can't seem to find an answer to the above question in the JBossWS documentation. Without the Servlet interface's init and destroy methods how would we clean up threads on undeployment? I have seen references to @PostConstruct and @PreDestroy however these seem to be called upon every construction of the endpoint interface's implementation. This seems to be constructed whenever a SOAP request is received, and does not seem to be linked to the lifecycle of the underlying servlet.

          Any help would be appreciated, thankyou.

          • 2. Re: Using Threads inside Web Services
            Richard Opalka Master


            in general users shouldn't use threads in webservice endpoints. This rule applies to both EJB and POJO based endpoints.
            Regarding your question about web service initialization/destroy process, the issue you're talking about will be fixed since next i.e. JBossWS 3.1.1.GA release. See JBWS-2486 for more info.