Hi.
I need to create an application that performs cryptocurrency operations with Solana. I implemented the library https://github.com/Heaven-Land/solanaj.
In pom.xml I declared these dependencies:
<!-- This is a library that works with Solana -->
<dependency>
<groupId>org.p2p</groupId>
<artifactId>solanaj</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- These are the required dependencies -->
<dependency>
<groupId>org.bitcoinj</groupId>
<artifactId>bitcoinj-core</artifactId>
<version>0.16.1</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.0</version><!-- !!!!! A version conflict is reported here: "Overriding managed version 3.14.9 for okhttp" !!!!! -->
</dependency>
<dependency>
<groupId>com.squareup.moshi</groupId>
<artifactId>moshi</artifactId>
<version>1.9.2</version>
</dependency>
<dependency>
<groupId>com.squareup.moshi</groupId>
<artifactId>moshi-adapters</artifactId>
<version>1.9.2</version>
</dependency>
In dependency for com.squareup.okhttp3/okhttp is reported warning: "Overriding managed version 3.14.9 for okhttp"
And I have this class:
import org.eclipse.scout.rt.platform.config.CONFIG;
import org.p2p.solanaj.core.PublicKey;
import org.p2p.solanaj.rpc.Cluster;
import org.p2p.solanaj.rpc.RpcApi;
import org.p2p.solanaj.rpc.RpcClient;
import org.p2p.solanaj.rpc.RpcException;
public class SolanaJUtils {
public static Cluster getCluster() {
String cluster = CONFIG.getPropertyValue(SolanaJCluster.class);
if (cluster != null) cluster = cluster.toLowerCase();
switch(cluster) {
case "testnet":
return Cluster.TESTNET;
case "devnet":
return Cluster.DEVNET;
case "mainnet":
return Cluster.MAINNET;
default:
return Cluster.DEVNET;
}
}
public static Long getBalance(String address) {
RpcClient client = new RpcClient(getCluster());
try {
RpcApi api = client.getApi();
return api.getBalance(new PublicKey(address)); // <<<< !!!! ERROR IS THROWN HERE !!!!
} catch (RpcException e) {
e.printStackTrace();
return null;
}
}
}
An error is thrown when calling the api.getBalance(new PublicKey(address)) method:
2022-08-04 09:58:51,255 ERROR [qtp596470015-56] org.eclipse.scout.rt.server.ServiceTunnelServlet.doPost(ServiceTunnelServlet.java:175) - Client=milos@127.0.0.1/127.0.0.1 - MDC[]
java.lang.NoSuchMethodError: 'okhttp3.RequestBody okhttp3.RequestBody.create(java.lang.String, okhttp3.MediaType)'
at org.p2p.solanaj.rpc.RpcClient.call(RpcClient.java:44)
at org.p2p.solanaj.rpc.RpcApi.getBalance(RpcApi.java:59)
at cz.a4b.tracetickets.server.solanaj.SolanaJUtils.getBalance(SolanaJUtils.java:87)
I tried:
But nothing helped.
When I link the same library in a normal Eclipse project (not Scout) including dependencies, it works.
Can someone please advise me what needs to be done?
Thank you.
---------------------------------------
EDIT 2022/08/04 17:54:
The problem is really that the required version of okhttp 4.9.0 is overridden by version 3.14.9 (see warning note above in dependencies). In version 4.9.0, the method is of the form: okhttp3.RequestBody okhttp3.RequestBody.create(java.lang.String, okhttp3.MediaType)
but in version 3.14.9 it is of the form: okhttp3.RequestBody okhttp3.RequestBody.create(okhttp3.MediaType, java.lang.String)
In the Manage Dependencies dialog it says: "Dependency okhttp-4.9.0 already declared with version 3.14.9 under org.eclipse.scout.rt:org.eclipse.scout.rt:11.0.42's dependencyManagement". This declaration is in C:\Users\milos\.m2\repository\org\eclipse\scout\rt\org.eclipse.scout.rt\11.0.42\org.eclipse.scout.rt-11.0.42.pom
Can anyone tell me how to tell Scout not to use managed version 3.14.9 but to use version 4.9.0? Thanks
[Updated on: Thu, 04 August 2022 15:54]
Report message to a moderator