question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error accessing transitive dependencies via %maven

See original GitHub issue

So I am working on the DFLib Jupyter integration per https://github.com/nhl/dflib/issues/44 . It mostly works well. Found one problem though. I am including all the DFLib modules as “compile” dependencies of “dflib-jupyter” , so I assumed I can only specify %maven com.nhl.dflib:dflib-jupyter:0.6-SNAPSHOT once, and get all of them. Apparently not. Here is a screenshot where Jupyter fails to import a package from one of the dependencies:

image

Oddly enough, when instead of importing “com.nhl.dflib”, I import “com.nhl.dflib.jdbc” package (from another module), the error is NoClassDefFound on the core DFLib package… So it seems to be ok with jdbc import, but still can’t find the core library.

image

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
andruscommented, Jun 11, 2019

School has taken priority as of lately and as a result I haven’t had much free time to work on IJava and friends other than try and keep up with replying to issues. So please don’t take the recent lack of progress as lack of interest in maintaining the project.

No worries. As a long time open source developer I can relate.

Could you try marking the basekernel with the provided scope?

This solved the second issue - the conflict between 2 notebooks. It no longer appears.

0reactions
karussellcommented, Jul 28, 2020

Thanks for providing this nice tool. I also got my small Java test working, but stumble over a very similar problem that is described here when doing the following:

%maven com.graphhopper:graphhopper-core:1.0
%maven com.graphhopper:graphhopper-reader-osm:1.0
%maven com.carrotsearch:hppc:0.8.1
%maven org.slf4j:slf4j-api:1.7.30
%maven org.slf4j:slf4j-log4j12:1.7.30
%maven log4j:log4j:1.2.17

import com.graphhopper.*;
import com.graphhopper.config.*;
import com.graphhopper.util.*;
import com.graphhopper.reader.osm.*;
import com.graphhopper.routing.util.*;

if(!new File("osm.pbf").exists()) {
  System.out.println("download OpenStreetMap data ...");
  new Downloader("GraphHopper Downloader").downloadFile("http://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf", "osm.pbf");
}

System.out.println("start importOrLoad ...");
GraphHopper hopper = new GraphHopperOSM().
    setOSMFile("osm.pbf").
    setProfiles(Collections.singletonList(new Profile("car").setVehicle("car").setWeighting("fastest"))).
    setEncodingManager(EncodingManager.create("car")).
    setGraphHopperLocation("graph-cache").
    importOrLoad();

GHResponse rsp = hopper.route(new GHRequest(52.532932,13.341522, 52.503684,13.404694).setProfile("car"));
if(rsp.hasErrors())
    throw new RuntimeException(rsp.getErrors().get(0));
ResponsePath best = rsp.getBest();
System.out.println("distance " + best.getDistance());

I sometimes get errors that a certain class is missing although it should be included from one of the %maven statements. E.g.:

java.lang.NoClassDefFoundError: org/apache/log4j/Level

or

java.lang.NoClassDefFoundError: com/carrotsearch/hppc/IntLookupContainer

or

java.lang.IllegalStateException: org.slf4j.LoggerFactory in failed state. Original exception was thrown EARLIER. See also http://www.slf4j.org/codes.html#unsuccessfulInit
	at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:427)

Sometimes it affects the last %maven statement. Not sure if it helps but this was (sometimes) reproducible at mybinder.org.

And one time I was able to remove such an error when I switched from %%loadFromPOM to %maven but it does not disappear now and is also permanent even if I restart my system. Is there a way to “restart from scratch”?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Maven transitive dependencies - Stack Overflow
The reason for failure in transitive dependency is the project in which we are dependent inherits the jar from custom path rather than...
Read more >
Maven dependencies | IntelliJ IDEA Documentation - JetBrains
Open the dependency POM and find the transitive dependency you want to exclude. Copy groupId and artifactId . In your project POM, underneath ......
Read more >
Maven – Optional Dependencies and Dependency Exclusions
For example, a certain older jar may have security issues or be incompatible with the Java version you're using. To address this, Maven...
Read more >
Downgrading versions and excluding dependencies
Forcing a version of a dependency requires a conscious decision. Changing the version of a transitive dependency might lead to runtime errors if...
Read more >
How to resolve transitive dependency problem on maven java ...
The maven way of resolving situations like this is to include this. In this scenario if I run project A, Maven will correctly...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found