はじめに
標準のEndpoint With ProxyのAPIプロキシに、ビルドが必要なカスタムをする機会があり、そこで発生したエラーについて回避方法を説明したいと思います。
セキュアプロパティの追加は直接Jarファイルを編集することで対応できますので、必要な場合にご利用ください。
躓きポイント
標準のEndpoint With ProxyをStudioで編集しデプロイした際に、Runtime Managerで起動すると、MuleのエクステンションのHTTPとProxyの依存関係によりエラーが発生します。解消する方法は暫定的な方法ですがpom.xmlファイルを編集し、依存関係を明示的に解決する必要があります。
Runtime Managerで起動時に発生するエラー
Worker(3.22.249.140): Your application has failed with exception java.lang.IllegalStateException: com.mulesoft.ch.services.agent.muleAgent.MuleAgentException: {"errorType":"class java.lang.IllegalArgumentException", "errorMessage":"There was an error on the Mule Runtime while deploying the application apiproxy2. Error: Failed to deploy from URI: file:/tmp/mule-received-artifact-7054385183534273877/apiproxy2.jar. DuplicateExportedPackageException: There are multiple artifacts exporting the same package:
Package org.mule.extension.http.api is exported on artifacts: rest-validator, HTTP" }
Anypoint Studioで起動時に発生するエラー
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Failed to deploy artifact 'apiproxy-gateway', see below +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ERROR 2020-06-24 05:07:13,444 [WrapperListener_start_runner] org.mule.runtime.module.deployment.internal.DefaultArchiveDeployer: There are multiple artifacts exporting the same package:
Package org.mule.extension.http.api is exported on artifacts: rest-validator, HTTP
org.mule.runtime.deployment.model.internal.plugin.DuplicateExportedPackageException: There are multiple artifacts exporting the same package:
Package org.mule.extension.http.api is exported on artifacts: rest-validator, HTTP
at org.mule.runtime.module.deployment.impl.internal.plugin.BundlePluginDependenciesResolver.verifyPluginExportedPackages(BundlePluginDependenciesResolver.java:185) ~[mule-module-deployment-model-impl-4.2.2.jar:4.2.2]
参考資料
- Q&A:Unable to deploy proxy application downloaded from API Manager
- Issue Ticket:DuplicateExportedPackageException: There are multiple artifacts exporting the same package
カスタマイズ方法
APIマネージャでAPIプロキシを作成しカスタマイズを行います。カスタマイズ手順は以下の通りです。
- Endpoint With ProxyのJARファイルダウンロード
- EEリポジトリのログイン情報設定
- Anypoint Studioにインポート
- 競合の依存関係を修正
- Cloudhubにデプロイ
Endpoint With ProxyのJARファイルダウンロード
API ManagerのAPI詳細画面のプルダウンからダウンロードすることができます。新規でEndpoint With Proxyで作成する場合は、API Proxyをデプロイしてからダウンロードすることをお勧めします。API DiscoveryのクライアントIDなど、設定すべきプロパティ値は自動で設定されているほうが構築がスムーズになります。
EEリポジトリのログイン情報設定
設定することでEEリポジトリに格納されているライブラリをダウンロードできます。
ログイン情報は、Muleのカスタマーサポートにケースを登録して取得する必要があります。
Anypoint Studioにインポート
インポートの”Packaged mule application(.jar)”を選択肢し、ダウンロードしたJarファイルをインポートする。
競合の依存関係を修正
デプロイ時に発生する依存関係に関するエラーを解消するためにpom.xmlの設定を変更します。
pom.xmlではexclusionsを宣言することで除外していますが、Runtime Managerの起動時にうまく動いてないようです。
Cloudhubにデプロイ
APIのアプリケーション名を指定して既存のEndpoint With Proxyを上書きする。
最後に
いかがだったでしょうか?
依存関係を明示的に定義する方法は色々とあると思います。暫定的な対処法ですがご紹介させていただきました。
参考までにご活用ください。では!