3 Replies Latest reply on Nov 15, 2012 5:19 AM by Martin Kouba

    @Schedule and @RequestScoped beans

    Marcel Šebek Newbie

      I'm seeing a strange behavior of @javax.ejb.Schedule methods with relation to CDI contexts. I have a request scoped bean with producer and disposer handler:


      public class Factory {

           @Produces @RequestScoped

           public MyConnection createConnection() {

                System.out.println("creating connection");

                return new MyConnection();



           public void disposeConnection(@Disposes MyConnection connection) {

                System.out.println("disposing connection");




      and an ejb (either stateless or singleton) with timer method:




      @Singleton @Startup

      public class MyEJB {


           private MyConnection conn;


           @Schedule(second = "*/5", minute = "*", hour = "*")

           public void timeout() {

                System.out.println("timer called");




      I see that for each call, a new connection is produced but no connection is disposed which leads to fast connection pool exhaustion. Can anyone tell me whether this type of injection is unsupported or if it is a bug in weld?