Reputation: 585
I need to create a EJB timer (using @Schedule), but have read that this is not supported in a Websphere Liberty profile? According to a previously posted question on StackOverflow, it wasn't 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 I DO have a default data source defined. Here is the EJB code - it is very simple because I was just trying to test out timer functionality:
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 id to "DefaultDataSource", and now I am getting a different 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)
Is this the result of the timer attempting to write to my SQL DB, and if so, is there a way to avoid this?
Upvotes: 4
Views: 6037
Reputation: 41240
ID
ID
of the Database StoreThat should get rid of the error and will not require you to switch to EJB Lite.
Upvotes: 0
Reputation: 42926
It looks like you have the ejbPersistentTimer-3.2
feature turned on, since you are getting exceptions for having a DataSource configured.
If you are going to use ejbPersistentTimer-3.2
(or ejb-3.2
which includes it) you need to configure a datasource to be used for persistent timers.
Since you don't need persistent EJB timers (because you have persistent=false
in your @Schedule
annotation) you can remove the ejbPersistentTimer-3.2
feature and just use the ejbLite-3.2
feature (which doesn't include the persistent timer feature).
The ejbLite-3.2
feature includes support for non-persistent timers, and you won't need to worry about configuring a DataSource.
Upvotes: 5
Reputation: 3176
EJB timers are supported with WAS Liberty provided you use 8.5.5.6 or newer which is fully compliant with Java EE 7.
Upvotes: 1
Reputation: 151
From the IBM article at http://www.ibm.com/developerworks/websphere/library/techarticles/1404_vines1/1404_vines1.html, it looks like it is not available and you'll have to go third party:
The EJB Timer Service is not supported on Liberty profile or Liberty Core. If your application uses the EJB Timer Service, you can select one of these options: Deploy this part of your application in the WebSphere Application Server Full profile. Use other third-party scheduling libraries. Note: Although the second option is listed as a complex approach, its complexity can be simplified if a small number of timers are involved.
Update:
A little further research found this thread which seems to offer a solution (at least there's an accepted answer):
https://developer.ibm.com/answers/questions/187132/ejbpersistenttimer-32/
Upvotes: -1