JBoss 7.1.2アプリケーションサーバーを稼働させており、サーブレットを登録するOSGiバンドルをデプロイしたいと思いました。(Hello Worldの一種ですが、サーブレット経由)
おそらくこれをWAB経由でアーカイブすることは可能ですが、OSGiの場合と同様に、単純な非wabバンドルでも機能するはずだと思いました。
次のように、アクティベーターを使用してバンドルを作成しました。
snip..
public void start(BundleContext bundleContext) throws Exception {
ServiceReference<?> httpServiceReference = bundleContext.getServiceReference(HttpService.class.getName());
System.out.println("ref: " + httpServiceReference);
HttpService httpService = (HttpService) context.getService(httpServiceReference);
System.out.println(httpService.getClass().getName());
try {
httpService.registerServlet("testservlet", new MyServlet() , null, null);
} catch (Exception e) {
e.printStackTrace();
}
}
バンドルをデプロイして開始した後、httpServiceReferenceはnull
です。これは奇妙だと思います。なぜなら、felix Webコンソールを見ると、実際にはHtttpServiceが利用できるからです。(pax-webから)
ここで私の参照がnullになる理由を誰かが知っていますか?ありがとう!