0
votes

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.

@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 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)

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.

2

2 Answers

0
votes

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.

0
votes

crashed stating multiple slf4j bindings

That's not the crash.

This is

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

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

Try making an Uber JAR that includes

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