0 Replies Latest reply on Jun 20, 2008 3:33 PM by saro falsaperla

    Timer with Jboss and MySql

    saro falsaperla Newbie

      Hi,
      i am new to EJB 3.0 and jboss
      i am trying to create a timer with this code taken from the j2ee documentation

      /**
       * TimerBean is a stateless session bean that creates a timer and prints out a
       * message when a timeout occurs.
       * Created Jan 9, 2006 3:44:08 PM
       * @author ian
       */
      @Stateless
      public class TimerSessionBean implements TimerSession {
       private static final Logger logger = Logger.getLogger(
       "com.sun.tutorial.javaee.ejb.timersession.TimerSessionBean");
       @Resource
       TimerService timerService;
      
       public void setTimer(long intervalDuration) {
       Timer timer = timerService.createTimer(
       intervalDuration,
       "Created new timer");
       }
      
       @Timeout
       public void timeout(Timer timer) {
       System.out.println("Timeout occurred");
       }
      }
      


      I get these errors...can someone help me?

      I use the "4.5. EJB Timer Configuration" of the jboss configuraton guide

      <!-- ==================================================================== -->
       <!-- J2EE Timer Service -->
       <!-- ==================================================================== -->
      
       <!-- An EJB Timer Service that is Tx aware -->
       <mbean code="org.jboss.ejb.txtimer.EJBTimerServiceImpl"
       name="jboss.ejb:service=EJBTimerService">
       <attribute name="RetryPolicy">jboss.ejb:service=EJBTimerService,retryPolicy=fixedDelay</attribute>
       <attribute name="PersistencePolicy">jboss.ejb:service=EJBTimerService,persistencePolicy=database</attribute>
       <attribute name="TimerIdGeneratorClassName">org.jboss.ejb.txtimer.BigIntegerTimerIdGenerator</attribute>
       <attribute name="TimedObjectInvokerClassName">org.jboss.ejb.txtimer.TimedObjectInvokerImpl</attribute>
       <depends optional-attribute-name="TransactionManagerFactory" proxy-type="org.jboss.tm.TransactionManagerFactory">
       jboss:service=TransactionManager
       </depends>
       </mbean>
      
       <!-- A retry policy that uses a fixed interval in milli seconds -->
       <mbean code="org.jboss.ejb.txtimer.FixedDelayRetryPolicy" name="jboss.ejb:service=EJBTimerService,retryPolicy=fixedDelay">
       <attribute name="Delay">100</attribute>
       </mbean>
      
       <!-- A persistence policy that does not persist the timers
       <mbean code="org.jboss.ejb.txtimer.NoopPersistencePolicy" name="jboss.ejb:service=EJBTimerService,persistencePolicy=noop"/>
       -->
      
       <!--
       A persistence policy that persists timers to a database.
      
       The 2 supported db persistence plugins are:
       org.jboss.ejb.txtimer.GeneralPurposeDatabasePersistencePlugin
       org.jboss.ejb.txtimer.OracleDatabasePersistencePlugin
      
       The table name defaults to "TIMERS". It can be overriden using the
       'TimersTable' attribute if the persistence plugin supports it.
       When overriding the timers table, an optional schema can be specified
       using the syntax [schema.]table
       -->
       <mbean code="org.jboss.ejb.txtimer.DatabasePersistencePolicy" name="jboss.ejb:service=EJBTimerService,persistencePolicy=database">
       <!-- DataSourceBinding ObjectName -->
       <depends optional-attribute-name="DataSource">jboss.jca:service=DataSourceBinding,name=MySqlDS</depends>
       <!-- The plugin that handles database persistence -->
       <attribute name="DatabasePersistencePlugin">org.jboss.ejb.txtimer.GeneralPurposeDatabasePersistencePlugin</attribute>
       <!-- The timers table name -->
       <attribute name="TimersTable">TIMERS</attribute>
       </mbean>
      



      <datasources>
       <local-tx-datasource>
       <jndi-name>MySqlDS</jndi-name>
       <connection-url>jdbc:mysql://localhost:3306/bidone</connection-url>
       <driver-class>com.mysql.jdbc.Driver</driver-class>
       <user-name>root</user-name>
       <password>*******</password>
       </local-tx-datasource>
      </datasources>
      


      19:29:27,693 INFO [EJB3Deployer] Deployed: file:/home/finalsayan/Desktop/SE2/3-IMPLEMENTATION/jboss-4.2.2.GA/server/default/tmp/deploy/tmp46825BIDONE.ear-contents/BIDONEEJB.jar
      19:29:27,700 INFO [TomcatDeployer] deploy, ctxPath=/BIDONEWeb, warUrl=.../tmp/deploy/tmp46825BIDONE.ear-contents/BIDONEWeb-exp.war/
      19:29:27,824 INFO [EARDeployer] Started J2EE application: file:/home/finalsayan/Desktop/SE2/3-IMPLEMENTATION/jboss-4.2.2.GA/server/default/deploy/BIDONE.ear
      19:29:27,845 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
      
      --- MBeans waiting for other MBeans ---
      ObjectName: jboss.ejb:service=EJBTimerService,persistencePolicy=database
       State: FAILED
       Reason: java.lang.IllegalStateException: Cannot find datasource meta data: jboss.jdbc:datasource=MySqlDS,service=metadata
       I Depend On:
       jboss.jca:service=DataSourceBinding,name=MySqlDS
      
      --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
      ObjectName: jboss.ejb:service=EJBTimerService,persistencePolicy=database
       State: FAILED
       Reason: java.lang.IllegalStateException: Cannot find datasource meta data: jboss.jdbc:datasource=MySqlDS,service=metadata
       I Depend On:
       jboss.jca:service=DataSourceBinding,name=MySqlDS
      
      
      19:29:27,976 INFO [Http11Protocol] Starting Coyote HTTP/1.1 on http-127.0.0.1-8080
      19:29:28,105 INFO [AjpProtocol] Starting Coyote AJP/1.3 on ajp-127.0.0.1-8009
      19:29:28,128 INFO [Server] JBoss (MX MicroKernel) [4.2.2.GA (build: SVNTag=JBoss_4_2_2_GA date=200710221139)] Started in 15s:276ms
      



      thank you