2

I'm currently trying to install Apache Arrow for Java in Eclipse and having some troubles.

I've found the Java Packages on https://search.maven.org/search?q=g:org.apache.arrow%20AND%20v:0.17.1

Because I didn't find any information about the installation, I just downloaded all the jar files:

  • arrow-peformance-0.17.1.jar
  • arrow-algorithm-0.17.1.jar
  • arrow-avro-0.17.1.jar
  • flight-grpc-0.17.1.jar
  • flight-core-0.17.1.jar
  • arrow-plasma-0.17.1.jar
  • arrow-jdbc-0.17.1.jar
  • arrow-tools-0.17.1.jar
  • arrow-vector-0.17.1.jar
  • arrow-memory-0.17.1.jar
  • arrow-format-0.17.1.jar

I then created a new Java project in Eclipse and copied all the jar files into a folder 'lib' in said project. Then, I added them under Project -> Properties -> Java Build Path -> Libraries -> Add JARs and selected all the jars in my 'lib' folder and applied.

After that, I tried to run the following java-code which I found on https://github.com/animeshtrivedi/blog/blob/master/post/2017-12-26-arrow.md:

import org.apache.arrow.vector.types.pojo.*;

public class FieldTesting {
    public static void main(String[] args) {
        Field intField = new Field("int", FieldType.nullable(new ArrowType.Int(32, true)), null);
    }
}

I get the following error message:

Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
    at org.apache.arrow.vector.types.pojo.Field.<clinit>(Field.java:55)
    at FieldTesting.main(FieldTesting.java:6)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 2 more

When I go to Referenced Libraries -> arrow-vector-0.17.1.jar -> org.apache.arrow.vector.types.pojo -> Field.class, it says "Source not found" as seen below. Do I need to attach the source manually? enter image description here

On the Apache Arrow website, where I downloaded the jar files, there were also "...sources.jar" files which I could download. Do I need to also download those and add them to the "Java Build Path"? (That seems like a lot of work).

There was also a "arrow-java-root" zip folder, can I somehow use this to add the library?


I'm not familiar with adding libraries to Java, so I don't know how to fix this. Any help is appreciated.

(I am on Windows 10, java 8)


Solution:

I converted my Project to a Maven Project (Configure -> Convert to Maven Project) and added the dependency "arrow-java-root". (https://stackoverflow.com/a/26350902) Thanks to andrewjames for pointing this out.

However, I now get the following message when I run the program:

ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.

But the program still terminates correctly, because if I add:

System.out.println(intField.toString())

It prints the field after the message above.

G.M
  • 530
  • 4
  • 20
  • 1
    The exception is nothing to do with not having the source - you don't need source to run compiled code in jars. It looks like Apache Arrow needs the slf4j logging jars. – greg-449 May 21 '20 at 16:29
  • 1
    I recommend using Maven (bundled with Eclipse) to take care of your project dependencies for you. See [here](https://stackoverflow.com/questions/9164893/how-do-i-add-a-maven-dependency-in-eclipse) for some pointers. – andrewJames May 21 '20 at 16:43
  • @andrewjames Thanks, I converted my Project to a Maven Project and added the dependency "arrow-java-root". It seems to be working now :) – G.M May 21 '20 at 18:02

1 Answers1

1

The message you get is because you don't have a log4j2 configuration file, and the logger is warning you about this, so it is going to use a default one, if you want to get rid of that message, you can create a log4j2.xml file in your src/main/resources folder with the following

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
  <Appenders>
    <Console name="Console" target="SYSTEM_OUT">
      <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
    </Console>
  </Appenders>
  <Loggers>
    <Root level="error">
      <AppenderRef ref="Console"/>
    </Root>
  </Loggers>
</Configuration>

you can read more about configuring log4j here

petrubear
  • 616
  • 5
  • 6