6 Replies Latest reply on Nov 4, 2003 6:05 AM by gue13

    oracle ds and Timer MBean  in Stateful Session Bean

    gue13 Newbie

      Hi all,

      i am trying to use the Timer MBean with a stateful session bean and need help...

      my sfsb has 3 business methods, which are to be called in a defined order (b1 => b2 => b3)
      after b1 and b2 a timeout of 11 seconds is required (which i tried using Timer MBean as described)
      (b2 does a "select for update" in database, locking one or more records, b3 releases the record, either doing a commit or rollback)

      Timer-Listener in my SFSB:

      public class Listener_New implements NotificationListener {
      public void handleNotification(Notification pNotification, Object pHandback) {...}

      my sfsb is working fine, my CON (Database Conneciton) exists over all 3 business methods. the only (and BIG) problem is, if the Timer-Listener receives an event (which i registered),
      the CON is still there (NOT closed) but i got the error:

      java.sql.SQLException: Connection handle is not currently associated with a ManagedConnection
      2003-11-02 21:35:56,682 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.WrappedConnection.checkStatus(WrappedConnection.java:804)
      2003-11-02 21:35:56,692 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.WrappedConnection.setAutoCommit(WrappedConnection.java:455)

      Maybe its because the Listener is not a business-method and the transaction-context or session-context is lost??? any idea?? please help!!!

      kind regards

        • 1. Re: oracle ds and Timer MBean  in Stateful Session Bean
          Elias Ross Master


          If your timer event is being activated through JMX, there is no container transaction established. The datasource you are using isn't going to work right. You can use a datasource that supports local transactions (if you can establish a user transaction) or no transactions.



          <no-tx-datasource>
          ... connection info goes here ...
          </no-tx-datasource>



          I would recommend firing a message through JMS to have some sort of transaction context to work with the session bean.

          • 2. Re: oracle ds and Timer MBean  in Stateful Session Bean
            Bernd Zeitler Expert

            IMHO, this is very bad design.
            No matter if you can get this to run, you must not do this. With registering your SFSB as listener to the Timer, you are violating the programming restrictions (EJB spec), since the timer is doing a callback by referencing the bean instance.

            Greetings,
            Frito

            • 3. Re: oracle ds and Timer MBean  in Stateful Session Bean
              gue13 Newbie

              i tried this in oracle_ds.xml:


              <no-tx-datasource>
              <jndi-name>OraclePOS</jndi-name>
              <connection-url>jdbc:oracle:thin:@[myip]:[myport]:[mysid]</connection-url>

              <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
              <user-name>[myuser]</user-name>
              [mypwd]

              <!-- <transaction-isolation>TRANSACTION_SERIALIZABLE</transaction-isolation> -->
              <!--pooling parameters-->
              <min-pool-size>1</min-pool-size>
              <max-pool-size>5</max-pool-size>
              <blocking-timeout-millis>5000</blocking-timeout-millis>
              <idle-timeout-minutes>5</idle-timeout-minutes>
              <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
              </no-tx-datasource>


              in addition an entry in transaction-service.xml:
              true

              without this, connection will be closed after a business method...

              => no changes, same error-message!
              java.sql.SQLException: Connection handle is not currently associated with a ManagedConnection


              very strange i think, the "no-tx-datasource"-declaration prevents using my datasource in transaction context?

              • 4. Re: oracle ds and Timer MBean  in Stateful Session Bean
                gue13 Newbie

                hi frito,

                tanks for your advise, i know it's not a "beautiful" solution - but the major problem is: how can i achive a custom timout starting after completing a business-method in a sfsb?

                kind regards

                • 5. Re: oracle ds and Timer MBean  in Stateful Session Bean
                  Bernd Zeitler Expert

                  I think the trick is not building a workaround and NOT doing this in SFSB.
                  Your SFSB could call a MBean doing all the things you like to do.

                  Greetings,
                  Frito

                  • 6. Re: oracle ds and Timer MBean  in Stateful Session Bean
                    gue13 Newbie

                    hi frito,
                    if i would be at the beginning of a project, maybe i would consider a better solution, but in fact, i have a sfsb with 3 business-methods, and a few jdbc-statements (select for update, etc.) over all 3 methods.
                    i need a kind of timeout-facility between the business-methods (eg. after the first, before the second) very urgent. is there no way, to solve this problem??? any idea?? it's hard to believe, that nobody needs more than the one timeout defined for the whole SFSB...

                    kind regards