我在Windows 10上使用docker。
我试图连接到我的本地主机,但它给出了一个错误。
我使用过命令> docker start cassandra-ce
...是成功的,但是当我运行'sbt run'
命令并在浏览器中输入我的localhost:9000时,它给出了错误:
Uncaught error from thread [application-akka.actor.default-dispatcher-4]: null, s
hutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[
application]
java.lang.ExceptionInInitializerError
at com.consultengine.services.InviteService.getAllInviteReceived(InviteSe
rvice.scala:54)
at com.consultengine.controllers.v1.InviteController.$anonfun$getAllInvit
eReceived$2(InviteController.scala:130)
at scala.concurrent.Future$.$anonfun$apply$1(Future.scala:655)
at scala.util.Success.$anonfun$map$1(Try.scala:251)
at scala.util.Success.map(Try.scala:209)
at scala.concurrent.Future.$anonfun$map$1(Future.scala:289)
at scala.concurrent.impl.Promise.liftedTree1$1(Promise.scala:29)
at scala.concurrent.impl.Promise.$anonfun$transform$1(Promise.scala:29)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)
at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExec
utor.scala:55)
at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingE
xecutor.scala:91)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:81)
at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.sca
la:91)
at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40)
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJ
oinExecutorConfigurator.scala:43)
at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.jav
a:1339)
at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.j
ava:107)
Caused by: com.impetus.kundera.configure.schema.SchemaGenerationException: Error
while opening socket, Caused by: .
at com.impetus.client.cassandra.schemamanager.CassandraSchemaManager.init
iateClient(CassandraSchemaManager.java:718)
at com.impetus.kundera.configure.schema.api.AbstractSchemaManager.exportS
chema(AbstractSchemaManager.java:112)
at com.impetus.client.cassandra.schemamanager.CassandraSchemaManager.expo
rtSchema(CassandraSchemaManager.java:166)
at com.impetus.kundera.configure.SchemaConfiguration.configure(SchemaConf
iguration.java:191)
at com.impetus.kundera.configure.ClientMetadataBuilder.buildClientFactory
Metadata(ClientMetadataBuilder.java:48)
at com.impetus.kundera.persistence.EntityManagerFactoryImpl.configureClie
ntFactories(EntityManagerFactoryImpl.java:408)
at com.impetus.kundera.persistence.EntityManagerFactoryImpl.configure(Ent
ityManagerFactoryImpl.java:161)
at com.impetus.kundera.persistence.EntityManagerFactoryImpl.<init>(Entity
ManagerFactoryImpl.java:135)
at com.impetus.kundera.KunderaPersistence.createEntityManagerFactory(Kund
eraPersistence.java:85)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.j
ava:79)
at com.consultengine.daos.InviteDAOImpl$.<init>(InviteDAO.scala:29)
at com.consultengine.daos.InviteDAOImpl$.<clinit>(InviteDAO.scala)
... 20 more
Caused by: org.apache.thrift.transport.TTransportException: java.net.ConnectExcep
tion: Connection refused: connect
at org.apache.thrift.transport.TSocket.open(TSocket.java:187)
at com.impetus.client.cassandra.schemamanager.CassandraSchemaManager.init
iateClient(CassandraSchemaManager.java:695)
... 31 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketIm
pl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.jav
a:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketI
mpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:
188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.apache.thrift.transport.TSocket.open(TSocket.java:182)
... 32 more
[error] a.a.ActorSystemImpl - Uncaught error from thread [application-akka.actor.
default-dispatcher-4]: null, shutting down JVM since 'akka.jvm-exit-on-fatal-erro
r' is enabled for ActorSystem[application]
java.lang.ExceptionInInitializerError: null
at com.consultengine.services.InviteService.getAllInviteReceived(InviteSe
rvice.scala:54)
at com.consultengine.controllers.v1.InviteController.$anonfun$getAllInvit
eReceived$2(InviteController.scala:130)
at scala.concurrent.Future$.$anonfun$apply$1(Future.scala:655)
at scala.util.Success.$anonfun$map$1(Try.scala:251)
at scala.util.Success.map(Try.scala:209)
at scala.concurrent.Future.$anonfun$map$1(Future.scala:289)
at scala.concurrent.impl.Promise.liftedTree1$1(Promise.scala:29)
at scala.concurrent.impl.Promise.$anonfun$transform$1(Promise.scala:29)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)
at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExec
utor.scala:55)
Caused by: com.impetus.kundera.configure.schema.SchemaGenerationException: Error
while opening socket, Caused by: .
at com.impetus.client.cassandra.schemamanager.CassandraSchemaManager.init
iateClient(CassandraSchemaManager.java:718)
at com.impetus.kundera.configure.schema.api.AbstractSchemaManager.exportS
chema(AbstractSchemaManager.java:112)
at com.impetus.client.cassandra.schemamanager.CassandraSchemaManager.expo
rtSchema(CassandraSchemaManager.java:166)
at com.impetus.kundera.configure.SchemaConfiguration.configure(SchemaConf
iguration.java:191)
at com.impetus.kundera.configure.ClientMetadataBuilder.buildClientFactory
Metadata(ClientMetadataBuilder.java:48)
at com.impetus.kundera.persistence.EntityManagerFactoryImpl.configureClie
ntFactories(EntityManagerFactoryImpl.java:408)
at com.impetus.kundera.persistence.EntityManagerFactoryImpl.configure(Ent
ityManagerFactoryImpl.java:161)
at com.impetus.kundera.persistence.EntityManagerFactoryImpl.<init>(Entity
ManagerFactoryImpl.java:135)
at com.impetus.kundera.KunderaPersistence.createEntityManagerFactory(Kund
eraPersistence.java:85)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.j
ava:79)
Caused by: org.apache.thrift.transport.TTransportException: java.net.ConnectExcep
tion: Connection refused: connect
at org.apache.thrift.transport.TSocket.open(TSocket.java:187)
at com.impetus.client.cassandra.schemamanager.CassandraSchemaManager.init
iateClient(CassandraSchemaManager.java:695)
at com.impetus.kundera.configure.schema.api.AbstractSchemaManager.exportS
chema(AbstractSchemaManager.java:112)
at com.impetus.client.cassandra.schemamanager.CassandraSchemaManager.expo
rtSchema(CassandraSchemaManager.java:166)
at com.impetus.kundera.configure.SchemaConfiguration.configure(SchemaConf
iguration.java:191)
at com.impetus.kundera.configure.ClientMetadataBuilder.buildClientFactory
Metadata(ClientMetadataBuilder.java:48)
at com.impetus.kundera.persistence.EntityManagerFactoryImpl.configureClie
ntFactories(EntityManagerFactoryImpl.java:408)
at com.impetus.kundera.persistence.EntityManagerFactoryImpl.configure(Ent
ityManagerFactoryImpl.java:161)
at com.impetus.kundera.persistence.EntityManagerFactoryImpl.<init>(Entity
ManagerFactoryImpl.java:135)
at com.impetus.kundera.KunderaPersistence.createEntityManagerFactory(Kund
eraPersistence.java:85)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketIm
pl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.jav
a:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketI
mpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:
188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.apache.thrift.transport.TSocket.open(TSocket.java:182)
at com.impetus.client.cassandra.schemamanager.CassandraSchemaManager.init
iateClient(CassandraSchemaManager.java:695)
我还更改了application.conf
application.baseUrl="http://localhost:9000"
ce.webserver.url="http://localhost:8100"
ce.cassandra.host="localhost"
version=33
和我的persistance.xml文件到本地主机和端口9160:
<properties>
<property name="kundera.nodes" value="localhost" />
<property name="kundera.port" value="9160" />
<property name="kundera.keyspace" value="cedb" />
<property name="kundera.dialect" value="cassandra" />
<property name="kundera.ddl.auto.prepare" value="update" />
<property name="kundera.client.lookup.class" value="com.impetus.client.cassandra.thrift.ThriftClientFactory" />
</properties>
答案 0 :(得分:0)
这是因为在docker中启动Cassandra时尚未完成端口映射。您的Cassandra仅在该特定docker网络中可见。使用以下命令通过端口映射启动Cassandra。
docker run -p 9042:9042 cassandra
然后您将在0.0.0.0:9042->9042/tcp
中看到docker ps
对于第二个错误,如果您不想自动管理架构,请将<property name="kundera.port" value="9160" />
端口更改为9042并删除<property name="kundera.ddl.auto.prepare" value="update" />
如果要自动管理架构,则将<property name="kundera.port" value="9160" />
端口更改为9042,并使用以下命令在docker中启动Cassandra,从而启动Cassandra thrift服务器并映射该thrift端口的端口。
docker run -p 9042:9042 -p 9160:9160 -e CASSANDRA_START_RPC=true cassandra