Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An older jar is used instead of the one indicated in %%loadFromPOM #31

Closed
r0x07k opened this issue Aug 15, 2024 · 5 comments
Closed

An older jar is used instead of the one indicated in %%loadFromPOM #31

r0x07k opened this issue Aug 15, 2024 · 5 comments
Labels
bug Something isn't working
Milestone

Comments

@r0x07k
Copy link

r0x07k commented Aug 15, 2024

While debugging the milvus-io/milvus-sdk-java#1040 issue I found out that JJava is using a random jar version for some reason.

Here is the reproduction:

%%loadFromPOM
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.10.1</version>
    </dependency>

import com.google.gson.JsonElement;
import com.google.gson.JsonParser;

String jsonString = "{\"name\":\"John\", \"age\":30}";
// This method is available in Gson 2.8.6 and later
JsonElement jsonElement = JsonParser.parseString(jsonString);
System.out.println(jsonElement);

The error:

|   JsonElement jsonElement = JsonParser.parseString(jsonString);
cannot find symbol
  symbol:   method parseString(java.lang.String)

So, the 2.8.5 or older version is used in fact. The same code works fine if run as a normal Java SE application.

@andrus
Copy link
Contributor

andrus commented Aug 15, 2024

Hi Pavel, thanks for reporting the problem. Feels like one of the many issues with Ivy (the current dependency management engine we inherited from iJava). I'll try to reproduce and see if there's a a fix. On the longer run we'll switch to Maven for this (see #23).

FWIW, there's a somewhat heavy-handed and hackish way to resolve at least some of the dependency issues: rm -rf ~/.ivy2/cache/

@r0x07k
Copy link
Author

r0x07k commented Aug 15, 2024

Hi Andrus,

Thank you for letting me know!

@stariy95 stariy95 added the bug Something isn't working label Aug 16, 2024
@andrus
Copy link
Contributor

andrus commented Aug 16, 2024

Ah, everything is simpler than I thought. The base Jupyter kernel that JJava uses has a transitive dependency on com.google.code.gson:gson:2.8.5, so it can't be redefined in a notebook. I opened #33 to port the base kernel code to JJava and update the dependencies.

@r0x07k
Copy link
Author

r0x07k commented Aug 18, 2024

That's an interesting root cause :). Thank you for discovering it!

@stariy95 stariy95 added this to the 1.0-M3 milestone Aug 26, 2024
@stariy95
Copy link
Member

stariy95 commented Sep 2, 2024

JJava now shades gson (and other 3rd-party dependencies) so this should be not a problem anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants