wso2esb如何在可执行类mediator jar中添加所有依赖jar文件

时间:2015-11-19 10:04:15

标签: wso2esb

我使用WSO2 Developer Studio创建了该项目。在src / main / java下我创建了包com.training在该包中的类UnzipFileMediator:

package com.training.mediators;
import org.apache.synapse.MessageContext; 
import org.apache.synapse.mediators.AbstractMediator;

//Import another jar dependent jar
import com.test.Testing;


public class UnzipFileMediator extends AbstractMediator { 

    public boolean mediate(MessageContext context) { 
        // TODO Implement your mediation logic here 
        System.out.println("UnzipFile Mediation entered*****");

       // Dependent JAR class

        Testing t= new Testing();
        t.sayHello();
        return true;
    }
}

在这个项目中,我使用以下步骤

部署了另一个jar
1. Right click on the project
2. Select configure build path
3. Select Java Build Path
4. Select Libraries
5.Click on Add External Jar. Then add the external jar called Hello
6. Hello Jar contain the class Testing
7. Above mentioned class import Dependent Testing class and create the `object and call the function as mentioned below.`
8.import com.test.Testing;
9. Its working fine here.

现在我将在WSO2ESB上部署它,以下是创建Jar文件的步骤:

1. Right click on the project
2. Select Export
3. Select Runnable JAR File
4. Select the check box 
                Package Required libraries into generated JAR
6. JAR is created and available to deploy at WSO2ESB

我将把这个jar部署到WSO2ESB下面的位置是:

1. <ESB_HOME>/repository/components/lib directory.

在synapse配置中,我像这样调用类

<class name="samples.mediators.UnzipFileMediator"></class>

但是当我尝试调用它时。它会产生以下错误:

java.lang.NoClassDefFoundError: com/test/Testing

这是我上面提到的依赖JAR文件类

请指导我做错了什么

1 个答案:

答案 0 :(得分:0)

您可以简单地将该依赖jar放在lib目录中。但请确保两个或更多罐子不包含相同的包装(当它发生时,会发生类加载问题)