Pivotal Cloud Flow 上的 Apache Drill 部署

Apache Drill Deployment on Pivotal Cloud Flow

我已经使用 Apache Drill 创建了一个 spring-boot maven 项目,我能够成功地从文件中查询数据。当我尝试在 PCF 上部署项目时,每次我的实例崩溃时都会显示多个 slf4j 绑定。

@SpringBootApplication
public class Drill {
    static final String JDBC_DRIVER = "org.apache.drill.jdbc.Driver";
    public static final String DRILL_JDBC_LOCAL_URI = "jdbc:drill:drillbit=xx.xx.xxx.xx;

    public static void main(String[] args) throws IOException {
        SpringApplication.run(Drill.class, args);
        boolean result = false;
        try {
            result = sqlResult();
        } catch (FileNotFoundException e) {
            //TODO Auto-generated catch block
            e.printStackTrace();
        }
        System.out.println(result);
    }

    public static boolean sqlResult() throws IOException {
        try {
            Class.forName(JDBC_DRIVER);
        } catch (ClassNotFoundException ce) {
            ce.printStackTrace();
        }
        long d = 1;
        try {
            Connection conn = DriverManager.getConnection(DRILL_JDBC_LOCAL_URI, "usrname","passwrd");
            Statement stmt = conn.createStatement();
            String sql = "select * from dfs.`/Users/system.user/Desktop/123.csv`";
            ResultSet rs = stmt.executeQuery(sql);
            long currentTimeMillis = System.currentTimeMillis();
            while (rs.next()) {     
                System.out.println("columns: "+rs.getString(1));
                d++;
            }
            long currentTimeMillisEnd = System.currentTimeMillis();
            System.out.println(" start: "+currentTimeMillis+" end "+currentTimeMillisEnd +" size: "+d);
        rs.close();
        } catch (Exception se) {
            System.out.println("last count is: "+d);
            se.printStackTrace();
        }

        return false;
    }
}

pom.xml:<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.6.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <org.slf4j-version>1.7.5</org.slf4j-version>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
            </exclusion>
            <exclusion>
                <artifactId>jcl-over-slf4j</artifactId>
                <groupId>org.slf4j</groupId>
            </exclusion>
            <exclusion>
                <artifactId>jul-to-slf4j</artifactId>
                <groupId>org.slf4j</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>         
    </dependency>
     <dependency>
        <groupId>org.apache.drill.exec</groupId>
        <artifactId>drill-jdbc-all</artifactId>
        <version>1.1.0</version>
        <exclusions>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
            </exclusion>
            <exclusion>
                <artifactId>jcl-over-slf4j</artifactId>
                <groupId>org.slf4j</groupId>
            </exclusion>
            <exclusion>
                <artifactId>jul-to-slf4j</artifactId>
                <groupId>org.slf4j</groupId>
            </exclusion>
        </exclusions>
    </dependency>   
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-core</artifactId>
        <version>0.20.2</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

这是我收到的错误消息:

[ERR] SLF4J: Class path contains multiple SLF4J bindings.
[ERR] SLF4J: Found binding in [jar:file:/home/vcap/app/BOOT-INF/lib/drill-jdbc-all-1.1.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
[ERR] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
[ERR] SLF4J: Found binding in [jar:file:/home/vcap/app/BOOT-INF/lib/logback-classic-1.1.11.jar!/org/slf4j/impl/StaticLoggerBinder.class]
[ERR] SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
[ERR] Exception in thread "main" java.lang.reflect.InvocationTargetException
[ERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERR] at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
[ERR] at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
[ERR] at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
[ERR] Caused by: java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.ObjectMapper.readValue(Ljava/lang/String;Lcom/fasterxml/jackson/core/type/TypeReference;)Ljava/lang/Object;
[ERR] at org.springframework.boot.SpringApplication.run(SpringApplication.java:296)
[ERR] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
[ERR] at pack.drill.Drill.main(Drill.java:26)

我尝试了网上所有可能的帮助,但我无法找出问题所在。我不明白为什么它在本地环境中工作得很好,为什么它甚至没有部署在 PCF 上。

crashed stating multiple slf4j bindings

那不是崩溃。

这是

NoSuchMethodError: com.fasterxml.jackson.databind.ObjectMapper.readValue

您的部署中缺少 Jackson 数据绑定库。

尝试制作包含

的 Uber JAR
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>some_verion_here</version>
</dependency>

2 个月前我也遇到过类似的异常并发布了很多问题,问题是它不是由于任何编码异常引起的。这是由于您组织的安全组阻止了演练访问。 联系你对应的 pcf 团队,让他们添加所需的安全组。