Open mik3hall opened 9 years ago
I was thinking of making this a separate issue because I thought I had another instance. But so far I guess this just came up on PrintPeers.
Exception in thread "main" java.lang.IllegalStateException at org.bitcoinj.net.NioClientManager.openConnection(NioClientManager.java:150) at org.bitcoinj.examples.PrintPeers.main(PrintPeers.java:121)
Adding these...
clientManager.startAsync();
clientManager.awaitRunning();
after Line 83 NioClientManager clientManager = new NioClientManager();
seemed a workaround.
Thats strange, I just ran into this a well. I'll try your work around.
Update. No go. I ran into this issue in NetworkAbstractionTests. I tried adding awaitRunning, and the error turned into
java.lang.IllegalStateException: Expected the service NioClientManager [FAILED] to be RUNNING, but the service has FAILED
at com.google.common.util.concurrent.AbstractService.checkCurrentState(AbstractService.java:344)
at com.google.common.util.concurrent.AbstractService.awaitRunning(AbstractService.java:280)
at com.google.common.util.concurrent.AbstractExecutionThreadService.awaitRunning(AbstractExecutionThreadService.java:211)
at org.bitcoinj.net.NetworkAbstractionTests.<init>(NetworkAbstractionTests.java:60)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.junit.runners.parameterized.BlockJUnit4ClassRunnerWithParameters.createTestUsingConstructorInjection(BlockJUnit4ClassRunnerWithParameters.java:43)
at org.junit.runners.parameterized.BlockJUnit4ClassRunnerWithParameters.createTest(BlockJUnit4ClassRunnerWithParameters.java:38)
at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:266)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.IllegalStateException: You must construct a Context object before using bitcoinj!
at org.bitcoinj.core.Context.get(Context.java:107)
at org.bitcoinj.utils.ContextPropagatingThreadFactory.newThread(ContextPropagatingThreadFactory.java:45)
at org.bitcoinj.net.NioClientManager$1.execute(NioClientManager.java:192)
at com.google.common.util.concurrent.MoreExecutors$2.execute(MoreExecutors.java:845)
at com.google.common.util.concurrent.AbstractExecutionThreadService$1.doStart(AbstractExecutionThreadService.java:55)
at com.google.common.util.concurrent.AbstractService.startAsync(AbstractService.java:225)
at com.google.common.util.concurrent.AbstractExecutionThreadService.startAsync(AbstractExecutionThreadService.java:196)
at org.bitcoinj.net.NetworkAbstractionTests.<init>(NetworkAbstractionTests.java:59)
... 30 more
Same as first part of Trouble with Context on bitcoinj 0.13.2 #1093 https://github.com/bitcoinj/bitcoinj/issues/1093
Exception in thread "main" java.lang.IllegalStateException: You must construct a Context object before using bitcoinj! at org.bitcoinj.core.Context.get(Context.java:83) at org.bitcoinj.core.Peer.(Peer.java:227)
at org.bitcoinj.core.Peer.(Peer.java:193)
at org.bitcoinj.core.Peer.(Peer.java:174)
at org.bitcoinj.examples.PrintPeers.main(PrintPeers.java:88)
Same fix worked... Context.getOrCreate(MainNetParams.get());