WSO2 ESB use of Custom Mediator - class

I like to write a Custom Mediator for the WSO2 ESB.
I found some Tutorials for this, but I don't get it working in the WSO2 ESB. I think I maybe have an error in the path I need for the Class Mediator, but let me explain everything:
For writing this Mediator I use the WSO2 developer Studio for Eclipse Juno.
There I created a new ESB Mediator Project called "b64writer" with this content:
package org.wso2.carbon;
import org.apache.synapse.MessageContext;
import org.apache.synapse.mediators.AbstractMediator;
public class B64Mediator extends AbstractMediator {
public boolean mediate(MessageContext context) {
// TODO Implement your mediation logic here
String inhalt = context.getEnvelope().toString();
trace.trace("Message: " + inhalt);
return true;
}
}
In the next step I created a new Carbon Application Project, with the Mediator selected on "Dependencies". The config for this is:
Group ID: org.wso2.carbon.b64mediator
Artifact ID: b64mediator
Version: 1.0.0
I used the button on the right side to create an archive. This archive I copied to "C:\wso2esb\repository\carbonapps\0".
And now my question: How can I use this Mediator?
It should work like this:
<class name="org.wso2.carbon.B64Mediator" />
But it isn't. WSO2 ESB can't find the class. Where's my mistake?

Ok, I had the same issue as you, and I managed to add the mediator by using the WSO2 Developer Studio add-on for eclipse to make a mediation library. (Bring up the new wizard box, and select WSO2/Extensions/Project Types/Mediator Project)
Then create your mediator or put into the project, and export it as a jar file to the /repository/components/lib folder. You have to restart the ESB every time you update the jar or if you're running the ESB when you add the jar.
I hope this helps.

Place the archive inside repository/components/dropins or repository/components/lib (if you don't build it as an osgi bundle) directory.

you should deploy class mediators as java Library artifact and refer them from class Mediators. That is, deply the jar you craeted from dev studio and keep taht in repository/components/lib folder and restart the server.
Then refer like;
<class name="org.wso2.carbon.B64Mediator" />
from your sequence

I don't know if you have solved your problem. I had the same issue but I could solved it.
I created my mediator using the WSO2 Developer Studio "Mediator Project" in Eclipse Kepler. Next I exported to Java/JAR file right clicking in my project and selecting "export generated class files and resources" in the properties.
The JAR file you have to place into repository/components/lib folder and restart your ESB

Related

Mule 4 Project Anypoint - import external Jar with Flows and Java

I am using latest Studio and embedded 4.1.5 engine.
I created a CommonProject with some reusable flows.
1 of the flow is using DW2.0 and is using a local class to cast the result of the transformation. CommonProject and DW work on its own.
Then I created a second project CallerProject. Added CommonProject as a dependency, and added the CommonProject FLOW via IMPORT:
When I call the CallerProject FLOW that uses the CommonProject imported flow, all seems to be working up to the DW2.0 transformation that is failing since the CLASS is not found.
Error: "Unable to find class ..."
Anything obvious I missed?
The java class is in the CommonProject JAR within the CallerProject JAR
I believe you want to import a project JAR file. The steps for that is:- File-> import -> Anypoint Studio -> Packaged Mule application(.jar).
You didn't mention mavenizing your flow.
This should help:
https://support.mulesoft.com/s/article/How-to-add-a-call-to-an-external-flow-in-Mule-4

WSO2 Composite Application-unable to create .car file

When i start with an ESB project and create the Endpoints, Sequences, proxy services and then try to do a Composite Application it will generated poml.xml file. But when i try to create the Archive(.car) it will not be generated. Can anyone please help me out with this? It would be grateful.
Eclipse : kepler
wso2esb-4.8.1

Creating new servlet in eclipse kepler for maven web app project

I created simple maven web application project. After creation there were no 'src/main/java' and 'src/test/java' folders but only 'src/main/resources'.
I added this two folders and updated maven project.
Than I added some package to 'src/main/java' and try to add servlet by right click at package element
At next step I see window with some servlet details
But when I start to add servlet name eclipse shows me message that "Not a java source folder".
By the same way I can add simple class to this pachage without any problem but in case of servlet I cannot. Do I miss something during configuration?
I could not find the cause of the problem, but I solved it restarting Eclipse (I have Eclipse Neon.2 Release (4.6.2)).

Appengine endpoint client library creation in eclipse

I have a java based appengine endpoint project in eclipse.
When I generate client library using command line tool.
https://developers.google.com/appengine/docs/java/endpoints/endpoints_tool
I'm getting only source based jar file ('project_name_version'.java-1.18.0-rc-sources.jar). It does not work fine in Android Studio when I add as a Library.
How can I get class based jar client library (google-api-services-'project_name_verison'-1.18.0-rc.jar)?
I tried searching online but no luck yet.
You could always zip up the sources file and use them in Android Studio. However , note that in the build.gradle file, you will have to reference the other dependent JAR files + versions that will be needed by the sources that you have generated in Eclipse via the Generate Cloud Endpoint Library option.
Build your app engine back end with JRE 7. You can change this from windows->preferences->java->installed JREs. You'll find an Add button at the right side of the pane. For more detail refer this Tutorial
This will solve most of your problems.

Servlet libraries are not defined in Eclipse

I am trying to make a simple servlet in Eclipse. But including the following libraries generates errors as if they were not defined in Eclipse.
import javax.servlet.*;
import javax.servlet.http.*;
How to have them recognised and defined?
Please add servlet-api.jar in classpath of your project.if you are using tomcat server, then it should be present in ${CATALINA_HOME}/lib
Be sure you are doing the right way:
If you are using the Classic version of Eclipse, then you must donwload the Web Tools Platform.
If you have an Eclipse Java EE Edition, then there is already installed the necessary plugins.
Create a new Dynamic Web Project: Menu New > Project > Dynamic Web Project.
Fill all values you want for the new project.
Do right click on the project and select New Servlet.
Last step creates a new Class file that is a servlet class, already importing the necessary packages, such as javax.servlet.http.*.
If you are using a Eclipse with a Maven plugin installed then, after configured it, you can only add the following dependencies:
http://mvnrepository.com/artifact/javax.servlet/servlet-api/2.5
http://mvnrepository.com/artifact/javax.servlet/jstl/1.2
http://mvnrepository.com/artifact/javax.servlet/jsp-api/2.0
In fact, you can see this tutorial explaining very well all the steps to create a Dynamic Web Prroject using WTP.
Or by ugin Maven, this one and this full explained.
Hope this help...