简体   繁体   中英

Deploy a custom mediator to WSO2 ESB using a CAR

I'm trying to deploy a custom class mediator packed in a .car file. The WSO2 documentation on the subject isn't very specific and there's no example available.

What I've done is:

  1. Wrote a custom class mediator, which works, if deployed as a .jar to $CARBON_HOME/repository/components/lib/
  2. Packaged the above JAR into a .car , which is then manually uploaded to the ESB using Management Console.

The problem: the server fails to find the mediator's class:

[2017-01-30 18:12:37,810]  WARN - SynapseXMLConfigurationFactory Proxy Service configuration: test cannot be built - Continue in fail-safe mode
org.apache.synapse.SynapseException: Error loading class : nl.my.mediators.HashMediator - Class not found
    at org.apache.synapse.config.xml.ClassMediatorFactory.createSpecificMediator(ClassMediatorFactory.java:107)
    at org.apache.synapse.config.xml.AbstractMediatorFactory.createMediator(AbstractMediatorFactory.java:94)
...

The .car file does contain the .jar in question:

Archive:  mediators-v1_1_1.1.3-SNAPSHOT.car
  Length      Date    Time    Name
---------  ---------- -----   ----
...
        0  2017-01-30 18:07   ca-mediators_1.1.3-SNAPSHOT/
     5399  2017-01-30 18:07   ca-mediators_1.1.3-SNAPSHOT/ca-mediators-1.1.3-SNAPSHOT.jar
      257  2017-01-30 18:07   ca-mediators_1.1.3-SNAPSHOT/artifact.xml
...

But, apparently, it's not picked up by the ESB. The artifact.xml file generated by the maven-car-plugin (which lacks documentation completely, by the way):

<?xml version="1.0" encoding="UTF-8"?><artifact name="ca-mediators" version="1.1.3-SNAPSHOT" type="lib/library/bundle" serverRole="EnterpriseServiceBus">
    <file>ca-mediators-1.1.3-SNAPSHOT.jar</file>
</artifact>

How can I make ESB pick up the classes in my JAR?

This problem is described in WSO2 documentation on extending the ESB:

When we ship the mediator through a CAR file, the mediator is accessible only to the artifacts (sequences, proxy services, APIs) available in the same CAR file. The mediator is not available globally.

The solution is proposed on the same page further on:

  • Write a sequence which engages the class mediator
  • Pack the sequence from the same CAR file which contains the class mediator
  • Call the sequence from other artifacts

I tried that and it worked out.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM