Search code examples
wildfly-swarmjberetthorntail

Error while get JobOperatorImpl with Thorntail (Wildfly Swarm) and JBeret


I need to get JobOperatorImpl for dealing with programmatically defined jobs in JBeret. I use Thorntail as a container with io.thorntail:batch-jberet dependency.

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

But I get an exception:Caused by: java.lang.ClassCastException: org.wildfly.extension.batch.jberet.deployment.JobOperatorService cannot be cast to org.jberet.operations.JobOperatorImpl

It works normally when I use JBeret dependency without Thorntail fraction.


Solution

  • You can cast it to org.jberet.operations.AbstractJobOperator.

    It should provide all methods you need for managing jobs.