Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » java.lang.NoSuchMethodError in okhttp3.RequestBody.create(java.lang.NoSuchMethodError: 'okhttp3.RequestBody okhttp3.RequestBody.create(java.lang.String, okhttp3.MediaType)')
java.lang.NoSuchMethodError in okhttp3.RequestBody.create [message #1854168] Thu, 04 August 2022 08:54 Go to next message
Miloslav Frajdl is currently offline Miloslav FrajdlFriend
Messages: 48
Registered: June 2018

I need to create an application that performs cryptocurrency operations with Solana. I implemented the library

In pom.xml I declared these dependencies:
	<!-- This is a library that works with Solana -->
	<!-- These are the required dependencies -->
      <version>4.9.0</version><!-- !!!!! A version conflict is reported here: "Overriding managed version 3.14.9 for okhttp" !!!!! -->

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;
			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) {
			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( - Client=milos@ - MDC[]
java.lang.NoSuchMethodError: 'okhttp3.RequestBody okhttp3.RequestBody.create(java.lang.String, okhttp3.MediaType)'
	at org.p2p.solanaj.rpc.RpcApi.getBalance(
	at cz.a4b.tracetickets.server.solanaj.SolanaJUtils.getBalance(

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

Re: java.lang.NoSuchMethodError in okhttp3.RequestBody.create [message #1854223 is a reply to message #1854168] Mon, 08 August 2022 11:39 Go to previous message
Beat Schwarzentrub is currently offline Beat SchwarzentrubFriend
Messages: 210
Registered: November 2010
Senior Member
Scout defines all dependency versions in the <dependencyManagement> section of the central pom.xml:

You should be able to override this in the <dependencyManagement> section of your own project pom.

This might be similar to this situation:

Previous Topic:Add JAR library to Scout project without Maven
Next Topic:Programmatically defined saved settings for table
Goto Forum:

Current Time: Wed Jul 24 11:56:33 GMT 2024

Powered by FUDForum. Page generated in 0.04365 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top