Trying to interact with the web3j object results in this error for me:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.bouncycastle.jcajce.provider.drbg.DRBG (file:/C:/Users/regen/.m2/repository/org/bouncycastle/bcprov-jdk15on/1.61/bcprov-jdk15on-1.61.jar) to constructor sun.security.provider.Sun()
WARNING: Please consider reporting this to the maintainers of org.bouncycastle.jcajce.provider.drbg.DRBG
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Exception in thread "main" java.util.concurrent.ExecutionException: java.lang.NoSuchMethodError: 'okhttp3.RequestBody okhttp3.RequestBody.create(java.lang.String, okhttp3.MediaType)'
at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2063)
at com.wienenergie.meipower.powerplantmocks.Mockscript.main(Mockscript.java:28)
Caused by: java.lang.NoSuchMethodError: 'okhttp3.RequestBody okhttp3.RequestBody.create(java.lang.String, okhttp3.MediaType)'
at org.web3j.protocol.http.HttpService.performIO(HttpService.java:154)
at org.web3j.protocol.Service.send(Service.java:48)
at org.web3j.protocol.Service.lambda$sendAsync$0(Service.java:60)
at org.web3j.utils.Async.lambda$run$1(Async.java:38)
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1800)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at java.base/java.lang.Thread.run(Thread.java:832)
The problem seems to occur at version 4.5.12 and above, the below versions work just fine.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@s1r-mar71n can you share a code snippet so we can replicate please
I solved this issue by making sure i explicitly declare dependencies for the okhttp version used in the web3j version i use, which for web3j-core v4.5.18 was:
<!-- HTTP -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.3.1</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>logging-interceptor</artifactId>
<version>4.3.1</version>
</dependency>
Before I added the explicit dependencies it has used an older 3.* version of okhttp.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I鈥檝e tried to explicitly add the okhttp dependencies and compiled maven successfully but was unable to run spring boot app.
No errors were generated though..
Anyone facing this issue too?
Most helpful comment
I solved this issue by making sure i explicitly declare dependencies for the okhttp version used in the web3j version i use, which for web3j-core v4.5.18 was:
Before I added the explicit dependencies it has used an older 3.* version of okhttp.