1

I'm new to Liberty and am trying out the Batch (352) functionality. I can't find this as having been asked, either through search engines or stackoverflow, so I'm apparently missing something blatantly obvious...

I've created a simple test application in Liberty 8.5.5.9. It has the structure:

  • testbatchEAR
    • testbatchWAR
      • testbatchBatch

The EAR has been added to the server through the usual Add/Remove menu pick.

I'm now trying to submit the job from the command line using:

batchManager submit --batchManager=localhost:9443 --user=<> --password=<> --trustSslCertificates --jobXMLName=TestProcessor.xml --applicationName=testbatch

And I get back a message (truncated):

Error: Server returned HTTP response code: 500 for URL: https://localhost:9443/ibm/api/batch/jobinstances: [Error 500:  com.ibm.ws.jbatch.rest.bridge.BatchContainerAppNotFoundException: Failed to load the application context for application testbatch#testbatch.war. Verify the application is installed.

I've tried testbatch, testbatchEAR, testbatchWAR, but from the "testbatch#testbatch.war" part of the message, it looks like it just uses the same name for both EAR and WAR, which I don't think is possible, is it?

What part of this am I missing? It must be right in front of my face, but every example or solution I find is using a naked WAR, which I can't do. Is there anywhere in liberty where I can find the application name? Should I be defining the names somewhere (server.xml?)?

Thanks in advance!

* Edit: Additional Information *

If I run it from the Eclipse Run Configurations > Java EE Batch Job section, it does run it, and doing a batchManager listJobs shows the application name as testbatchEAR#testbatchWAR.war.

So I guess the real question I have, is how can I put this name into the --applicationName option of batchManager.bat? It takes and makes #.war out of it. I've tried putting the full name from listJobs, but it won't allow a '#' character...

Scott Kurz
  • 4,985
  • 1
  • 18
  • 40
Mike
  • 159
  • 10
  • what does the `` or `` element in your server.xml look like? – Andy Guibert Sep 01 '16 at 13:35
  • @aguibert . This starts the application normally. If I try to change the name, suddenly it can't find the ear in the location. – Mike Sep 01 '16 at 13:56
  • I believe you need to specify applicationName of the EAR and component name (with the --componentName parameter) of the WAR file. From the help, componentName " Identifies an EJB component within the batch application EJB module." – DFollis Sep 01 '16 at 14:52
  • @DFollis Unfortunately, that skips a level, and is additionally an odd help message since the Batch project that is created is actually a utility project! However the output caused me to look closer at the help docs and I was apparently skipping --moduleName. Adding --moduleName=testbatchWAR.war produced the correct name testbatchEAR#testbatchWAR.war and let me submit! Since it was your input that led me there, if you want to put the --moduleName info as an answer, I'll accept it. – Mike Sep 01 '16 at 16:00

1 Answers1

0

Specify both --applicationName and --moduleName in an EAR application

(As you discovered), in a case in which the batch application is packaged within a WAR within an EAR you will typically have to specify both --applicationName and --moduleName, e.g.:

batchManager submit --batchManager=localhost:9443 ... --applicationName=testbatch --moduleName=testbatchWAR.war ...

Specify just --applicationName in a WAR application

You may have seen examples though in which only the --applicationName is needed, e.g. here.

This syntax works in the case that the batch application is packaged as a WAR (but not a WAR within an EAR).

The "utility project" name here is not relevant, and there is no EJB so there is no --componentName relevant either.

The doc does mention this here in the section:

POST /ibm/api/batch/jobinstances

...

The applicationName identifies the batch application. It is required unless moduleName is specified, in which case the applicationName is derived from the moduleName by trimming off the .war or .jar suffix of the moduleName. For example, if you provide no applicationName and moduleName=SimpleBatchJob.war, then applicationName defaults to SimpleBatchJob.

The moduleName identifies the module within the batch application that contains the job artifacts, such as the JSL. The job is submitted under the module's component context. The moduleName is required unless applicationName is specified, in which case the moduleName is derived from the applicationName by appending .war to the applicationName. For example, if you provide applicationName=SimpleBatchJob and no moduleName, then moduleName defaults to SimpleBatchJob.war.

But if you're creating both a Web project and an EAR project in a tool like WDT, you're not going to easily be able to give the projects the same names (since they'll collide), so this really only works well in the case that there's not a separate EAR project. When the EAR project exists, you need both parameters.

Community
  • 1
  • 1
Scott Kurz
  • 4,985
  • 1
  • 18
  • 40