kousen/reactive-spring

Mongo issue on Officers

Closed this issue · 2 comments

Thank you so much for your excellent tutorials.

In running the officers application on IntelliJ, I get this error:

>   .   ____          _            __ _ _
>  /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
> ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
>  \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
>   '  |____| .__|_| |_|_| |_\__, | / / / /
>  =========|_|==============|___/=/_/_/_/
>  :: Spring Boot ::        (v2.3.4.RELEASE)
> 
> 2020-10-20 12:01:54.774  INFO 74222 --- [           main] c.o.r.ReactiveOfficersApplication        : Starting ReactiveOfficersApplication on logos with PID 74222 (/Users/barton/Documents/dev/spring/reactive-spring (kousen)/reactive-officers/build/classes/java/main started by barton in /Users/barton/Documents/dev/spring/reactive-spring (kousen)/reactive-officers)
> 2020-10-20 12:01:54.777  INFO 74222 --- [           main] c.o.r.ReactiveOfficersApplication        : No active profile set, falling back to default profiles: default
> 2020-10-20 12:01:55.231  INFO 74222 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Reactive MongoDB repositories in DEFAULT mode.
> 2020-10-20 12:01:55.372  INFO 74222 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 136ms. Found 1 Reactive MongoDB repository interfaces.
> 2020-10-20 12:01:55.773  INFO 74222 --- [           main] org.mongodb.driver.cluster               : Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms'}
> 2020-10-20 12:01:55.907  INFO 74222 --- [localhost:27017] org.mongodb.driver.cluster               : Exception in monitor thread while connecting to server localhost:27017
> 
> com.mongodb.MongoSocketOpenException: Exception opening socket
> 	at com.mongodb.connection.netty.NettyStream$OpenChannelFutureListener.operationComplete(NettyStream.java:416) ~[mongodb-driver-core-4.0.5.jar:na]
> 	at com.mongodb.connection.netty.NettyStream$OpenChannelFutureListener.operationComplete(NettyStream.java:384) ~[mongodb-driver-core-4.0.5.jar:na]
> 	at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:577) ~[netty-common-4.1.52.Final.jar:4.1.52.Final]
> 	at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:570) ~[netty-common-4.1.52.Final.jar:4.1.52.Final]
> 	at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:549) ~[netty-common-4.1.52.Final.jar:4.1.52.Final]
> 	at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:490) ~[netty-common-4.1.52.Final.jar:4.1.52.Final]
> 	at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:615) ~[netty-common-4.1.52.Final.jar:4.1.52.Final]
> 	at io.netty.util.concurrent.DefaultPromise.setFailure0(DefaultPromise.java:608) ~[netty-common-4.1.52.Final.jar:4.1.52.Final]
> 	at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:117) ~[netty-common-4.1.52.Final.jar:4.1.52.Final]
> 	at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.fulfillConnectPromise(AbstractNioChannel.java:321) ~[netty-transport-4.1.52.Final.jar:4.1.52.Final]
> 	at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:337) ~[netty-transport-4.1.52.Final.jar:4.1.52.Final]
> 	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:702) ~[netty-transport-4.1.52.Final.jar:4.1.52.Final]
> 	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650) ~[netty-transport-4.1.52.Final.jar:4.1.52.Final]
> 	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576) ~[netty-transport-4.1.52.Final.jar:4.1.52.Final]
> 	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) ~[netty-transport-4.1.52.Final.jar:4.1.52.Final]
> 	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) ~[netty-common-4.1.52.Final.jar:4.1.52.Final]
> 	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.52.Final.jar:4.1.52.Final]
> 	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.52.Final.jar:4.1.52.Final]
> 	at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
> Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: localhost/fe80:0:0:0:0:0:0:1%1:27017
> Caused by: java.net.ConnectException: Connection refused
> 	at java.base/sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:na]
> 	at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:779) ~[na:na]
> 	at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:330) ~[netty-transport-4.1.52.Final.jar:4.1.52.Final]
> 	at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:334) ~[netty-transport-4.1.52.Final.jar:4.1.52.Final]
> 	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:702) ~[netty-transport-4.1.52.Final.jar:4.1.52.Final]
> 	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650) ~[netty-transport-4.1.52.Final.jar:4.1.52.Final]
> 	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576) ~[netty-transport-4.1.52.Final.jar:4.1.52.Final]
> 	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) ~[netty-transport-4.1.52.Final.jar:4.1.52.Final]
> 	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) ~[netty-common-4.1.52.Final.jar:4.1.52.Final]
> 	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.52.Final.jar:4.1.52.Final]
> Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: localhost/fe80:0:0:0:0:0:0:1%1:27017
> 
> 	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.52.Final.jar:4.1.52.Final]
> 	at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
> 
> Caused by: java.net.ConnectException: Connection refused
> 
> 2020-10-20 12:01:56.444  INFO 74222 --- [           main] o.s.b.web.embedded.netty.NettyWebServer  : Netty started on port(s): 8080
> 2020-10-20 12:01:56.454  INFO 74222 --- [           main] c.o.r.ReactiveOfficersApplication        : Started ReactiveOfficersApplication in 2.012 seconds (JVM running for 2.35)
> 2020-10-20 12:01:56.512  INFO 74222 --- [           main] org.mongodb.driver.cluster               : No server chosen by com.mongodb.internal.async.client.ClientSessionHelper$1@7fe07361 from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, serverDescriptions=[ServerDescription{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: localhost/fe80:0:0:0:0:0:0:1%1:27017}, caused by {java.net.ConnectException: Connection refused}}]}. Waiting for 30000 ms before timing out
> 2020-10-20 12:02:26.517  INFO 74222 --- [5dd7a2de1257086] org.mongodb.driver.cluster               : No server chosen by WritableServerSelector from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, serverDescriptions=[ServerDescription{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: localhost/fe80:0:0:0:0:0:0:1%1:27017}, caused by {java.net.ConnectException: Connection refused}}]}. Waiting for 30000 ms before timing out

Can you advise what I need to do to enable the connection to be established?

Thank you so much.

Barton

Yes, that was it. I used the instructions on the mongoDB site to install via brew. Over the course of the tutorials I have become spoiled to having Spring do everything and run everything embedded - I heard you mention on the tutorial that you had installed it, but assumed I did not have to since the dependency was declared in Spring.