NEO
NEO

Reputation: 399

SPRING XD -SQOOP JOB FAILED due to invalid arguments

We are trying to ingest data from sql server to hdfs using sqoop job as a module of spring xd.

When I tried running the following command using xd - shell of spring xd tool:

sqoop --command=import --args='--connect 'jdbc:sqlserver://localhost/mydb'  
--username root --password p@ss --query select * from tablename  
--target-dir /path/to/hdfs/file'

I get the following error while launching the job from spring xd shell as a sqoop job:

sqoop.errors

Try --help for usage instructions.
Exception in thread "main" java.lang.RuntimeException: Sqoop failed - return code 1
at org.springframework.xd.sqoop.SqoopRunner.main(SqoopRunner.java:81)

more errors

19:38:40,556 ERROR main tool.BaseSqoopTool - Error parsing arguments for import:
19:38:40,556 ERROR main tool.BaseSqoopTool - Unrecognized argument: '--connect
19:38:40,556 ERROR main tool.BaseSqoopTool - Unrecognized argument: 'jdbc:sqlserver://localhost/mydb'
19:38:40,556 ERROR main tool.BaseSqoopTool - Unrecognized argument: --username
19:38:40,557 ERROR main tool.BaseSqoopTool - Unrecognized argument: root
19:38:40,557 ERROR main tool.BaseSqoopTool - Unrecognized argument: --password
19:38:40,557 ERROR main tool.BaseSqoopTool - Unrecognized argument: p@ss
19:38:40,557 ERROR main tool.BaseSqoopTool - Unrecognized argument: --query
19:38:40,557 ERROR main tool.BaseSqoopTool - Unrecognized argument: select
19:38:40,557 ERROR main tool.BaseSqoopTool - Unrecognized argument: *
19:38:40,557 ERROR main tool.BaseSqoopTool - Unrecognized argument: from
19:38:40,557 ERROR main tool.BaseSqoopTool - Unrecognized argument: tablename
19:38:40,557 ERROR main tool.BaseSqoopTool - Unrecognized argument: --target-dir
19:38:40,557 ERROR main tool.BaseSqoopTool - Unrecognized argument: /path/to/hdfs/file'  

exit description :

java.lang.IllegalStateException: Step execution failed - Exception in thread "main" java.lang.RuntimeException: Sqoop failed - return code 1
at org.springframework.batch.step.tasklet.x.AbstractProcessBuilderTasklet.execute(AbstractProcessBuilderTasklet.java:209)

I also tried putting = after arguments but obtained same results.

Why?

Upvotes: 1

Views: 557

Answers (1)

SomethingDark
SomethingDark

Reputation: 14325

You've got single quotes inside of single quotes, which is splitting your command into

sqoop --command=import --args='--connect '
jdbc:sqlserver://localhost/mydb
'--username root --password p@ss --query select * from tablename --target-dir /path/to/hdfs/file'

since --connect isn't a valid argument by itself, you're getting an error.

You can either escape the single quotes, like this: sqoop --command=import --args='--connect \'jdbc:sqlserver://localhost/mydb\' --username root --password p@ss --query select * from tablename --target-dir /path/to/hdfs/file'

or you should also be able to use double quotes around the args section instead of single quotes, like this: sqoop --command=import --args="--connect 'jdbc:sqlserver://localhost/mydb' --username root --password p@ss --query select * from tablename --target-dir /path/to/hdfs/file"

Upvotes: 0

Related Questions