コマンド行コンソールを使用した実行時のバンドルのデバッグ
OSGi アプリケーション・コマンド行コンソールは、アプリケーション・サーバーで実行されている 特定のバンドル・セットの探索またはデバッグに使用できる wsadmin コマンドのセットです。 テスト環境での アプリケーションのデバッグの補助として、コンソールにはバンドルを開始したり停止したり するためのコマンドもあります。
このタスクの概要
- 分離フレームワーク
- 分離フレームワークには、特定のアプリケーション専用に定義されたバンドルが含まれています。各 OSGi アプリケーションは、自身の分離フレームワーク内で稼働します。 ネットワーク・デプロイメント環境では、分離フレームワークは、アプリケーションがインストールされている各サーバーに 1 つずつあります。 アプリケーションに複合バンドルが 1 つ以上組み込まれている場合は (アプリケーションの一部として、あるいはアプリケーションの拡張として)、それぞれの複合バンドルに個別の分離フレームワークが含まれています。
- 共有バンドル・フレームワーク
- 共有バンドル・フレームワークは、各サーバーに 1 つずつあります。共有バンドルには、サーバーにインストールされているアプリケーションで使用可能なすべての共有バンドルが含まれています。 アプリケーションがパッケージ依存関係をとおして 1 つ以上の複合バンドルを間接的に参照する場合、それぞれの複合バンドルには共有バンドル・フレームワークが 1 つ含まれています。
現在実行されているフレームワークを処理するには、まず、そのフレームワークに接続します。
手順
- OSGi アプリケーション・コマンド行コンソールを開始します。コマンド・プロンプトで、 osgiApplicationConsole.bat コマンド (Windows システムの場合) または osgiApplicationConsole.sh コマンド ( Linux® システムの場合) を実行します。 このコマンドは、app_server_root/bin ディレクトリーまたは任意の profile_root/bin ディレクトリーから実行することができます。 このコマンドは以下のオプション・パラメーターを取ります。
- -h
- ターゲット・マシンのホスト名。 例えば、
machine1.hursley.ibm.comなどです。 - -o
- ターゲット・サーバーの SOAP ポートのポート番号。 例えば、
8880などです。 - -u
- wsadmin 接続が保護されている場合のユーザー ID。
- -p
- wsadmin 接続が保護されている場合のパスワード。
以下に例を示します。app_server_root/bin/osgiApplicationConsole -h machine1.hursley.ibm.com -o 8880wsadmin コマンド・プロンプトが表示されます。 この wsadmin インスタンスによって、OSGi アプリケーション・コンソール・コマンドが認識されます。 - 使用可能なフレームワークに接続します。
connect コマンドを使用して特定のフレームワークに接続します。
フレームワーク名とバージョン番号、およびフレームワークが実行されているノードとサーバーがわかっている場合は、その情報を接続に使用できます。 以下に例を示します。wsadmin>connect("com.ibm.ws.eba.helloWorldService.eba", "1.0.0", "wasNode1", "server1")また、list コマンドを使用すれば、使用可能なすべてのフレームワークがリストされ、各フレームワークに固有の ID が指定されるので、この ID を使用して接続することもできます。 以下に例を示します。- 使用可能なすべてのフレームワークをリストします。
特定のアプリケーション・サーバーに 接続している場合、このコマンドにより、次のようなシステム応答が生成されます。wsadmin>list()ID Bundle Version Node Server 0 SharedBundles 7.0.0 wasNode1 server1 1 com.ibm.ws.eba.helloWorldService.eba 1.0.0 wasNode1 server1 2 com.ibm.ws.eba.obr.fep.eba5.eba 1.0.0 wasNode1 server1 3 com.ibm.ws.eba.wab.componenttest 1.0.0 wasNode1 server1 - com.ibm.ws.eba.helloWorldService.eba フレームワークに接続します。
コマンドが正常に完了すると、以下のようなシステム応答が生成されます。wsadmin>connect(1)CWSAJ0035I: Connecting to framework com.ibm.ws.eba.helloWorldService.eba_1.0.0 on node wasNode1 and server server1. CWSAJ0036I: Successfully connected to framework com.ibm.ws.eba.helloWorldService.eba_1.0.0.
別のフレームワークに接続するには、再度、connect コマンドを実行します。 別のフレームワークに接続する場合に、前のフレームワークを切断する必要はありません。
- 使用可能なすべてのフレームワークをリストします。
- 接続したフレームワークの作業を行います。以下の 1 つ以上のコマンドを使用して、接続したフレームワークの作業を行います。
- 使用可能なすべてのフレームワークをリストし、現在接続されているフレームワークを示します。list コマンドを使用します。
このコマンドにより、次のようなシステム応答が生成されます。wsadmin>list()ID Bundle Version Node Server 0 SharedBundles 7.0.0 wasNode1 server1 1 com.ibm.ws.eba.helloWorldService.eba 1.0.0 wasNode1 server1 <== Connected 2 com.ibm.ws.eba.obr.fep.eba5.eba 1.0.0 wasNode1 server1 3 com.ibm.ws.eba.wab.componenttest 1.0.0 wasNode1 server1 - フレームワーク内の各バンドルの要約情報を表示します。ss コマンドを使用します。
wsadmin>ss()注:このコマンドにより、次のようなシステム応答が生成されます。ss
は簡略状況
を表します。ID State Bundle 0 ACTIVE org.eclipse.osgi_3.6.1.R36x_v20100806 1 ACTIVE com.ibm.samples.websphere.osgi.blog.app_1.0.0 2 ACTIVE com.ibm.samples.websphere.osgi.blog_1.0.0 3 ACTIVE com.ibm.samples.websphere.osgi.blog.persistence_1.0.0 4 ACTIVE com.ibm.samples.websphere.osgi.blog.web_1.0.0 5 ACTIVE com.ibm.samples.websphere.osgi.blog.api_1.0.0 - フレームワーク内のすべてのバンドルに関する総合情報、ならびにそれらのバンドルが登録または利用するサービスを表示します。bundles コマンドを使用します。
このコマンドにより、次のようなシステム応答が生成されます。wsadmin>bundles()注: アプリケーションに組み込んだバンドルに関する情報は、バンドル 2 および後続のバンドルとしてリストされます。 バンドル 0 および 1 はシステム成果物です。これらのバンドルは変更したり利用したりしないでください。 バンドル 0 の詳細は次の例では示されませんが、このバンドルは通常、他のバンドルよりはるかに多くの情報を生成します。org.eclipse.osgi_3.6.1.R36x_v20100806 [0] Id=0, Status=ACTIVE Location=System Bundle ... com.ibm.samples.websphere.osgi.blog.app_1.0.0 [1] Id=1, Status=ACTIVE Location=com.ibm.samples.websphere.osgi.blog.app_1.0.0 ... com.ibm.samples.websphere.osgi.blog_1.0.0 [2] Id=2, Status=ACTIVE Location=reference:file:/C:/IBM/WebSphere/AppServer/profiles/profile01/ installedEBAs/com.ibm.samples.websphere.osgi.blog.app_1.0.0/byValue/ 98b31e7a-4375-45fa-be20-d34b06f5c8b8.3/3/ Registered Services {com.ibm.samples.websphere.osgi.blog.api.BloggingService}={service.id=46, osgi.service.blueprint.compname=bloggingServiceComponent } {org.osgi.service.blueprint.container.BlueprintContainer}={osgi.blueprint. container.symbolicname=com.ibm.samples.websphere.osgi.blog,service.id=47, osgi.blueprint.container.version=1.0.0} No services in use. com.ibm.samples.websphere.osgi.blog.persistence_1.0.0 [3] Id=3, Status=ACTIVE Location=reference:file:/C:/IBM/WebSphere/AppServer/profiles/profile01/ installedEBAs/com.ibm.samples.websphere.osgi.blog.app_1.0.0/byValue/ 98b31e7a-4375-45fa-be20-d34b06f5c8b8.1/1/ Registered Services {javax.persistence.EntityManagerFactory}={osgi.unit.provider=org.apache.openjpa. persistence.PersistenceProviderImpl,service.id=42,osgi.unit.name=blogExample, osgi.unit.version=1.3.0,org.apache.aries.jpa.container.managed=true,org.apache. aries.jpa.default.unit.name=false} {javax.persistence.EntityManagerFactory}={osgi.unit.provider=org.apache.openjpa. persistence.PersistenceProviderImpl,service.id=43,org.apache.aries.jpa.proxy.factory=true, osgi.unit.name=blogExample,osgi.unit.version=1.3.0,org.apache.aries.jpa.container.managed=true, org.apache.aries.jpa.default.unit.name=false} {com.ibm.samples.websphere.osgi.blog.persistence.api.BlogPersistenceService}={service.id=44, osgi.service.blueprint.compname=persistenceImpl} {org.osgi.service.blueprint.container.BlueprintContainer}={osgi.blueprint.container. symbolicname=com.ibm.samples.websphere.osgi.blog.persistence,service.id=45, osgi.blueprint.container.version=1.0.0} No services in use. com.ibm.samples.websphere.osgi.blog.web_1.0.0 [4] Id=4, Status=ACTIVE Location=reference:file:/C:/IBM/WebSphere/AppServer/profiles/profile01/ installedEBAs/com.ibm.samples.websphere.osgi.blog.app_1.0.0/byValue/ 98b31e7a-4375-45fa-be20-d34b06f5c8b8.2/2/ Registered Services {javax.servlet.ServletContext}={service.id=48,osgi.web.contextpath=/blog, osgi.web.version=1.0.0,osgi.web.symbolicname=com.ibm.samples.websphere.osgi.blog.web} {org.osgi.service.blueprint.container.BlueprintContainer}={osgi.blueprint.container. symbolicname=com.ibm.samples.websphere.osgi.blog.web,service.id=49, osgi.blueprint.container.version=1.0.0} No services in use. com.ibm.samples.websphere.osgi.blog.api_1.0.0 [5] Id=5, Status=ACTIVE Location=reference:file:/C:/IBM/WebSphere/AppServer/profiles/profile01/ installedEBAs/com.ibm.samples.websphere.osgi.blog.app_1.0.0/byValue/ 98b31e7a-4375-45fa-be20-d34b06f5c8b8.0/0/ No registered services. No services in use. - フレームワーク内の特定のバンドルの総合情報を表示します。
bundleコマンドを使用します。 調べるバンドルの ID を指定します。 バンドル ID 値は、 ss コマンドの出力の 1 つです。
このコマンドは、指定されたバンドルに関連付けられた情報をリストします。 例えば、バンドル・シンボル名、バンドル・バージョン、バンドルが登録するサービス、バンドルが利用するサービス、およびバンドルがフラグメント・バンドルであるかホスト・バンドルであるかなど。
以下に例を示します。
このコマンドにより、次のようなシステム応答が生成されます。wsadmin>bundle(3)com.ibm.samples.websphere.osgi.blog.persistence_1.0.0 [3] Id=3, Status=ACTIVE Location=reference:file:/C:/IBM/WebSphere/AppServer/profiles/profile01/ installedEBAs/com.ibm.samples.websphere.osgi.blog.app_1.0.0/byValue/ 98b31e7a-4375-45fa-be20-d34b06f5c8b8.1/1/ Registered Services {javax.persistence.EntityManagerFactory}={osgi.unit.provider=org.apache.openjpa. persistence.PersistenceProviderImpl,service.id=42,osgi.unit.name=blogExample, osgi.unit.version=1.3.0,org.apache.aries.jpa.container.managed=true,org.apache. aries.jpa.default.unit.name=false} {javax.persistence.EntityManagerFactory}={osgi.unit.provider=org.apache.openjpa. persistence.PersistenceProviderImpl,service.id=43,org.apache.aries.jpa.proxy.factory=true, osgi.unit.name=blogExample,osgi.unit.version=1.3.0,org.apache.aries.jpa.container.managed=true, org.apache.aries.jpa.default.unit.name=false} {com.ibm.samples.websphere.osgi.blog.persistence.api.BlogPersistenceService}={service.id=44, osgi.service.blueprint.compname=persistenceImpl} {org.osgi.service.blueprint.container.BlueprintContainer}={osgi.blueprint.container. symbolicname=com.ibm.samples.websphere.osgi.blog.persistence,service.id=45, osgi.blueprint.container.version=1.0.0} No services in use. No exported packages Imported Packages Imported Packages com.ibm.samples.websphere.osgi.blog.persistence.api; version="1.0.0"<com.ibm.samples.websphere.osgi.blog.api_1.0.0 [3]> javax.persistence; version="1.1.0"<org.eclipse.osgi_3.6.1.R36x_v20100806 [3]> No fragment bundles No host bundles No named class spaces Required bundles org.eclipse.osgi_3.6.1.R36x_v20100806 [0] com.ibm.samples.websphere.osgi.blog.api_1.0.0 [5] - 特定のバンドルのヘッダー情報を表示します。
headersコマンドを使用します。 調べるバンドルの ID を指定します。 バンドル ID 値は、 ss コマンドの出力の 1 つです。
以下に例を示します。
このコマンドにより、次のようなシステム応答が生成されます。wsadmin>headers(2)Ant-Version = Apache Ant 1.7.1 Bundle-ActivationPolicy = lazy Bundle-ManifestVersion = 2 Bundle-Name = Blog Core Services Bundle Bundle-SymbolicName = com.ibm.samples.websphere.osgi.blog Bundle-Vendor = IBM Bundle-Version = 1.0.0 Created-By = 2.4 (Your Corporation) Import-Package = com.ibm.samples.websphere.osgi.logging;version="[1.0.0,1.1.0)", com.ibm.samples.websphere.osgi.blog.api;version="[1.0.0,1.1.0)", com.ibm.samples.websphere.osgi.blog.comment.persistence.api;version="[1.0.0,1.1.0)", com.ibm.samples.websphere.osgi.blog.persistence.api;version="[1.0.0,1.1.0)" Manifest-Version = 1.0 - フレームワークによってインポートまたはエクスポートされるパッケージに関する情報を表示します。packagesコマンドを使用します。 オプションで、以下のパラメーターのいずれかまたは両方を指定して特定のパッケージまたはパッケージのサブセットを選択します。
- bundle ID
- このバンドルに対してエクスポートされたパッケージに関する情報を表示します。
- バンドル ID 値は、 ss コマンドの出力の 1 つです。
- package name
- 指定されたパッケージに関する情報を表示します。
コマンド構文:wsadmin>packages() wsadmin>packages(bundle_id) wsadmin>packages(package_name)バンドル ID を使用する例:
このコマンドにより、次のようなシステム応答が生成されます。wsadmin>packages(5)com.ibm.samples.websphere.osgi.blog.persistence.api; version="1.0.0" <com.ibm.samples.websphere.osgi.blog.api_1.0.0 [5]> com.ibm.samples.websphere.osgi.blog_1.0.0 [2] imports com.ibm.samples.websphere.osgi.blog.persistence_1.0.0 [3] imports com.ibm.samples.websphere.osgi.blog.comment.persistence.api; version="1.0.0" <com.ibm.samples.websphere.osgi.blog.api_1.0.0 [5]> com.ibm.samples.websphere.osgi.blog_1.0.0 [2] imports com.ibm.samples.websphere.osgi.blog.api; version="1.0.0" <com.ibm.samples.websphere.osgi.blog.api_1.0.0 [5]> com.ibm.samples.websphere.osgi.blog_1.0.0 [2] imports com.ibm.samples.websphere.osgi.blog.web_1.0.0 [4] importsパッケージ名を使用する例:
このコマンドにより、次のようなシステム応答が生成されます。wsadmin>packages("com.ibm.samples.websphere.osgi.blog.comment.persistence.api")com.ibm.samples.websphere.osgi.blog.comment.persistence.api; version="1.0.0" <com.ibm.samples.websphere.osgi.blog.api_1.0.0 [5]> com.ibm.samples.websphere.osgi.blog_1.0.0 [2] imports - フレームワークによって現在登録されているサービスに関する情報を表示します。 この情報には、各サービスについて、サービス・インターフェース、そのサービスを登録したバンドル、およびそのサービスを利用するバンドルが含まれます。servicesコマンドを使用します。 オプションで、以下のパラメーターのいずれかまたは両方を指定して特定のサービスまたはサービスのサブセットを選択します。
- service ID
- 指定されたサービスに関する情報を表示します。
- filter
- フィルターに一致するすべてのサービスに関する情報を表示します。
- フィルターは、OSGi Service Platform Release 4 Version 4.2 Core Specification のセクション 3.2.7 で定義されている OSGi フィルター形式に従うものでなければなりません。
コマンド構文:wsadmin>services() wsadmin>services(service_id) wsadmin>services("(&(prop1=value_1)(prop2=value_2))")サービス ID を使用する例:
このコマンドにより、次のようなシステム応答が生成されます。wsadmin>services(2){org.osgi.service.packageadmin.PackageAdmin}={service.id=2, service.ranking=2147483647,service.vendor=Eclipse.org - Equinox, service.pid=0.org.eclipse.osgi.framework.internal.core.PackageAdminImpl} Registered by bundle: org.eclipse.osgi_3.6.1.R36x_v20100806 [0] Bundles using service: org.eclipse.osgi_3.6.1.R36x_v20100806 [0]プロパティー・フィルターを 1 つだけ使用する例:
このコマンドにより、次のようなシステム応答が生成されます。wsadmin>services("(objectClass=org.osgi.service.packageadmin.PackageAdmin)"){org.osgi.service.packageadmin.PackageAdmin}={service.id=2, service.ranking=2147483647,service.vendor=Eclipse.org - Equinox, service.pid=0.org.eclipse.osgi.framework.internal.core.PackageAdminImpl} Registered by bundle: org.eclipse.osgi_3.6.1.R36x_v20100806 [0] Bundles using service: org.eclipse.osgi_3.6.1.R36x_v20100806 [0]プロパティー・フィルターを複数使用する例:
このコマンドにより、次のようなシステム応答が生成されます。wsadmin>services("(&(objectClass=javax.resource.Referenceable)(ibm.private.jndi.object=true))"){java.lang.reflect.InvocationHandler,com.ibm.websphere.rsadapter.WSDataSource,java.sql.Wrapper, javax.sql.CommonDataSource,javax.resource.Referenceable,javax.sql.DataSource}={service.id=35, osgi.jndi.service.name=jdbc/pgc,ibm.private.jndi.object=true} Registered by bundle: org.eclipse.osgi_3.6.1.R36x_v20100806 [0] No bundles using service. {java.lang.reflect.InvocationHandler,com.ibm.websphere.rsadapter.WSDataSource,java.sql.Wrapper, javax.sql.CommonDataSource,javax.resource.Referenceable,javax.sql.DataSource}={service.id=36, osgi.jndi.service.name=jdbc/DefaultEJBTimerDataSource,ibm.private.jndi.object=true} Registered by bundle: org.eclipse.osgi_3.6.1.R36x_v20100806 [0] No bundles using service. {java.lang.reflect.InvocationHandler,com.ibm.websphere.rsadapter.WSDataSource,java.sql.Wrapper, javax.sql.CommonDataSource,javax.resource.Referenceable,javax.sql.DataSource}={service.id=39, osgi.jndi.service.name=jdbc/lrsched,ibm.private.jndi.object=true} Registered by bundle: org.eclipse.osgi_3.6.1.R36x_v20100806 [0] No bundles using service. {javax.resource.Referenceable,javax.resource.cci.ConnectionFactory}={service.id=40, osgi.jndi.service.name=eis/jdbc/pgc_CMP,ibm.private.jndi.object=true} Registered by bundle: org.eclipse.osgi_3.6.1.R36x_v20100806 [0] No bundles using service. - フレームワークに関するキャッシュ内のランタイム情報を更新します。システムが、フレームワークおよびフレームワーク内で実行されているバンドルに関するランタイム情報を収集するためには、しばらく時間がかかる場合があります。 したがって、osgiApplicationConsole コマンドを実行する場合、コマンド行コンソールは、ランタイム情報をキャッシュに入れます。 例えば、バンドルを更新または追加するなど、 現在選択されているフレームワークに変更を行う場合、それらの変更は、refresh コマンドを実行するまで コマンド行コンソール・コマンドの出力には反映されません。注: OSGi アプリケーション・コマンド・ライン・コンソールを再始動して、このランタイム情報を更新することもできます。 ただし、その際にはフレームワークに再接続する必要があります。 refresh コマンドを使用した方が迅速に行えます。コマンド構文:
wsadmin>refresh() - バンドルを停止します。
stop コマンドを使用して、特定のバンドル ID によって指定されたバンドルを停止します。 バンドル ID 値は、 ss コマンドの出力の 1 つです。
注:- OSGi アプリケーション・コマンド行コンソールは、主にアプリケーションのデバッグ・メソッドとして使用することを目的としたものです。 実稼働環境では、アプリケーションの開始と停止には、通常、管理コンソール・コマンドかまたはそれに相当する管理コマンドを使用します。
- stop コマンドは、共有バンドル・フレームワークの下のバンドル、システム・バンドル、またはシステム成果物を表すバンドル (バンドル ID 0 および 1) では使用しないでください。使用すると、重大なエラーが発生する可能性があります。
以下に例を示します。
このコマンドにより、次のようなシステム応答が生成されます。wsadmin>stop(5)CWSAJ0042I: Stopping Bundle com.ibm.samples.websphere.osgi.blog.api_1.0.0. CWSAJ0034I: Bundle com.ibm.samples.websphere.osgi.blog.api stopped successfully. - バンドルを開始します。
start コマンドを使用して、特定のバンドル ID によって指定されたバンドルを開始します。 バンドル ID 値は、 ss コマンドの出力の 1 つです。
注:- OSGi アプリケーション・コマンド行コンソールは、主にアプリケーションのデバッグ・メソッドとして使用することを目的としたものです。 実稼働環境では、アプリケーションの開始と停止には、通常、管理コンソール・コマンドかまたはそれに相当する管理コマンドを使用します。
- start コマンドは、共有バンドル・フレームワーク下のバンドル、システム・バンドル、またはアプリケーションを表すバンドル (バンドル ID 0 および 1) では使用しないでください。使用すると、重大なエラーが発生する可能性があります。
以下に例を示します。
このコマンドにより、次のようなシステム応答が生成されます。wsadmin>start(5)CWSAJ0040I: Starting Bundle com.ibm.samples.websphere.osgi.blog.api_1.0.0. CWSAJ0032I: Bundle com.ibm.samples.websphere.osgi.blog.api started successfully. - コンソール・コマンドに関するヘルプ情報を表示します。
help コマンドを使用して、ランタイム・コマンドおよびその使用に関する要約を表示します。
コマンド構文:
このコマンドにより、次のようなシステム応答が生成されます。wsadmin>help()CWSAJ0025I: OSGi application console Display commands: These commands work only if connected to a framework ss() - This command gives the summary information about the installed bundles. bundles() - This command gives comprehensive information about the installed bundles. packages() - This command gives information about the imported/exported packages. services() - This command gives information about the registered Services. bundle(<bundleID>) - This command gives information about the specified bundle headers(<bundleID>) - This command gives information about the headers associated with the specified bundle packages(<bundle ID>) - This command gives information about the exported packages for this bundle. packages(<package Name>) - This command gives information about the specified package. services(<service ID>) - This command gives information about the specified service. services(<OSGI Filter>) - This command gives information about the services matching the filter. refresh() - This command refreshes the internal OSGi application console cache with the latest information about the state of the framework. Framework commands: list() - This command lists the available frameworks that you can connect to. connect(<Framework id>) - This command connects to the specified framework. connect(<Bundle Name>, <Bundle Version>, <Node Name>, <Server Name>) - This command connects to the specified framework. Controlling Bundles: start(<bundleID>) - This command starts the requested bundle. stop(<bundleID> - This command stops the requested bundle.
- 使用可能なすべてのフレームワークをリストし、現在接続されているフレームワークを示します。