SpencerPark / IJava

A Jupyter kernel for executing Java code.
MIT License
1.07k stars 211 forks source link

'%maven' can't load Avro dependency (packaged as OSGi bundle jar) #117

Open andrus opened 3 years ago

andrus commented 3 years ago
%maven org.apache.avro:avro:1.10.1

The %maven magic above doesn't add Apache Avro library to classpath properly, resulting in an exception like the one below when trying to access any Avro classes.

java.lang.NoClassDefFoundError: org/apache/avro/LogicalType
    at .do_it$Aux(#34:2)
    at .(#34:1)

When I replace that with %%loadFromPOM cell magic, everything works fine:

%%loadFromPOM
<dependency>
    <groupId>org.apache.avro</groupId>
    <artifactId>avro</artifactId>
    <version>1.10.1</version>
</dependency>

%maven works for most jars that I use, except for this one. The only difference that I found is that Ivy treats Avro jar as an OSGi bundle, not a regular jar:

ls -l ~/.ivy2/cache/org.apache.avro/avro/bundles/
total 1152
-rw-r--r--  1 andrus  staff  589142 Nov 18 14:53 avro-1.10.1.jar

I suspect that affects how it calculates the classpath. Suppose the correct behavior would be to do what %%loadFromPOM does - simply add the jar to the classpath, ignoring OSGi specifics.