2016-05-12 35 views
0

我創建了一個名爲hello-lagom的示例Lagom項目,並且一切似乎都正常。然而,當我嘗試在第一次啓動服務定位器,然後運行該項目,像這樣運行了HelloWorld-IMPL項目:Lagom lagomServiceLocatorStart不工作 - 連接被拒絕

activator lagomServiceLocatorStart 
activator helloworld-impl/run 

控制檯顯示的服務定位器運行:

[info] Service locator is running at http://localhost:8000 
[info] Service gateway is running at http://localhost:9000 
[success] 

c.l.l.j.p.InitServiceLocatorHolder - Cassandra server name=[cas_native] 
couldn't be registered to the service locator. 
java.net.ConnectException: Connection refused: localhost/127.0.0.1:8000 

開始與lagomCassandraStart嵌入式卡桑德拉沒有幫助:

然而Lagom啓動的HelloWorld IMPL服務時拋出了一個連接被拒絕的例外。不僅cassandra服務,但helloworld-impl未能註冊到服務定位器。我試圖telnet端口,但它返回連接被拒絕。

這可能是一個錯誤只發生在試圖運行一個服務獨立或有可能是我失蹤的東西?

+0

當我嘗試登錄時得到了同樣的錯誤。 – Hantsy

回答

1

問題是,您的第一個命令activator lagomServiceLocatorStart啓動嵌入式服務定位器,但服務定位器也在命令執行後立即停止(因爲激活器會話已結束)。我們在激活器會話結束時自動停止嵌入式服務定位器的原因是爲了避免泄漏資源。

你這裏有三種解決方法:

1)串聯的兩個任務,讓他們將在同一激活會話中執行:activator lagomServiceLocatorStart helloworld-impl/run

2)首先進入激活會話,然後執行任務(我肯定會推薦這超過1,因爲你不交罰款的時間爲每次開機激活劑):

$ activator 
> lagomServiceLocatorStart 
> helloworld-impl/run 

3)使用Lagom runAll任務,而不是手動啓動SERVIC e定位器和你的服務,因爲它爲你照顧(使用這個,除非你有很好的理由否則):

$ activator 
> runAll