Sqoop
  1. Sqoop
  2. SQOOP-338

NPE after specifying incorrect JDBC credentials

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.4.0-incubating
    • Component/s: None
    • Labels:
      None
    • Environment:

      Sqoop 1.2.0-cdh3u0
      git commit id 455acc8dee10b6a3579358cccc3635241076391b
      Compiled by hudson@ubuntu-slave02 on Fri Mar 25 16:25:35 PDT 2011

      Description

      I tried to do a sqoop import but forgot to specify a username and password. The command line used was:

      sqoop import --connect jdbc:mysql://localhost/training --hive-import --table Movies
      

      This resulted in an NPE being logged.

        Activity

        Hide
        Todd Lipcon added a comment -
        [training@localhost ml-data]$ sqoop import --connect jdbc:mysql://localhost/training --hive-import --table Movies
        11/09/15 13:43:21 INFO tool.BaseSqoopTool: Using Hive-specific delimiters for output. You can override
        11/09/15 13:43:21 INFO tool.BaseSqoopTool: delimiters with --fields-terminated-by, etc.
        11/09/15 13:43:21 INFO tool.CodeGenTool: Beginning code generation
        11/09/15 13:43:21 ERROR manager.SqlManager: Error executing statement: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user ''@'localhost' to database 'training'
        11/09/15 13:43:21 ERROR manager.SqlManager: Error executing statement: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user ''@'localhost' to database 'training'
        com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user ''@'localhost' to database 'training'
                at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
                at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
                at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
                at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
                at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
                at com.mysql.jdbc.Util.getInstance(Util.java:386)
                at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052)
                at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)
                at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)
                at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:935)
                at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4101)
                at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1300)
                at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2337)
                at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2370)
                at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2154)
                at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:792)
                at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
                at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
                at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
                at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
                at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
                at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
                at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)
                at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
                at java.sql.DriverManager.getConnection(DriverManager.java:582)
                at java.sql.DriverManager.getConnection(DriverManager.java:207)
                at com.cloudera.sqoop.manager.SqlManager.makeConnection(SqlManager.java:604)
                at com.cloudera.sqoop.manager.GenericJdbcManager.getConnection(GenericJdbcManager.java:51)
                at com.cloudera.sqoop.manager.MySQLManager.execute(MySQLManager.java:201)
                at com.cloudera.sqoop.manager.SqlManager.getColumnNamesForRawQuery(SqlManager.java:112)
                at com.cloudera.sqoop.manager.SqlManager.getColumnNames(SqlManager.java:96)
                at com.cloudera.sqoop.orm.ClassWriter.generate(ClassWriter.java:924)
                at com.cloudera.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:82)
                at com.cloudera.sqoop.tool.ImportTool.importTable(ImportTool.java:337)
                at com.cloudera.sqoop.tool.ImportTool.run(ImportTool.java:423)
                at com.cloudera.sqoop.Sqoop.run(Sqoop.java:144)
                at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)
                at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:79)
                at com.cloudera.sqoop.Sqoop.runSqoop(Sqoop.java:180)
                at com.cloudera.sqoop.Sqoop.runTool(Sqoop.java:218)
                at com.cloudera.sqoop.Sqoop.main(Sqoop.java:228)
        11/09/15 13:43:21 ERROR sqoop.Sqoop: Got exception running Sqoop: java.lang.NullPointerException
        java.lang.NullPointerException
                at com.cloudera.sqoop.orm.ClassWriter.cleanColNames(ClassWriter.java:889)
                at com.cloudera.sqoop.orm.ClassWriter.generate(ClassWriter.java:951)
                at com.cloudera.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:82)
                at com.cloudera.sqoop.tool.ImportTool.importTable(ImportTool.java:337)
                at com.cloudera.sqoop.tool.ImportTool.run(ImportTool.java:423)
                at com.cloudera.sqoop.Sqoop.run(Sqoop.java:144)
                at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)
                at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:79)
                at com.cloudera.sqoop.Sqoop.runSqoop(Sqoop.java:180)
                at com.cloudera.sqoop.Sqoop.runTool(Sqoop.java:218)
                at com.cloudera.sqoop.Sqoop.main(Sqoop.java:228)
        
        Show
        Todd Lipcon added a comment - [training@localhost ml-data]$ sqoop import --connect jdbc:mysql://localhost/training --hive-import --table Movies 11/09/15 13:43:21 INFO tool.BaseSqoopTool: Using Hive-specific delimiters for output. You can override 11/09/15 13:43:21 INFO tool.BaseSqoopTool: delimiters with --fields-terminated-by, etc. 11/09/15 13:43:21 INFO tool.CodeGenTool: Beginning code generation 11/09/15 13:43:21 ERROR manager.SqlManager: Error executing statement: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user ''@'localhost' to database 'training' 11/09/15 13:43:21 ERROR manager.SqlManager: Error executing statement: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user ''@'localhost' to database 'training' com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user ''@'localhost' to database 'training' at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) at com.mysql.jdbc.Util.getInstance(Util.java:386) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:935) at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4101) at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1300) at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2337) at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2370) at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2154) at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:792) at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305) at java.sql.DriverManager.getConnection(DriverManager.java:582) at java.sql.DriverManager.getConnection(DriverManager.java:207) at com.cloudera.sqoop.manager.SqlManager.makeConnection(SqlManager.java:604) at com.cloudera.sqoop.manager.GenericJdbcManager.getConnection(GenericJdbcManager.java:51) at com.cloudera.sqoop.manager.MySQLManager.execute(MySQLManager.java:201) at com.cloudera.sqoop.manager.SqlManager.getColumnNamesForRawQuery(SqlManager.java:112) at com.cloudera.sqoop.manager.SqlManager.getColumnNames(SqlManager.java:96) at com.cloudera.sqoop.orm.ClassWriter.generate(ClassWriter.java:924) at com.cloudera.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:82) at com.cloudera.sqoop.tool.ImportTool.importTable(ImportTool.java:337) at com.cloudera.sqoop.tool.ImportTool.run(ImportTool.java:423) at com.cloudera.sqoop.Sqoop.run(Sqoop.java:144) at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65) at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:79) at com.cloudera.sqoop.Sqoop.runSqoop(Sqoop.java:180) at com.cloudera.sqoop.Sqoop.runTool(Sqoop.java:218) at com.cloudera.sqoop.Sqoop.main(Sqoop.java:228) 11/09/15 13:43:21 ERROR sqoop.Sqoop: Got exception running Sqoop: java.lang.NullPointerException java.lang.NullPointerException at com.cloudera.sqoop.orm.ClassWriter.cleanColNames(ClassWriter.java:889) at com.cloudera.sqoop.orm.ClassWriter.generate(ClassWriter.java:951) at com.cloudera.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:82) at com.cloudera.sqoop.tool.ImportTool.importTable(ImportTool.java:337) at com.cloudera.sqoop.tool.ImportTool.run(ImportTool.java:423) at com.cloudera.sqoop.Sqoop.run(Sqoop.java:144) at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65) at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:79) at com.cloudera.sqoop.Sqoop.runSqoop(Sqoop.java:180) at com.cloudera.sqoop.Sqoop.runTool(Sqoop.java:218) at com.cloudera.sqoop.Sqoop.main(Sqoop.java:228)
        Hide
        Brock Noland added a comment -

        Attached is a patch which handles the NPE in ClassWriter and AvroSchemaGenerator.

        However, I do wonder if ConnManager.getColumnNames* shouldn't just throw an exception as opposed to returning null if an error is thrown?

        Show
        Brock Noland added a comment - Attached is a patch which handles the NPE in ClassWriter and AvroSchemaGenerator. However, I do wonder if ConnManager.getColumnNames* shouldn't just throw an exception as opposed to returning null if an error is thrown?
        Hide
        Brock Noland added a comment -

        This is resolved in trunk.

        Show
        Brock Noland added a comment - This is resolved in trunk.

          People

          • Assignee:
            Brock Noland
            Reporter:
            Todd Lipcon
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development