1

I'm trying to use JBeret implementaton of JSR352 in an EE environment but not Wildfly/JBoss.

I'm working with JBeret 1.4.7.Final deployed on Open Liberty 21.0.0.12. I know that Open Liberty have its own JSR352 implementation but I'm interested by the infinispan JobRepositry proposed by JBeret. I don't want to rely on a persistant database with all its deployment constraint.

I've added all dependencies listed in the documentation : https://github.com/jberet/jsr352/tree/1.4.x#minimal-application-dependencies

But I'm getting an error telling me that there is no BatchEnvironment implementation available.

[INFO] [ERROR   ] CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method "scheduleJobExecution" on bean "BeanId(scheduleBatchlet#scheduleBatchlet.war#BatchletSingletonBean, null)". Exception data: java.lang.ExceptionInInitializerError
[INFO]  at org.jberet.spi.JobOperatorContext.getJobOperatorContext(JobOperatorContext.java:48)
[INFO]  at org.jberet.samples.wildfly.batchletsingleton.BatchletSingletonBean.scheduleJobExecution(BatchletSingletonBean.java:46)
[INFO]  at sun.reflect.GeneratedMethodAccessor629.invoke(Unknown Source)
[INFO]  at java.lang.reflect.Method.invoke(Method.java:498)
[INFO]  at com.ibm.ejs.container.EJSContainer.invokeProceed(EJSContainer.java:4886)
[INFO]  at [internal classes]
[INFO] Caused by: javax.batch.operations.BatchRuntimeException: JBERET000640: A BatchEnvironment implementation could not be found. Please ensure the SPI has been implemented and is on the class path
[INFO]  ... 11 more
[INFO] 

It seems that there is no implementation in the jberet-core dependency ! Wildfly seems to have its own implementation but obviously Open Liberty don't have one because its JSR352 implementation does not rely on JBeret.

So I've tried to add some other dependencies from the java-ee-bom module (jberet-se actually) : https://github.com/jberet/jsr352/tree/1.4.x/jberet-ee-bom jberet-se have a BatchEnvironment implementation but I don't know if it's the right way to use this implementation in an EE environment... And it's not working either. I'm getting a WeldContainer error. Seems that the SE dependency need all the weld SE dependencies... Don't seems right for my need :s

[INFO] [ERROR   ] CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method "scheduleJobExecution" on bean "BeanId(scheduleBatchlet#scheduleBatchlet.war#BatchletSingletonBean, null)". Exception data: java.lang.NoClassDefFoundError: org/jboss/weld/environment/se/WeldContainer
[INFO]  at org.jberet.se.SEArtifactFactory.<init>(SEArtifactFactory.java:30)
[INFO]  at org.jberet.se.BatchSEEnvironment.getArtifactFactory(BatchSEEnvironment.java:117)
[INFO]  at org.jberet.operations.AbstractJobOperator.startJobExecution(AbstractJobOperator.java:447)
[INFO]  at org.jberet.operations.AbstractJobOperator.access$000(AbstractJobOperator.java:60)
[INFO]  at org.jberet.operations.AbstractJobOperator$1.invoke(AbstractJobOperator.java:146)
[INFO]  at org.jberet.operations.AbstractJobOperator$1.invoke(AbstractJobOperator.java:142)
[INFO]  at org.jberet.operations.AbstractJobOperator.invokeTransaction(AbstractJobOperator.java:465)
[INFO]  at org.jberet.operations.AbstractJobOperator.start(AbstractJobOperator.java:142)
[INFO]  at org.jberet.operations.AbstractJobOperator.start(AbstractJobOperator.java:102)
[INFO]  at org.jberet.operations.AbstractJobOperator.start(AbstractJobOperator.java:81)
[INFO]  at org.jberet.operations.DelegatingJobOperator.start(DelegatingJobOperator.java:68)
[INFO]  at org.jberet.samples.wildfly.batchletsingleton.BatchletSingletonBean.scheduleJobExecution(BatchletSingletonBean.java:49)
[INFO]  at sun.reflect.GeneratedMethodAccessor632.invoke(Unknown Source)
[INFO]  at java.lang.reflect.Method.invoke(Method.java:498)
[INFO]  at com.ibm.ejs.container.EJSContainer.invokeProceed(EJSContainer.java:4886)
[INFO]  at [internal classes]
[INFO] 

Is JBeret too tied to Wildfly to be used in an other EE environment ? Do I miss something ? I didn't find any BatchEnvironment suitable for an other EE application server than Wildfly...

Clément Honoré
  • 137
  • 1
  • 12
  • It's true Open Liberty's batch impl doesn't support a pluggable job repository. I'm not sure what dependencies you'd have to package to your application to provide the needed JBeret impl but let me ask a different question from another angle: what feature set are you intending to use from Open Liberty (i.e., what features do you have configured in server.xml)? – Scott Kurz Apr 20 '22 at 11:09
  • In my sample app, I just have "ejb-3.2" (for my ejb timer scheduler) and "cdi-2.0". I've not enable "batch-1.0" because I don't want to have two implementations of jsr352 (and if I do I have an injection error because it found two impl for StepContext interface). – Clément Honoré Apr 20 '22 at 11:20
  • Thanks. If you have a sample repo somewhere I'd be interested to give it a try (in case someone who already knows the answer doesn't answer in the meantime). – Scott Kurz Apr 20 '22 at 11:37
  • Thanks to you. I've uploaded my sample app here : https://github.com/Kiiv/poc-jberet-scheduled-batchlet – Clément Honoré Apr 20 '22 at 13:56
  • OK, I've recreated your problem but am out of suggestions. I'm seeing the same thing as you: the JBeret SE BatchEnvironment depends on Weld. Even if you wanted to bring Weld SE into your app I'm not sure it'll work since the bean archive is laid out differently. Will leave this then for someone more knowledgeable about JBeret. Separately if there's anything we can do to help w/ the Open Liberty Batch impl (which does only offer DB persistence as you noted) feel free to each us at: https://gitter.im/OpenLiberty/developer-experience . – Scott Kurz Apr 20 '22 at 15:27

0 Answers0