Set/configure the EJB Timer Service’s DataSource

后端 未结 3 1885
野趣味
野趣味 2020-12-08 11:37

I\'m trying to use the Timer Service in EJB 3.1 in my app.

@Stateless
@LocalBean
public class StatelessTimerSessionBean {

    @Schedule(minute = \"*\", seco         


        
相关标签:
3条回答
  • 2020-12-08 12:08

    1. Example Database Setup

    1. I use MySQL for my database.

    2. Create the table EJB__TIMER__TBL from {GF_HOME}/glassfish/lib/install/databases/ejbtimer_{DB_ENGINE}.sql

    DB_ENGINE = e.g MySQL:

    CREATE TABLE EJB__TIMER__TBL (
        `CREATIONTIMERAW`      BIGINT        NOT NULL,
        `BLOB`                 BLOB,
        `TIMERID`              VARCHAR(255)  NOT NULL,
        `CONTAINERID`          BIGINT        NOT NULL,
        `OWNERID`              VARCHAR(255)  NULL,
        `STATE`                INTEGER       NOT NULL,
        `PKHASHCODE`           INTEGER       NOT NULL,
        `INTERVALDURATION`     BIGINT        NOT NULL,
        `INITIALEXPIRATIONRAW` BIGINT        NOT NULL,
        `LASTEXPIRATIONRAW`    BIGINT        NOT NULL,
        `SCHEDULE`             VARCHAR(255)  NULL,
        `APPLICATIONID`        BIGINT        NOT NULL,
        CONSTRAINT `PK_EJB__TIMER__TBL` PRIMARY KEY (`TIMERID`)
    );
    

    2. Server Configuration

    1. Start your GlassFish server admin console: usually http://localhost:4848
    2. On your left navigate to [Configurations] > [server-config] > [EJB Container]
    3. Then click the TAB up top [EJB Timer Service]
    4. Then fill out Timer Datasource: with your JDBC Resource eg. [mysql-pu]. ( Note: Defaults to jdbc/__TimerPool)
    5. Restart the Server

    3. The Result

    ...
    INFO: [TimerBeanContainer] Created  TimerBeanContainer: TimerBean
    INFO: EJB5181:Portable JNDI names for EJB TimerBean: [java:global/ejb-timer-service-app/TimerBean, java:global/ejb-timer-service-app/TimerBean!com.sun.ejb.containers.TimerLocal]
    INFO: WEB0671: Loading application [ejb-timer-service-app] at [/ejb-timer-service-app]
    INFO: EJB5109:EJB Timer Service started successfully for data source [mysql-pu]
    INFO: Setting DBReadBeforeTimeout to false
    INFO: ==> Restoring Timers ... 
    INFO: There are no EJB Timers owned by this server
    INFO: <== ... Timers Restored.
    ...
    

    4. Still Broken? TimerService just stopped working (it used to work)?

    So this happened to me after a day full of "deploy on save". The TimerService was unavailable all of a sudden.

    Severe:   Exception while loading the app
    Severe:   Undeployment failed for context /ejb-timer-service-app
    Warning:   Cannot deploy or load EJBTimerService: org.glassfish.deployment.common.DeploymentException: Error in linking security policy for ejb-timer-service-app -- Inconsistent Module State
    

    Solution Found Here

    5. Useful Links

    • Oracle: To Deploy an EJB Timer to a Cluster
    0 讨论(0)
  • 2020-12-08 12:25

    In JBoss/WildFly, you can follow these instructions:

    Mastertheboss.com: Creating clustered EJB 3 Timers
    Published: 08 March 2015

    0 讨论(0)
  • 2020-12-08 12:26

    That sounds like the glassfish-3.1.2.2 does not support EJB3, try to use jboss 7.

    http://docs.oracle.com/cd/E26576_01/doc.312/e24939/release-notes.htm

    0 讨论(0)
提交回复
热议问题