-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JBatch fails to execute job on @Startup #204
Comments
This has been reproduced. This is caused by the Batch job executor service checking that the application is enabled before executing the Batch task. However as the application is still deploying this check fails and the batch task is not started. The race condition arises because the Session bean @PostConstruct is called before the application is fully deployed. |
This is fixable but I'm not sure if it would work in all cases as the application may not be fully deployed before the batch job is executed. |
The EJB specification doesn't state that you can use JBatch or concurrency utility within a Singleton @startup @PostConstruct method. I suppose this needs clarification from EJB spec leads. I will try to raise with them. The spec says you can only do; SessionContext methods: getBusinessObject, getRollbackOnly, setRollbackOnly, getTimerService, lookup, getContextData |
Requires input from EJB spec leads |
According to the spec 3.2: In PostConstruct all injected components should be already initialized and "ready to use". Try to run the PostConstruct method within a transaction. Beginning with Java EE 7 it is allowed to execute lifecycle methods within a transaction. |
Related GlassFish JIRA https://java.net/jira/browse/GLASSFISH-21087 for concurrent tasks |
PAYARA-220 fixes #204 still submits executor task during deployment.
FISH-472 Preserve JDK selectors when deleting a JVM option
Hi,
During my testing with jbatch I observed that the batch runtime fails to execute the job if the job gets started via @PostConstruct of a singleton ejb with @Startup-Annotation.
The jobs runs fine, but (in my case) the actual batchlet gets not executed.
I think/guess the probleme is related to the following issue, which I posted last year on the glassfish issue tracker: https://java.net/jira/browse/GLASSFISH-21216
To reproduce:
1). create a simple web-app
2). create a singleton ejb:
3). create a simple Batchlet implementation:
4). and the simple-job.xml file:
On the console you will see the output of the ejb but not the output of the batchlet.
But if you use a @schedule annotation instead of @PostConstruct, the batchlet output gets printed.
The text was updated successfully, but these errors were encountered: