4 Replies Latest reply on Sep 29, 2005 4:00 PM by bill.burke

    @Service Stateless Session Bean problems

    eelgueta

      Hi All,

      I need to create an EJB that works like an application-wide service, so I'm using the following bean:

      public @Stateless @Service class MyAppServiceBean implements MyAppService {...}

      I understand the @Stateless annotation instructs JBoss to use a single instance, so in the client app I'm creating one instance and storing the reference in a session object. However, when I retrieve the reference in another servlet, I get a new instance.

      I can tell because the @PostConstruct method logs a message, and I'm seeing that message when I retrieve the reference in the second servlet.

      Am I correct in my assumption the @Stateless annotation implies a single instance? If so, is this a bug? If not, what is the correct use for this annotation?

      Thank you very much in advance for any answer/tip/pointer.

      Ed.