WASdev / standards.jsr352.jbatch

Home of 'jbatch', a compatible implementation of the Jakarta Batch specification (and the former Reference Implementation for the JSR 352, Batch Applications for the Java Platform specification).
Other
21 stars 18 forks source link

Enabling loading XML from directory? #38

Closed seckin206 closed 6 years ago

seckin206 commented 9 years ago

Hi,

How can I enable loading job XMLs from a directory? I know there are two versions of the XML loader, but I couldn't figure out how to do it using batch-service.properties

BrentDouglas commented 9 years ago

Afaict, the RI doens't have a built in for it. You could implement com.ibm.jbatch.spi.services.IJobXMLLoaderService where you load the job from a dir and then add JOBXML_LOADER=your.impl.ClassName to batch-services.properties.

BrentDouglas commented 9 years ago

Nope, I take that back, it does hava a dir loader. Add JOBXML_LOADER=com.ibm.jbatch.container.services.impl.DirectoryJobXMLLoaderServiceImpl in META-INF/services/batch-services.properties and you should be right.

You will also need to set the system property com.ibm.jbatch.jsl.directory=/path/to/your/xmls.

seckin206 commented 9 years ago

I should include the line in my batch applications META-INF/services/batch-services.properties file, am i right?

BrentDouglas commented 9 years ago

Hmm it looks like you would have to edit the batch-services.properties from the jbatch jar, which seems pretty useless for what you are doing. You can however provide this info using two system properties instead of editing the jar: com.ibm.jbatch.spi.ServiceRegistry.JOBXML_LOADER=com.ibm.jbatch.container.services.impl.DirectoryJobXMLLoaderServiceImpl and com.ibm.jbatch.jsl.directory=/path/to/your/xmls

seckin206 commented 9 years ago

Well, tried but not working. I still get the same error FileNotFound under META-INF/batch-jobs. I guess it indicates that it is not looking for the directory I put.

If you wanna reproduce my setup: Glassfish 4.1 JVM Options -Dcom.ibm.jbatch.jsl.directory="D:/" -Dcom.ibm.jbatch.spi.ServiceRegistry.JOBXML_LOADER=com.ibm.jbatch.container.services.impl.DirectoryJobXMLLoaderServiceImpl

BrentDouglas commented 9 years ago

Could you post a stack trace? Also shouldn't that be D:\?

seckin206 commented 9 years ago

https://gist.github.com/seckin206/2e44b8bf4fd86fabf2f2

seckin206 commented 9 years ago

screenshot from 2015-09-10 12 39 25

scottkurz commented 9 years ago

The property name is just _JOBXML_LOADER_SERVICE_ not the more nicely qualified _com.ibm.jbatch.spi.ServiceRegistry.JOBXML_LOADER_.

Well that's kind of ugly. No one's pushed on this at all in a GF environment so we hadn't thought to make this more nicely configurable.

Also I'm not sure versions of Glassfish this first was integrated with, though I imagine it's been in nightly builds for awhile now.

Please see if that helps.

BrentDouglas commented 9 years ago

Oh, yeah I see now. I misread this line as being the literal property: https://github.com/WASdev/standards.jsr352.jbatch/blob/fc09f8dec9826ca56981fba2dbd43c1d6c411077/com.ibm.jbatch.spi/src/main/java/com/ibm/jbatch/spi/ServiceRegistry.java#L160

seckin206 commented 9 years ago

I changed the line into this : -DJOBXML_LOADER_SERVICE=com.ibm.jbatch.container.services.impl.DirectoryJobXMLLoaderServiceImpl

Still getting the same error.

scottkurz commented 9 years ago

Hmm... can you collect server logs in GF with:

com.ibm.jbatch.container.level=FINEST

This seems to be the latest hit on how to do that in general: http://docs.oracle.com/cd/E18930_01/html/821-2416/abluk.html

seckin206 commented 9 years ago

https://gist.github.com/seckin206/2c9dc64c34fc9ec5c37e

Isolated run, rather than JVM Options, I now added the respective options to "System Properties". No changes in behaviour.

seckin206 commented 9 years ago

screenshot from 2015-09-11 00 31 29

seckin206 commented 9 years ago

BTW, you have mentioned about JSL_DIR here:

http://stackoverflow.com/questions/19904750/jsr-352-dynamic-job-loading

scottkurz commented 9 years ago

(Edited a 2nd time as I realized the confusion Brent and I each had).

I'm sorry, I was wrong. @BrentDouglas was closer (and I appreciate you answering) but was a bit off as well.

The JVM property should be:

_-Dcom.ibm.jbatch.spi.ServiceRegistry.JOBXML_LOADER_SERVICE=com.ibm.jbatch.container.services.impl.DirectoryJobXMLLoaderServiceImpl_

So @seckin206, can you please go back to that property value and see if it works. If not, collect the same trace? (Hopefully we have enough logging in this code for this to be useful. Let's give it a shot.)

FWIW, I'd gotten confused between the SPI properties and the JVM system properties.

As you see here:

https://github.com/WASdev/standards.jsr352.jbatch/blob/00a487cdde32a7477263dd4b659d9470b5ed8deb/com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/servicesmanager/ServicesManagerImpl.java#L105-L108

the sequence is to configure with the properties files embedded in the JAR, then override with the SPI, then override again with the JVM props. In the SPI, we use shorter prop names, which has a logic to it.

And BTW, I didn't have any extra information in that SO post. I was just offering to help walk through it like we're doing now.

seckin206 commented 6 years ago

This issue is no longer valuable for me, I hope discussion so far can help the readers in future.