sqoop-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cheolsoo Park (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (SQOOP-480) MS SQL server connector is incompatible with Sqoop-1.4
Date Fri, 01 Jun 2012 22:26:23 GMT

    [ https://issues.apache.org/jira/browse/SQOOP-480?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13287740#comment-13287740
] 

Cheolsoo Park commented on SQOOP-480:
-------------------------------------

After having a discussion with Bilung, I wrote a simpler test case that reproduces the issue
of this jira. I'd like to see if anyone has better suggestions on this problem:

1. I define class Foo and Bar in package Name1 and Name2 and export them as _Jar1.jar_:

{code:title=Name1.Foo}
package Name1;

public class Foo {
  protected Bar b;

  public Name1.Bar getBar() {
    return b;
  }

  public void setBar(Name1.Bar b) {
    this.b = b;
  }
}
{code}

{code:title=Name1.Bar}
package Name1;

public class Bar {

}
{code}

{code:title=Name2.Foo}
package Name2;

public class Foo extends Name1.Foo {

  public Name2.Bar getBar() {
    return (Name2.Bar)b;
  }
}
{code}

{code:title=Name2.Bar}
package Name2;

public class Bar extends Name1.Bar {

}
{code}

2. I also define Foo and Bar in package Name2 and export them as _Jar2.jar_:

{code:title=Name2.Foo}
package Name2;

public class Foo {
  protected Name2.Bar b;

  public Name2.Bar getBar() {
    return b;
  }

  public void setBar(Name2.Bar b) {
    this.b = b;
  }
}
{code}

{code:title=Name2.Bar}
package Name2;

public class Bar {

}
{code}

3. I compile the following Main class against _Jar2.jar_ and export it as _Test.jar_.

{code}
public class Main {

  public static void main(String[] args) {

    Name2.Foo name2Foo = new Name2.Foo();
    Name2.Bar name2Bar = new Name2.Bar();

    name2Foo.setBar(name2Bar);
    Name2.Bar b = name2Foo.getBar();

    System.out.println(b.toString());
  }

}
{code}

4. Now I run Main with the following command:

{code}
java -jar Test.jar
{code}

This works if _Jar2.jar_ is in classpath (not surprising since it is compiled against _Jar2.jar_),
but it doesn't work if _Jar1.jar_ is in classpath. Specifically, it fails with the following
error:

{code}
Exception in thread "main" java.lang.NoSuchMethodError: Name2.Foo.setBar(LName2/Bar;)V
	at Main.main(Main.java:9)
{code}

What's interesting is that Name2.Foo inherits _setBar(LName2/Bar;)V_ from Name1.Foo, so _setBar(LName2/Bar;)V_
should be visible in Name2.Foo. However, this doesn't seem to happen if Test.java is compiled
against _Jar2.jar_ and run with _Jar1.jar_.

Obviously, the easiest and safest way to fix is to re-compile Test.java against _Jar1.jar_.
But it may be not always feasible if Test.java is 3rd-party software (In this jira, Test.java
is Microsoft Sqoop connector).

Another workaround that I implemented in my patch is to explicitly define _Name2.Foo.setBar(Name2.Bar
b)_ in _Jar1.jar_ as follows:

{code}
public void setBar(Name2.Bar b) {
  super.setBar((Name1.Bar)b);
}
{code}

Note that _Name2.Foo.getBar()_ in _Jar1.jar_ must be defined regardless because the return
type of _Name1.Foo.getBar()_ is Name1.Bar while that of _Name2.Foo.getBar()_ is Name2.Bar,
and Name1.Bar cannot be auto-cast to Name2.Bar. But _Name2.Foo.setBar(Name2.Bar b)_ is somewhat
redundant because Name2.Bar can be auto-cast to Name1.Bar.

Thoughts?
                
> MS SQL server connector is incompatible with Sqoop-1.4
> ------------------------------------------------------
>
>                 Key: SQOOP-480
>                 URL: https://issues.apache.org/jira/browse/SQOOP-480
>             Project: Sqoop
>          Issue Type: Bug
>            Reporter: Cheolsoo Park
>            Assignee: Cheolsoo Park
>         Attachments: SQOOP-480.patch
>
>
> Sqoop import fails with the following error message:
> 12/04/27 09:29:16 INFO orm.CompilationManager: Writing jar file: /tmp/sqoop-hadoop/compile/
> 45d0bca50cb78c50c20acf18fcd64f90/QualityMeasure.jar
> Exception in thread "main" java.lang.NoSuchMethodError: com.cloudera.sqoop.manager.ImportJobContext.setConnManager(Lcom/cloudera/sqoop/manager/ConnManager;)V
>     at com.microsoft.sqoop.SqlServer.MSSQLServerManager.importTable(MSSQLServerManager.java:142)
>     at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:380)
>     at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:453)
>     at org.apache.sqoop.Sqoop.run(Sqoop.java:145)
>     at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)
>     at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:181)
>     at org.apache.sqoop.Sqoop.runTool(Sqoop.java:220)
>     at org.apache.sqoop.Sqoop.runTool(Sqoop.java:229)
>     at org.apache.sqoop.Sqoop.main(Sqoop.java:238)
>     at com.cloudera.sqoop.Sqoop.main(Sqoop.java:57)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message