2

I have a batch job with takes 2 parameters. when I pass these arguments while running the jar file directly, it works. Also when i pass these arguments via the shell of the spring cloud dataflow it works:

dataflow:>task launch --name adv-load --arguments "appnexus_seat=SEAT_MIQ_1 last_modified=2018/08/10"
Launched task 'adv-load'

But when I pass the similar arguments while running the task form the UI, it fails. Example, In the UI, i passed: appnexus_seat & last_modified as 2 keys with the same values as above but a different date so that it doesnt think its the same job. This failed.

I did however manage to find the issue. When i run the task via shell, in the logs I get this:

2018-09-21 14:04:50.970  INFO 4035 --- [           main] o.s.b.a.b.JobLauncherCommandLineRunner   : Running default command line with: [appnexus_seat=SEAT_MIQ_1, last_modified=2018/08/10, --spring.cloud.task.executionid=5]
2018-09-21 14:04:51.073  INFO 4035 --- [           main] o.s.b.c.l.support.SimpleJobLauncher      : Job: [FlowJob: [name=advertiserLoadJob]] launched with the following parameters: [{appnexus_seat=SEAT_MIQ_1, -spring.cloud.task.executionid=5, last_modified=2018/08/10}]
2018-09-21 14:04:51.081  INFO 4035 --- [           main] o.s.c.t.b.l.TaskBatchExecutionListener   : The job execution id 5 was run within the task execution 5
2018-09-21 14:04:51.116  INFO 4035 --- [           main] o.s.batch.core.job.SimpleStepHandler     : Executing step: [advertiserLoadStep1]

Whereas when i run it via the Ui i get this:

2018-09-21 14:05:57.417  INFO 4924 --- [           main] o.s.b.a.b.JobLauncherCommandLineRunner   : Running default command line with: [appnexus_seat=SEAT_MIQ_1,last_modified=2018/08/10, --spring.cloud.task.executionid=6]
2018-09-21 14:05:57.518  INFO 4924 --- [           main] o.s.b.c.l.support.SimpleJobLauncher      : Job: [FlowJob: [name=advertiserLoadJob]] launched with the following parameters: [{appnexus_seat=SEAT_MIQ_1,last_modified=2018/08/10, -spring.cloud.task.executionid=6}]
2018-09-21 14:05:57.528  INFO 4924 --- [           main] o.s.c.t.b.l.TaskBatchExecutionListener   : The job execution id 6 was run within the task execution 6
2018-09-21 14:05:57.586  INFO 4924 --- [           main] o.s.batch.core.job.SimpleStepHandler     : Executing step: [advertiserLoadStep1]
2018-09-21 14:05:57.653 ERROR 4924 --- [           main] o.s.batch.core.step.AbstractStep         : Encountered an error executing step advertiserLoadStep1 in job advertiserLoadJob

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.advertiserLoadTasklet': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.mediaiq.appnexus.load.client.AppnexusRestClient com.mediaiq.appnexus.batch.tasklet.AbstractPageLoadTasklet.appnexusClient; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'JOB' defined in class path resource [com/mediaiq/appnexus/load/config/AppnexusRestClientFactory.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [com.mediaiq.appnexus.value.AppnexusSeat]: : Failed to convert value of type [java.lang.String] to required type [com.mediaiq.appnexus.value.AppnexusSeat]; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [com.mediaiq.appnexus.value.AppnexusSeat]: no matching editors or conversion strategy found; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert value of type [java.lang.String] to required type [com.mediaiq.appnexus.value.AppnexusSeat]; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [com.mediaiq.appnexus.value.AppnexusSeat]: no matching editors or conversion strategy found

If you look at the difference you can see that when i run it via the shell it gives a space between the 2 arguments whereas when i run it via the Ui its doesn't. Not giving this space results in an issue as the value of the first argument becomes "SEAT_MIQ_1,last_modified=2018/08/10" instead of just being "SEAT_MIQ_1" and last_modified being another argument.

Please let me know how to resolve this. Thanks. :)

Siddhant Sorann
  • 313
  • 3
  • 15

1 Answers1

0

When you run the task from the UI, you need to specify each argument in a separate field:

enter image description here

This will correctly pass parameters to your task.

Mahmoud Ben Hassine
  • 28,519
  • 3
  • 32
  • 50
  • Hey, I have been doing exactly that. Still, it has not been adding a space between arguments but only a comma. – Siddhant Sorann Sep 21 '18 at 10:34
  • I tested my answer with version 1.7.0.M1 and it works fine. Which version of spring cloud data flow are you using? – Mahmoud Ben Hassine Sep 21 '18 at 10:52
  • dataflow server: 1.6.3 – Siddhant Sorann Sep 21 '18 at 11:16
  • Also, when you're running your job with params can you please show me the logs of the execution where it shows you the command line args and job parameters taken? Thanks – Siddhant Sorann Sep 21 '18 at 11:17
  • My task is actually a hello world Spring Batch job that takes 2 parameters `name1` and `name2` and prints: `Hello name1 name2`. Here is the command in the log: `2018-09-21 13:47:41.996 INFO 3982 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : Job: [SimpleJob: [name=job]] launched with the following parameters: [{name2=bar, -spring.cloud.task.executionid=1, name1=foo}]`. I just tested with version 1.6.3.RELEASE and it works as expected too. – Mahmoud Ben Hassine Sep 21 '18 at 11:51
  • Hey, Thanks a lot. I also tried using v1.7.0.M1 and it worked. I guess it's a bug with the current version. Thanks a lot! – Siddhant Sorann Sep 21 '18 at 12:28
  • @MahmoudBenHassine - How can we always pass the Unique Task Argument programmatically ? This is needed when we run Task through SCDF UI. Any pointers ? Here is original Q : https://stackoverflow.com/questions/61271924/a-job-instance-already-exists-and-is-complete-for-parameters-spring-cloud-task/61272274#61272274 – Jeff Cook Apr 17 '20 at 13:07