阅读背景:

Pivotal Cloud Flow上的Apache Drill部署

来源:互联网 

I have created one spring-boot maven project using Apache Drill and I am able to successfully query the data from the file. When I tried to deploy the project on PCF, every time my instance crashed stating multiple slf4j bindings.

我使用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>

This is the error message I get:

这是我收到的错误消息:

[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 https://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)

[错误] SLF4J:类路径包含多个SLF4J绑定。 [ERR] SLF4J:在[jar:file:/home/vcap/app/BOOT-INF/lib/drill-jdbc-all-1.1.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] [找到绑定] ERR] SLF4J:请参阅https://www.slf4j.org/codes.html#multiple_bindings以获得解释。 [ERR] SLF4J:在[jar:file:/home/vcap/app/BOOT-INF/lib/logback-classic-1.1.11.jar!/org/slf4j/impl/StaticLoggerBinder.class] [ERR]中找到绑定SLF4J:实际绑定的类型为[ch.qos.logback.classic.util.ContextSelectorStaticBinder] [ERR]在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)中的线程“main”java.lang.reflect.InvocationTargetException [ERR]中的异常)sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[ERR]在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)[ERR] org.springframework.boot.loader.MainMethodRunner的[ERR] .run(MainMethodRunner.java:48)[ERR] org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)[ERR] org.springframework.boot.loader.Launcher.launch(Launcher.java) :87)[ERR]引起:java.lang.NoSuchMethodError:com.fasterxml.jackson.databind.ObjectMapper.readValue(Ljava / lang / String; Lcom / fasterxml / jackson / core / type / TypeReference;)Ljava / lang /宾语; [ERR] org.springframework.boot.SpringApplication.run(SpringApplication.java:296)[ERR] atg.springframework.boot.SpringApplication.run(SpringApplication.java:1107)[ERR] at pack.drill.Drill。主(Drill.java:26)

I tried all the possible help available on net but I am not able to figure out the issue. I am not understanding why it is working perfectly fine in a local environment and why it is not even deploying on PCF.

我尝试了网上提供的所有可能的帮助,但我无法弄清楚这个问题。我不明白为什么它在本地环境中工作得很好以及为什么它甚至不在PCF上部署。

2 个解决方案

#1


0  

2 months back I too faced the similar exception and posted so many questions, the thing is that it is not due to any coding exception. It is due to the security groups of your organisation which is blocking the drill access. Contact your corresponding pcf team and ask them to add the required security group.

2个月前我也遇到了类似的异常并发布了这么多问题,问题在于它不是由于任何编码异常。这是由于您组织的安全组阻止了钻取访问。联系相应的pcf团队,要求他们添加所需的安全组。

#2


0  

crashed stating multiple slf4j bindings

崩溃声明多个slf4j绑定

That's not the crash.

那不是崩溃。

This is

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

You're missing the Jackson databind libraries in your deployment.

您在部署中缺少Jackson数据库库。

Try making an Uber JAR that includes

尝试制作包含的Uber JAR

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

分享到: