C Oracle REST Data Servicesのトラブルシューティング

この付録では、Oracle REST Data Servicesのトラブルシューティングについて説明します。

トピック:

詳細なリクエスト・エラー・メッセージの有効化

詳細なリクエスト・エラー・メッセージを有効にするには、defaults.xmlという名前のOracle REST Data Servicesの構成ファイルに次の設定を追加します。

<entry key="debug.printDebugToScreen">true</entry>

この設定がdefaults.xmlの中に存在すると、任意のリクエストの生成するエラー・レスポンスにスタック・トレースを含む詳細なメッセージが含まれます。機密情報が攻撃者に漏れるリスクがあるため、この設定は本番システムでは有効にしないでください。

ORDSユーザー定義サービス

次の表では、ORDSユーザー定義サービスを示しています。

表C-1 ORDSユーザー定義サービスのリスト

サービス レスポンス
--HTTP 200
BEGIN
  ORDS.define_service(
    p_module_name    => 'test1',
    p_base_path      => 'test1/',
    p_pattern        => 'ok/',
    p_method         => 'GET',
    p_source_type    => ORDS.source_type_collection_feed,
    p_source         => 'SELECT * FROM dual',
    p_items_per_page => 0);
  COMMIT;
END;
/
>curl -i -X GET --user DEMO:demo -k http://localhost:8082/ords/demo/test1/ok/
HTTP/1.1 200 OK Date: Thu, 19 Mar 2020 17:18:05 GMT 
Content-Type: application/json
ETag: "BLNTmyd/ZM889Q0GlgJ1t7lkSYo2kpAVIv4CY5dvtp9NI/Em1DJRzpmE5Bg/4GiKifewtzuJA6i+YCgdxETWWQ=="
Transfer-Encoding: chunked
--HTTP 200 , p_source_type => ORDS.source_type_collection_feed,
BEGIN
  ORDS.define_service( 
      p_module_name => 'test2',  
      p_base_path => 'test2/', 
      p_pattern => 'norows/', 
      p_method => 'GET', 
      p_source_type => ORDS.source_type_collection_feed, 
      p_source => 'SELECT * FROM dual where 1 = 2', p_items_per_page => 0); 
  COMMIT; 
END; 
/
>curl  --head  -i -X  GET --user DEMO:demo -k http://localhost:8082/ords/demo/test2/norows/
HTTP/1.1 200 OK
Date: Thu, 19 Mar 2020 17:18:28 GMT
Content-Type: application/json
ETag: "aZVsHTwewrbbkl6wHNcTa3RFFdEsbdtDRBTSlR93r/vBmDvVsgud2rFqLDI65UKxzSElnAAMQdlBj/sB9ywWqQ=="
Transfer-Encoding: chunked

create table no_rows (col1 int); 
--HTTP 200 , p_source_type => ORDS.source_type_collection_feed, 
BEGIN
  ORDS.define_service( 
     p_module_name => 'test2b', 
     p_base_path => 'test2b/',
     p_pattern => 'norows/', 
     p_method => 'GET', 
     p_source_type => ORDS.source_type_collection_feed, 
     p_source => 'SELECT * FROM no_rows', p_items_per_page => 0); 
  COMMIT; 
END; 
/

>curl  --head  -i -X  GET --user DEMO:demo -k http://localhost:8082/ords/demo/test2b/norows/
HTTP/1.1 200 OK
Date: Thu, 19 Mar 2020 17:18:34 GMT
Content-Type: application/json
ETag: "Ns/g/hFxVWYPHUyZT53HNl6EMVlQUXD5wmz3eoO15dlY6nSVkk2FX3sNw3Yvq87SdLYAlCLeuqb4N4DQrcy+0Q=="
Transfer-Encoding: chunked
--HTTP 404 , p_source_type => ORDS.source_type_collection_item, 
BEGIN
  ORDS.define_service( 
    p_module_name => 'test2c', 
    p_base_path => 'test2c/', 
    p_pattern => 'norows/',
    p_method => 'GET', 
    p_source_type => ORDS.source_type_collection_item, 
    p_source => 'SELECT * FROM dual where 1 = 2', 
    p_items_per_page => 0); 
  COMMIT; 
END; 
/
>curl  --head  -i -X  GET --user DEMO:demo -k http://localhost:8082/ords/demo/test2c/norows/
HTTP/1.1 404 Not Found
Content-Type: text/html
Content-Length: 16127
--HTTP 404 
BEGIN
  ORDS.define_service( 
    p_module_name => 'test3', 
    p_base_path => 'test3/', 
    p_pattern => 'doesnotexist/', 
    p_method => 'GET', 
    p_source_type => ORDS.source_type_collection_feed, 
    p_source => 'SELECT 10 as A FROM doesnotexist', 
    p_items_per_page => 0); 
  COMMIT; 
END; 
/
>curl  --head  -i -X  GET --user DEMO:demo -k http://localhost:8082/ords/demo/test3/doesnotexist/
HTTP/1.1 403 Forbidden
Content-Type: text/html
Error-Reason: error="missing.object"; error_description*=UTF-8'
'The request could not be processed because a table or view referenced
0by the SQL statement being evaluated is not accessible or does not exist
Content-Length: 16327
--HTTP 555 
BEGIN
  ORDS.define_service(
    p_module_name => 'test4', 
    p_base_path => 'test4/', 
    p_pattern => 'badsyntax/', 
    p_method => 'GET', 
    p_source_type => ORDS.source_type_collection_feed, 
    p_source => 'SELECT 10', 
    p_items_per_page => 0); 
  COMMIT; 
END; 
/
>curl  --head  -i -X  GET --user DEMO:demo -k http://localhost:8082/ords/demo/test4/badsyntax/
HTTP/1.1 500 Server Error
Content-Type: text/html
Error-Reason: error="resource.generator.evaluation"; error_description*=UTF-8'
'The request could not be processed because an error occurred whilst attempting
 to evaluate the SQL statement associated with this resource. Please check the
 SQL statement is correctly formed and executes without error. 
SQL Error Code ORA-00923 FROM keyword not found where expected  Error Message.
Content-Length: 16514

Oracle REST Data ServicesでのApplication Expressの静的リソースの構成

Oracle REST Data Servicesを使用していて、Oracle Application Expressのページにアクセスしようとすると(たとえば、https://example/ords/を表示しようとすると)空白のページが表示されることがあります。この問題の原因はApplication Expressの静的リソースの不適切な構成にあり、そのためにApplication Expressで必要とするJavaScriptおよびCSSリソースが見つからず、Application Expressのページが正しくレンダリングされません。

具体的な原因として、次のいずれかが考えられます。

  • Application Expressの静的イメージがOracle REST Data Servicesのインスタンスと同じサーバーに配置されていることを確認していない。

  • WebLogic Serverにi.warをデプロイしていない。

  • java -jar ords.war staticコマンドを使用してi.warを生成するときに、誤ったパスを指定した。

  • 静的リソース(/i)にデフォルト以外のコンテキスト・パスを使用してApplication Expressを構成し、java -jar ords.war staticを使用するときに、それと同じコンテキスト・パスを指定していない(--context-pathオプションを使用する)。

  • i.warをデプロイした後で、i.warから参照しているフォルダを移動、名前の変更、または削除した。

  • スタンドアロン・モードで実行していて、スタンドアロン・モードの最初の実行時にメッセージが表示されたときに、誤ったパスを入力した(またはパスを指定しなかった)。

  • スタンドアロン・モードで実行していて、--static-imagesオプションに誤ったパスを入力した。

  • Application Expressを新規バージョンにアップグレードしたが、Application Expressの新規バージョンの静的リソースを指すように i.warを再構成および再デプロイしていないか、またはスタンドアロン・モードで--apex-imagesオプションを使用して場所を更新していない。

問題の診断に役立てるため、apex_version.txtファイルにアクセスしてみることができます。たとえば、Application Expressのデプロイがhttps://example.com/ords/にあり、静的リソースがhttps://example.com/i/にデプロイされている場合、ブラウザを使用して次のURLにアクセスします。

https://example.com/i/apex_version.txt

「404 見つかりません」というエラーになる場合は、i.warがデプロイされていない、Application Expressの静的リソースを含むフォルダを指していない、といった前述の具体的な原因のリストをチェックします。

プレーン・テキストのフ​​ァイルが表示される場合は、次のようなテキストが含まれているはずです。

Application Express Version:  4.2.1

このバージョン番号がデータベースにデプロイされているApplication Expressのバージョンと一致していることを確認してください。番号が一致しない場合は、Oracle REST Data Servicesがデータベース内のApplication Expressのバージョンと一致するApplication Expressの静的リソースの正しいバージョンを使用するように構成されていないので、前述の具体的な原因リストの最後の項目で説明した誤りがないかを確認してください。

問題を解決する上でのヘルプを必要とする場合は、WebLogic Serverなどのご使用環境でのi.warの作成およびデプロイについて、本書内の情報をチェックしてください。

また、コマンド・プロンプトで次のように入力して、静的リスナー・コマンドの詳細なヘルプを表示できます。

java -jar ords.war help static