Skip to Content

SAP HCI is based upon Apache Camel and as such there are many already available components that can be re-used  as adapters in HCI. Looking on the web for a ‘How To’ tutorial results in very few hits with the one ‘useful’ blog being the following (although only about 80% useful!)

Using existing Camel component for Gmail adapter in HCI

With some help from SAP support and by some hands-on development I eventually managed to successfully create a new adapter that deployed and was usable in my integration flows.

 

For this example I have selected the the Apache Camel Weather component (here) to base my new adapter on.

Step 1 – Determine the current version that the tenant is based upon

To ensure that we build the camel component using the correct version of the source, we need to determine what the current camel core that the HCI tenant is using.

  • Open the Integration Operations perspective and select the Component Status View.
  • Filter using the search term ‘camel’
  • Make a note of the Version for the Camel Core (2.17.4.sap-04 in our case)

 

Step 2 – Download Code for the Camel Component and Dependent Jar Files 

The following link lists the available Apache Camel components and there are several options to getting the source/binary for our component.

Download the Binary

  1. Click the ‘Download’ link
  2. Depending on the version you need (2.17.4 in our case) follow the link to the archives.
  3. Select the required version to get to the version page
  4. Choose the binary distribution appropriate to your needs and select the HTTP link

This is where I came unstuck as every link I clicked on failed (so I used GitHub instead – see below)

Use GitHub to Download the Source

  1. Select the GitHub link
  2. Copy the URL to clone the repo
  3. Clone the Repo in Eclipse
  4. Choose the branch
    • Choose the branch closest to the required version (2.17.x) in our case.
  5. Choose destination
  6. Wait…
  7. Create a new local branch (from an existing tag)
  8. Name the branch and click the Select.. button
  9. Choose Tags and select the correct version (2.17.4 in my case)
  10. Click Finish and wait…
  11. You now have the correct version checked out as a local branch

 

NOTE: Steps 3 & 4 Assume that you have downloaded the source from Git and need to build the Jar files for the component

Step 3 – Create the Eclipse Project for the Camel Component

  1. In Eclipse, create a project using the Import…import (right-click menu)
  2. Select Existing Maven Projects
  3. Browse to the camel weather folder in the Git repo, select the pom.xml file. Click Finish
  4. The Camel Weather project should now be available in your Eclipse workspace.

Step 4 – Build the Eclipse Project for the Camel Component

Build the Maven project to generate the Jar file file.

  1. Right-click the project and choose Maven Install
  2. Progress will be shown in the Console
  3. If everything works then you should end up with this message
  4. The Jar should then be here

 

Step 5 – Determine the Compile Dependencies for the Camel Component

When we create the adapter project we will need to include the Jar files of the dependent components.

  1. Double-click the pom.xml file and switch to the Dependency Hierarchy tab
  2. All dependencies with [compile] next to them will be needed
    • NOTE: The camel-core and slf4j-api are installed on the HCI tenant by default and are NOT needed.
  3. Find where the Jar files exist from the Maven Dependencies in the project

Step 6 -Create the Adapter Project based on the Camel Component

  1. Create the new Adapter project, right-click on project explorer and choose New..Project
  2. Provide a project name, adapter name, ID, Version and Vendor
  3. Click Finish
  4. Copy the camel-weather-XX to the ‘component’ schema
  5. Copy the dependency Jars (the ones we determined earlier)  to the ‘libs’ schema
  6. Right-click the adapter project and generate the metadata
  7. This creates the metadata.xml
  8. Right-click Adapter project and Execute Checks
  9. This should pass….
  10. Right-click Adapter Project and Build Adapter Project
  11. This should build…

 

Step 7 – Deploying the Adapter Project

The hardest part of the whole process is actually getting the adapter to deploy successfully to the HCI tenant. If you are (extremely) lucky it will happen first time but you are probably going to run in to some issues which I will cover in Steps 7a and b

  1. Right-click Adapter Project and Deploy Adapter Project
  2. If all is OK the adapter will be in status DEPLOYED but you are unlikely to get this first time and instead the Deploy State will be ERROR
  3. Switch to the Integrations Operation perspective and check the Tail Log.
  4. The most likely error will be similar to this:
    • Unable to resolve /tmp/inputStreamExtract1377190728082992750.zip/jaxb-core-2.2.11.jar: missing 
      requirement org.apache.aries.subsystem.core.archive.ImportPackageRequirement: 
      namespace=osgi.wiring.package, attributes={}, directives={filter=(&(osgi.wiring.package=org.xml.sax)
      (version>=0.0.0))}, resource=/tmp/inputStreamExtract1377190728082992750.zip/jaxb-core-2.2.11.jar was 
      unsuccessfull on node: weather-adapter_yell.com for task: NodePresence 
      {nodeId=8c31c2bc52419443dcf7b2d339225a77ed3599db, baseUri=https://vsa2703301:8041/, nodeType=IFLMAP, 
      productVariant=HCI, nodeCoordinate=NodeCoordinate { account=avrhcie, application=e0401iflmap, 
      tenantId=a17f5e9a1, clusterName=avrhcie.gbt131.e0401 } , version=2.30.15, nodeStackProfileId=iflmap,
       timeStamp=1501929150031} with error message: 1f026a6c-6166-4c86-b997-ffd2ef6a5b9f|
      ​
  5. If the version is shown as 0.0.0 then this indicates a missing dependent Jar file – in this case (org.xml.sax) was NOT one listed in the pom.xml file for the camel component.
  6. To resolve this google for this Jar in maven
  7. Click the link and download the JAR
  8. Add the jar to the libs schema of the adapter project.
  9. Right-click the project and try to Build Adapter Project again…
  10. If the project builds then attempt the deploy once more.

 

Step 7a – Creating an OSGI Bundle for a Jar

If in Step 7  the newly added Jar file is not an OSGI bundle then you will get the following error when you attempt to build the project.

Failed to build project; error -Build failed:Build failed:Dependency libs/sax-2.0.1.jar 
is not a valid OSGi bundle

 

  1. Right-click the Project Explorer and create New..Project
  2. Select ‘Plug-in from Existing JAR Archives’
  3. Select Add External…
  4. Add the non-osgi jar file  (sax-2.0.1 in this case). Click Next..
  5. Create the project (make sure to use the highlighted values)
  6. Right-click project and Export..
  7. Select ‘Deployable plug-ins and fragments’. Click Next..
  8. Click Finish
  9. Go to the folder chosen above (sub-folder \plugins) and copy the jar file
  10. Paste the Jar file to the libs schema of the adapter project
  11. Remove the non-osgi jar version of the file
  12. Right-click adapter project and Build Adapter Project again
  13. Deploy again.
  14. Repeat the process of adding missing jars (and building an OSGI bundle version if required) until the adapter deploys…
    • In my case the project was also missing jar org.w3c.dom and I created another project to create the OSGI bundle for it.
  15. Eventually the adapter project looks like this

 

Step 7b – Other deployment issues

The next error you may get during the deployment is:

Candidate permutation failed due to a conflict between an export and import; will try another if 
possible. (org.osgi.service.resolver.ResolutionException: Uses constraint violation. Unable to resolve 
resource com.sun.xml.bind.jaxb-impl [/tmp/inputStreamExtract3671958431916628783.zip/jaxb-impl-
2.2.11.jar] because it exports package 'com.sun.xml.bind.v2.runtime' and is also exposed to it from 
resource com.sun.xml.bind.jaxb-core [/tmp/inputStreamExtract3671958431916628783.zip/jaxb-core-
2.2.11.jar] via the following dependency chain:|

2017 08 09 15:39:23#+00#INFO#System.out##anonymous#AvatarThreadLOW11599#na#avrhcie#e0401iflmap#web##na#na#na#na#  
com.sun.xml.bind.jaxb-impl [/tmp/inputStreamExtract3671958431916628783.zip/jaxb-impl-2.2.11.jar]|


This basically indicates that we don’t need both the jaxb-core and jaxb-impl jar files in the Adapter Project

  1. Delete the jaxb-impl-2.2.11. The project then looks like this
  2. Build the project
  3. Deploy the project
  4. Success!

 

 

Step 8 – Test the Adapter

Test the adapter using an integration flow.

  1. Create a new project
  2. Define the receiver component to use the new adapter
  3. Configure the adapter (see the Apache Camel Weather component page for what the options do)
    • The AppId can be created on the OpenWeather site here)
    • Location has been hard coded for simplicity (ensure no space between city,country)
  4. Deploy the flow
  5. Test the flow
    • The flow is triggered by a REST request (payload is ignored)

 

To report this post you need to login first.

10 Comments

You must be Logged on to comment or reply to a post.

  1. Farooq Ahmed

    Hi Peter,

    The approach of creating a customized adapter HCI is very well explained.

    But few questions on this as below.

    1. How this new custom adapter will be moved from DEV to QUA/PROD with all having same tenant version. (Is that all the same steps needs to be followed again?)
    2. And what if the Tenant version is different, is there any other way which will be less error prone.

    Thanks,

    Farooq. (FA)

    (0) 
    1. JOnes Peter Post author
      1. I’ve previously defined both test and live tenants in my Eclipse workspace. We switch between the two in the node explorer and then just deploy the adapter to the currently selected tenant

      2. If the tenants are different version then you’ll have to possibly have to build different versions of the adapter using the appropriate versions of the camel components. You may be luck and the tenant version may be backward compatible with the adapter build. Suck it and see!

      1. ddd
      (0) 
  2. Hemachandan A S

    Thanks Jones for sharing this very useful blog and cloud you please advice how to customize existing adapters so that we can try to add required features based on the scenarios just like function modules in SAP PI/PO adapter.

    (0) 
    1. JOnes Peter Post author

      Hi. as we don’t have access to the source  ‘out of the box’ adapters that come with HCI, I’m not sure we can do much. The best you could do is probably create your own duplicate using the available camel adapters source and then use this in your flows rather than the standard version.

      (0) 
  3. Apu Das

    Hi Jones,

    Great blog indeed. Thanks for sharing this elaborately.

    One strange thing when I am trying to replicate the same in my test tenant. At the time of deployment it is giving me below error, but I can see camel-weather in my adapter list.

    Deployment of artifact: org.osgi.service.subsystem.SubsystemException: java.lang.IllegalArgumentException: invalid range “[null,null]”: invalid version “null”: non-numeric “null” was unsuccessful on node: camel_weather_SAP_Vendor for task:

    Tried to undeploy the same from deployed artifacts so that adapter will be removed from adapter list. But. I can see this in adapter list.

    Please help to understand me this better.

     

    Thanks in advance,

    (0) 
    1. JOnes Peter Post author

      Not sure what is causing the error but to if you undeploy the adapter then this should be removed from the tenant  ‘Deployed Artifact’ tab:

      If you mean that the adapter is still showing in the the list of adapters displayed when defining a channel:

      This can be removed by searching for the name of the adapter and then deleting the two files highlighted:

      Restart Eclipse, you’ll probably see an error if the adapter was being used in a flow so just ignore this

       

      After Eclipse re-opens the adapter should now be removed form the list:

       

       

       

       

       

       

       

      (0) 

Leave a Reply