0 Replies Latest reply on Feb 20, 2019 6:57 PM by cfang

    How to Obtain JobOperator in JBeret Batch Application

    cfang

      Recently a user reported problem with running JBeret-based batch application in WildFly:

       

      JBERET000640 - Wildfly 14 · Issue #117 · jberet/jsr352 · GitHub

       

      The symptom is as follows, but it boils down how to get hold of JobOperator in order to perform various batch job operations:

       

      JBERET000640: A BatchEnvironment implementation could not be found. Please ensure the SPI has been implemented and is on the class path

       

      I think this issue has come up multiple times, and worth copying it here with a summary of solutions:

       

      • to access the standard API in javax.batch.operations.JobOperator, then call BatchRuntime.getJobOperator() to obtain JobOperator.
        • this is the standard, portable API that works in all versions of JBeret, WildFly, JBoss EAP, or any other compatible JSR-352 implementations.
      • to access additional non-spec-defined API in JBeret's implementation of JobOperator, then use

      AbstractJobOperator jobOperator = (AbstractJobOperator) JobOperatorContext.getJobOperatorContext().getJobOperator();

      as demonstrated in JBeret test class AbstractIT.

        • this is JBeret-specific API and works in JBeret 1.3 or later, which is what the majority of JBeret users are using by now.

       

      Hope this will help you better develop JBeret-based batch application.  See the original jberet github issue #117 for complete details.