Unable to load job xml in jar files inside WAR (and EAR) in EAP 7.0.x
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 7.0.x
Issue
META-INF/batch-jobs/batchInJar.xml in a batch jar file inside WAR is ignored and never loaded. This resulted in the following exception when executing a batch job in jar inside WAR.
javax.batch.operations.JobStartException: JBERET000601: Failed to get job xml file for job batchInJar.xml
at org.jberet.creation.ArchiveXmlLoader.getJobXml(ArchiveXmlLoader.java:129)
at org.jberet.creation.ArchiveXmlLoader.loadJobXml(ArchiveXmlLoader.java:91)
at org.jberet.operations.JobOperatorImpl.start(JobOperatorImpl.java:102)
at service.BatchService.start(BatchService.java:11)
at controller.BatchTestController.batchInJarStart(BatchTestController.java:27)
...(snip)...
Here's an example directory structure of the war file and the jar file included in the war file:
[1] batch-jar-in-war.war
|-- index.xhtml
|-- META-INF
| `-- MANIFEST.MF
`-- WEB-INF
|-- classes
| |-- ...
| `-- META-INF
| `-- batch-jobs
| `-- batchInWar.xml <-- This job xml works
|-- faces-config.xml
|-- lib
| `-- simpleBatch-1.0.jar --- [2]
`-- web.xml
[2] simpleBatch-1.0.jar
|-- META-INF
| |-- batch-jobs
| | `-- batchInJar.xml <-- This job xml is unable to load
|-- processor
| `-- ...
|-- reader
| `-- ...
|-- service
| `-- ...
`-- writer
`-- ...
Resolution
This issue is a bug reported in the following JIRAs. This has been fixed in EAP 7.0.6 or later.
- EAP 7.0.z: [[JBEAP-6776] This content is not included.GSS Unable to load job xml in jar files inside WAR (and EAR)](https://issues.jboss.org/browse/JBEAP-6776) which was fixed in EAP 7.0.3
- EAP 7.1.z: [[JBEAP-6777] This content is not included.GSS Unable to load job xml in jar files inside WAR (and EAR)](https://issues.jboss.org/browse/JBEAP-6777) which was fixed in EAP 7.1.0
- WildFly (Community): Content from issues.jboss.org is not included.[WFLY-4988] Can't load job from another jar inside ear
You can workaround this issue by adding META-INF/services/org.jberet.spi.JobXmlResolver with the following content to your batch jar file:
org.jberet.tools.MetaInfBatchJobsJobXmlResolver
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.