2016-04-20 6 views
1

servicemix/karafにnewbyとして、私はREST要求を受け入れて返す非常に単純なプログラムを作成しようとしています。私が持っているクラスは:servicemix:どのポートが私のosgiバンドルですか?

package (....) 

import org.springframework.http.HttpStatus; 
import org.springframework.http.MediaType; 
import org.springframework.http.ResponseEntity; 
import org.springframework.web.bind.annotation.RequestBody; 
import org.springframework.web.bind.annotation.RequestMapping; 
import org.springframework.web.bind.annotation.RequestMethod; 
import org.springframework.web.bind.annotation.ResponseBody; 
import org.springframework.web.bind.annotation.RestController; 

import (...).model.RSDocument; 
import (...).model.RSDocumentResponse; 

@RestController 
public class DocumentService { 

    @RequestMapping(value = "/rest/document", method = RequestMethod.POST, 
      produces = MediaType.APPLICATION_JSON_VALUE) 
    public @ResponseBody ResponseEntity<RSDocumentResponse> printDocument(
      @RequestBody RSDocument documentRequest) 
    { 
     System.out.println(documentRequest.getContent()); 
     RSDocumentResponse response = new RSDocumentResponse(); 
     response.setSuccess(true); 
     return new ResponseEntity<>(response, HttpStatus.OK); 
    } 

} 

私はTomcatでうまく動作しています。 Tomcatでは、eclipseでサーバー上でダブルクリックし、 "Ports"セクションに値を設定することで、着信要求をlistenするポートを指定します。どのようにしてServicemixのポートを設定するのですか、現在リッスンしているポートを特定するにはどうしたらいいですか? Servicemixのコマンドラインから順番にバンドルを開始しています。私のアプリケーションが80(Apache)、8080(None)、または8181(Servicemixコンソール)をリッスンしているようではない

+0

:あなたが他のすべての必要なバンドルがインストールされていると、すべての依存関係を含め、実行中の場合は、上のRESTサービスにナビゲートすることができるはず設定されています。私はあなたがこの1つ以上のクラスを持っていると思います –

答えて

1

最初に、Webコンテナを展開してください。このために戦争機能がインストールされていることを確認してください。

feature:list | grep war 

それがインストールされていない場合は、issueingしてインストール:

feature:install war 

を今は、あなたのjarファイル/戦争は、Webコンテナたコンテキストを伝えるWebベースのcontextPathマニフェストエントリが含まれていることを確認してください探すパス。どのようにあなたのアプリケーションをパッケージ化してデプロイん

localhost:8181/myContextPath/rest/document 
+0

KarafはWebコンテナとしてJettyに依存しており、コネクタのポートのような設定は$ KARAF_HOME /等 – Ralf

+0

@Ralf、それは実際には真実の半分です...それはOSGiのHttpサービスであるため、osgiサービスのプロパティを使用するのが好ましい方法です: org.osgi.service.http.port –

+0

も参照してください。http: //ops4j.github.io/pax/web/SNAPSHOT/User-Guide.html#basic-configuration –

関連する問題