問題描述
在路徑中找不到 WSO2ESB 自定義中介 Java 類 (WSO2ESB Custom Mediator Java Class is not found in the path)
我使用 WSO2 Developer Studio 創建了項目。在 src/main/java
我創建了包 samples.mediators
在該包中的類 UnzipFileMediator
:
package samples.mediators;
import org.apache.synapse.MessageContext;
import org.apache.synapse.mediators.AbstractMediator;
public class UnzipFileMediator extends AbstractMediator {
public boolean mediate(MessageContext context) {
// TODO Implement your mediation logic here
System.out.println("UnzipFile Mediation entered");
return true;
}
}
按照以下說明部署代碼:
右鍵單擊項目並選擇將項目導出為可部署存檔。
- < p>它創建了名為 Unzip.jar 的 jar 文件
我將 Jar 文件部署到
/repository/components/lib
目錄.
在突觸配置中我這樣調用類
<class name="samples.mediators.UnzipFileMediator"></class>
但是當我嘗試保存它時,它會產生以下錯誤:
org.apache.axis2.AxisFault: Class samples.mediators.UnzipFileMediator not found in the path
我在這裡做錯了什麼?
參考解法
方法 1:
Use a different package name.
Because the namespace (or package) samples.mediators
is already used by WSO2 in a different jar. You had deployed now a second jar with the same package name, these classes will not be found in the Classpath by WSO2.
Choose for your own classes a correct package (namespace) with your company name like com.mycompany.mediators
.
(by Mohammad Irfan、FiveO)