Reputation: 145
I'm trying to use a class mediator with the WSO2 ESB.
Following is my mediator class.
package samples.mediators;
import org.apache.synapse.MessageContext;
import org.apache.synapse.mediators.AbstractMediator;
public class SiriBankMediator extends AbstractMediator {
@Override
public boolean mediate(MessageContext messageContext) {
System.out.println("Hurraaaayyyy!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
return false;
}
}
As suggested by Writing a WSO2 ESB Mediator, I tried the "Easier Way", created a jar with synapse-core_2.1.0.wso2v8.jar included in class path.
MANIFEST.MF is as follows
Manifest-Version: 1.0
Class-Path: synapse-core_2.1.0.wso2v8.jar
Created-By: 1.7.0_07 (Oracle Corporation)
And then as article suggested, dropped the jar to repository/components/lib in the ESB.
But after ESB restart when I try to load class it gives the error Class not found in the path
Jar file used is shared at siri.jar
Wonder what is missing in the steps I followed.
Thank you in advance.
Note: I used WSO2 Enterprise Service Bus 4.5.1
Upvotes: 2
Views: 3496
Reputation: 1947
This answer might not useful for you because this was asked like 2 years ago but anyone else came across this issue will be find my answer useful.
Just use package name other than samples.mediators that'll solve this issue. cheers..!
Upvotes: 0
Reputation: 1
try with your mediator class package name with at least three letters ,
example : package samples.mediators;
instead of that package name , try, package samples.mediators.anything;
Upvotes: 0
Reputation: 1213
I've successfully deployed your custom mediator using the maven approach. Here's what I've done.
I created the following directory structure and placed your SiriBankMediator.java in src/main/java:
.
├── pom.xml
├── src
│ └── main
│ └── java
│ └── SiriBankMediator.java
The pom.xml file is as follows:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.samples.mediator</groupId>
<artifactId>siribankmediator</artifactId>
<version>1.0</version>
<repositories>
<repository>
<id>wso2-maven2-repository</id>
<url>http://dist.wso2.org/maven2</url>
</repository>
<repository>
<id>apache-Incubating-repo</id>
<name>Maven Incubating Repository</name>
<url>http://people.apache.org/repo/m2-incubating-repository</url>
</repository>
<repository>
<id>apache-maven2-repo</id>
<name>Apache Maven2 Repository</name>
<url>http://repo1.maven.org/maven2/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>org.test</Bundle-SymbolicName>
<Bundle-Name>org.test</Bundle-Name>
<Export-Package>
org.test.mediator.*,
</Export-Package>
<Import-Package>
*; resolution:=optional
</Import-Package>
<Fragment-Host>synapse-core</Fragment-Host>
</instructions>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>fully.qualified.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.synapse</groupId>
<artifactId>synapse-core</artifactId>
<version>1.3.0.wso2v1</version>
</dependency>
</dependencies>
</project>
Then inside the directory containing the POM file, we do mvn compile package
. This should build the jar file you need to put inside of $ESB_HOME/repository/components/lib
in the folder called target.
Finally you can load the class as org.samples.mediator.SiriBankMediator through the carbon management frontend. Don't forget to restart your ESB. Hope that helps. :)
Upvotes: 6
Reputation: 4729
My Manifest of my Custom Mediator jars look like this:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.3
Created-By: 1.6.0_27-b07 (Sun Microsystems Inc.)
So maybe do not add that classpath and if this does not work, try to build with a Java 1.6 version. Then it should all be fine.
Remember add your jar in "components/lib". Check the "components/dropins" folder after startup if WSO2 ESB has created a OSGi bundle of your jar. Then the class should be available.
Upvotes: 1