Support Questions

Find answers, ask questions, and share your expertise
Celebrating as our community reaches 100,000 members! Thank you!

ERROR tool.ImportTool: Import failed: Could not load jar /tmp/sqoop-root/ ....


I run the following sqoop merge import


sudo sqoop import \
--connect 'jdbc:sqlserver://\test_server;database=Training' \
--username Training_user --password Training_user \
--table BigDataTest -m 1 \
--check-column lastmodified \
--merge-key id \
--incremental lastmodified \
--compression-codec=snappy \
--as-parquetfile \
--target-dir /user/hive/warehouse \
--hive-table bigDataTest \
--last-value '2019-05-06 15:07:49.917'

I get this


19/05/09 11:00:50 INFO tool.ImportTool: Final destination exists, will run merge job. 19/05/09 11:00:50 ERROR tool.ImportTool: Import failed: Could not load jar /tmp/sqoop-root/compile/e913f7c459cf4e1cdb8a8d5802f1dac2/codegen_BigDataTest.jar into JVM. (Cou
ld not find class BigDataTest.) at org.apache.sqoop.util.ClassLoaderStack.addJarFile( at com.cloudera.sqoop.util.ClassLoaderStack.addJarFile( at org.apache.sqoop.tool.ImportTool.loadJars( at org.apache.sqoop.tool.ImportTool.lastModifiedMerge( at org.apache.sqoop.tool.ImportTool.importTable( at at at at org.apache.sqoop.Sqoop.runSqoop( at org.apache.sqoop.Sqoop.runTool( at org.apache.sqoop.Sqoop.runTool( at org.apache.sqoop.Sqoop.main( Caused by: java.lang.ClassNotFoundException: BigDataTest at$ at$ at Method) at at java.lang.ClassLoader.loadClass( at at java.lang.ClassLoader.loadClass( at java.lang.Class.forName0(Native Method) at java.lang.Class.forName( at org.apache.sqoop.util.ClassLoaderStack.addJarFile( ... 11 more

why? and how I can fix it ?



I found this resolution elsewhere:


    The problem is resolved after i copied the .class file from /tmp/sqoop-hduser/compile/ to hdfs /home/hduser/ and also the current working directory from where i am running sqoop.


In case that does not work, this should help you get moving:


Specify the --bindir where the compiled code and .jar file should be located.

Without these arguments, Sqoop would place the generated Java source file in your current working directory and the compiled .class file and .jar file in /tmp/sqoop-<username>/compile.


With an example:

sqoop import --bindir ./ --connect jdbc:mysql://localhost/hadoopguide --table widgets


- Dennis Jaheruddin

If this answer helped, please mark it as 'solved' and/or if it is valuable for future readers please apply 'kudos'.