Creating an EJB Timer in Liberty

I need to create an EJB timer (using @Schedule), but read that this is not supported in the Websphere Liberty profile? According to a previously posted question about StackOverflow, it was not supported as of 08/2013:

Java EE-Timer / @ Schedule in Websphere Liberty profile

Currently, when I try to use the @Schedule annotation, I get the following exception:

[ERROR   ] CWWKZ0004E: An exception occurred while starting the application 
<EAR>. The exception message was: com.ibm.ws.container.service.state.StateChangeException: com.ibm.ws.exception.RuntimeError: java.lang.IllegalStateException: The ejbPersistentTimer feature is enabled, but the defaultEJBPersistentTimerExecutor persistent executor cannot be resolved. The most likely cause is that the DefaultDataSource datasource has not been configured. Persistent EJB timers require a datasource configuration for persistence.

The problem is that I have a default data source installed. Here is the EJB code - it is very simple because I was just trying to check the timer functions:

import javax.ejb.Schedule;
import javax.ejb.Stateless;

@Stateless
public class TimerBean {

    @Schedule(second="*/10", persistent=false)
    public void doSomething() {
        System.out.println("Hello World!");
    }

}

Update:

I changed my dataSource identifier to "DefaultDataSource" and now I have other exceptions in my console when starting the server:

[ERROR   ] WTRN0078E: An attempt by the transaction manager to call start on a transactional resource has resulted in an error. The error code was XAER_RMERR. The exception stack trace follows: javax.transaction.xa.XAException: com.microsoft.sqlserver.jdbc.SQLServerException: Could not find stored procedure 'master..xp_sqljdbc_xa_start'.
at com.microsoft.sqlserver.jdbc.SQLServerXAResource.DTC_XA_Interface(SQLServerXAResource.java:647)
at com.microsoft.sqlserver.jdbc.SQLServerXAResource.start(SQLServerXAResource.java:679)
at com.ibm.ws.rsadapter.spi.WSRdbXaResourceImpl.start(WSRdbXaResourceImpl.java:1189)
at [internal classes]

[ERROR   ] J2CA0030E: Method enlist caught javax.transaction.SystemException: XAResource start association error:XAER_RMERR
at com.ibm.tx.jta.impl.RegisteredResources.startRes(RegisteredResources.java:1048)
at [internal classes]
Caused by: javax.transaction.xa.XAException: com.microsoft.sqlserver.jdbc.SQLServerException: Could not find stored procedure 'master..xp_sqljdbc_xa_start'.
at com.microsoft.sqlserver.jdbc.SQLServerXAResource.DTC_XA_Interface(SQLServerXAResource.java:647)
at com.microsoft.sqlserver.jdbc.SQLServerXAResource.start(SQLServerXAResource.java:679)

, SQL- , , ?

+4
4

, ejbPersistentTimer-3.2, DataSource.

ejbPersistentTimer-3.2 ( ejb-3.2, ), , .

EJB ( persistent=false @Schedule), ejbPersistentTimer-3.2 ejbLite-3.2 ( ).

ejbLite-3.2 , DataSource.

+3

EJB WAS Liberty 8.5.5.6 , Java EE 7.

+1
  • . EJB , . , ID
  • EJB → EJB → EJB
  • EJB Persistent Timers Scheduled Executor ID

EJB Lite.

0
-1
source

Source: https://habr.com/ru/post/1615255/


All Articles