1 Reply Latest reply on May 8, 2006 6:32 PM by dkrizic

    @WebService @Stateless: Not running @PostActvate

    dkrizic

      Hi

      This works:

      @Remote @Stateless @WebService
      public class CalculatorService1 implements Calculator {
      
       @WebMethod
       public int add(int a, int b) {
       Calculator c = new CalculatorImpl();
       int result = c.add( a, b );
       return result;
       }
      }
      


      But I want to create the Calculator using a Spring Bean description. The perfect place is @PostActivate like I did here:

      @Remote @Stateless @WebService
      public class CalculatorService2 implements Calculator {
      
       private static final String SPRING_FILE = "calc.xml";
       private static final String CALC_BEAN = "calculator";
       private Calculator c = null;
       private Log log;
      
       public CalculatorService2() {
       log = LogFactory.getLog( getClass() );
       log.info("Constructor");
       }
      
       @WebMethod
       public int add(int a, int b) {
       log.info("Request for adding " + a + " + " + b );
       int result = c.add( a, b );
       return result;
       }
      
       @PostActivate
       public void postActivate() {
       log.info("Post activate");
       InputStream is = getClass().getClassLoader().getResourceAsStream( SPRING_FILE );
       InputStreamResource isr = new InputStreamResource( is );
       XmlBeanFactory bf = new XmlBeanFactory( isr );
       c = (Calculator) bf.getBean( CALC_BEAN );
       }
      
       @PrePassivate
       public void prePassivate() {
       log.info("Pre passivate");
       c = null;
       }
      }
      


      But the method is never executed. I thought the WebService is wrapper for a SLSB, but it seems like not.

      How could I fix the second code?