Skip to Content
Author's profile photo Eng Swee Yeoh

Setup com.equalize.xpi.af.modules Adapter Module project in NWDS easily using EGit

Introduction

When I first shared on SCN the custom adapter modules that I developed, I hoped that it would be beneficial to others who require similar solutions for their requirement. My intention was to bridge some of the gaps in SAP’s own standard offering (some gaps which have been around for far too long!) by providing highly reusable solutions.

I have been pleasantly surprised by the response of SCN members to the com.equalize.xpi.af.modules suite of adapter modules (FormatConversionBean, AttachmentSplitterBean and DynamicAttributeChangeBean). As I have provided the EAR file that can be used for direct deployment to PI/PO 7.31/7.4 (and I believe it should also work in PI/PO 7.3), many have deployed it on their systems and provided feedback that the modules are working well. Some have also provided feedback on issues and bugs which have helped me improve the modules further.

Occasionally, there are some requests on setting up the project in NWDS (based on the source codes I provide in GitHub) in order to further customize the solution. Although the blog Recompile com.equalize.xpi.af.modules as EJB 2.1 modules in NWDS 7.1x was written with the intention to enable those working on older PI systems to compile the modules, the procedures are also relevant for NWDS 7.3x and higher.

As I use EGit more and more in my daily routine, it has provided various valuable ways to enhance my workflow such as using EGit to quickly create an Adapter Module’s EJB & EAR project.

Similarly, for those working on NWDS 7.3x and higher and interested in customizing these adapter modules, it is much easier to use EGit to setup the project from the GitHub repository (instead of the steps in the blog for NWDS 7.1x). I have since restructured the GitHub repository so that it can be easily cloned and imported into an Eclipse/NWDS workspace. In this blog, I will share the steps of how this can be achieved relatively easily. I hope this will be useful for those who are interested in customizing/enhancing this solution further.

Prerequisite

Note: This blog assumes that a working setup of an NWDS installation is already in place. There are many blogs in SCN that already covers that topic.

1. EGit installation and configuration

EGit comes pre-installed in an NWDS 7.5 bundle. For NWDS 7.3x, follow the Installation section of the following blog.

Using EGit for Java source code management in NWDS

Once it is installed, complete the Initial Configuration section of the above blog.

2. PI Adapter Module library files

Although NWDS 7.3x onwards provides built in XPI Adapter Libraries, these are reduced copies and do not contain all classes compared to the libraries which are on the system. Some of the logic in the custom adapter modules refer to some classes which are not available in these reduced libraries. As such, the following JAR files need to be retrieved from the PI system.

  • com.sap.aii.af.cpa.svc.api.jar
  • com.sap.aii.af.ms.ifc_api.jar

Refer to the following Wiki for the location of these files and how to get them.

Where to get the libraries for XI development – Process Integration – SCN Wiki

3. Apache POI library files

Download the following Apache POI 3.9 library files, and extract the JAR files to a folder named Apache_POI in the local file system.

Apache POI 3.9 ZIP file

Step by Step Procedure

Step 1 – Clone Git repository and Import Projects to NWDS

Go to the Git repository on the following site and click Copy to clipboard.

GitHub – engswee/equalize-xpi-modules

/wp-content/uploads/2016/01/github_872905.png

In NWDS, switch to Git perspective, and select Clone a Git repository.

/wp-content/uploads/2016/01/clone_872909.png

The cloning wizard will be auto populated with the GitHub repository details. Click Next twice.

/wp-content/uploads/2016/01/git_repo_872911.png

Select an appropriate location to store the Git repository locally. In the same step, select Import all existing projects after clone finishes.

/wp-content/uploads/2016/01/folder_872912.png

Switch to the Java EE perspective, and the following 4 projects will be listed in the Project explorer. The first two are the EAR and EJB projects, followed by a standalone testing project, and lastly a Java project which the EJB project is dependent on.

/wp-content/uploads/2016/01/projects_872919.png

Step 2 – Resolve JRE System Library

The projects were originally developed using SAP JVM 6. If a different JDK is used in your system, the JRE System Library needs to be updated accordingly.

Right click on the EJB project, select Build Path > Configure Build Path.

/wp-content/uploads/2016/01/libs_872920.png

For example, if this was imported into an NWDS 7.5 installation (which supports Java 8), we can switch it to JDK 1.8.

/wp-content/uploads/2016/01/jdk_872921.png

Step 3 – Resolve classpath variable for Apache POI libraries

The Apache POI libraries need to be bundled together in the EAR file during deployment. As such, they are included in the build path of the EJB project as classpath variables.

Go to Window > Preferences > Java > Build Path > Classpath Variables. Select New.

/wp-content/uploads/2016/01/variables_872922.png

Add a new entry named EXT_LIB, and select the parent folder where the Apache_POI folder reside. In the example below, select Library.

/wp-content/uploads/2016/01/ext_lib_872923.png

Save all the settings and when the following prompt is displayed, select Yes.

/wp-content/uploads/2016/01/build_872927.png

Step 4 – Resolve user library for PI adapter module libraries

Since the PI adapter module library files already exists in the system, they do not need to be bundled in the EAR file. Instead they are referenced in the EJB project as user libraries.

Go to Windows > Preferences > Java > Build Path > User Libraries. Select New.

Add a new user library named PI_LIB.

/wp-content/uploads/2016/01/user_lib_872929.png

Click Add External JARs to the new user library.

/wp-content/uploads/2016/01/ext_jar_872937.png

Select the following two JAR files (which should already be downloaded based on the Prerequisite section).

/wp-content/uploads/2016/01/af_lib_872936.png

Save all the settings. At this point, all the build path should be resolved and all classes should compile and build successfully.

For this point, furthercustomization to the codes can be performed.

Assigned Tags

      16 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Andres Guerrero
      Andres Guerrero

      Hi Eng,

      Im having a problem compiling the EJB project, i have done all the steps but i can´t fix this:

      /wp-content/uploads/2016/07/error_1003008.jpg

      i am using SAP Enhancement Package 1 for SAP NetWeaver Developer Studio 7.3, thanks for your help.

      Note: the JDK version is 1.6.0_45

      Author's profile photo Eng Swee Yeoh
      Eng Swee Yeoh
      Blog Post Author

      Hi Andres

      From your screenshot, there seems to be nothing under PI_LIB. You might want to check if you have completed step 4 which adds the external JARs listed under prerequisite item 2.

      /wp-content/uploads/2016/07/pi_lib_1003139.png

      If you still have any issues, please raise it as a discussion thread since the comment section in the blog is not the appropriate area for resolving issues.

      Regards

      Eng Swee

      Author's profile photo Andres Guerrero
      Andres Guerrero

      Hi Eng,

      i found the problem, i was using the wrong version of the nwds, i found the solotion thanks of one of your posts.

      THANKS.

      Regards

      Andres Guerrero.

      Author's profile photo Former Member
      Former Member

      Hi Eng,

      I was able to able to build successfully. Can you provide instructions on exporting it as an EAR file?

      Since there are three seperate packages - com.equalize.xpi.af.modules.app, com.equalize.spi.af.modules.ejb and com.equalize.xpi.util, do I need to export three SAP Ear files and deploy them?

      I selected all three packages and exported as a single SAP EAR file. Once I added it via SAP MMC I get the below error -

       Software delivery unit located in <E:\Install\New Module\equalize-xpi-modules-masterEAR.ear> is rejected because of
       the following reasons: Component equalize.com/com.equalize.xpi.af.modules.app cannot be installed.
      Component com.equalize.xpi.af.modules.app is not part of any existing software components
       (SC).

      Thanks,
      Rahul

      Author's profile photo Eng Swee Yeoh
      Eng Swee Yeoh
      Blog Post Author

      Hi Rahul

       

      You just have to export the EAR project com.equalize.xpi.af.modules.app as an SAP EAR file. Alternatively, you can follow step 4.12 in the following document to deploy directly from NWDS.

      https://archive.sap.com/documents/docs/DOC-16229

       

      Regards

      Eng Swee

      Author's profile photo Former Member
      Former Member

      Hi Eng Swee,

      thanks for your great blog, and the incredible helpful module.

      I am having trouble adding the external Apache JARs to the project. It seems as if in newer NWDS versions choosing "Add/Remove" on the EAR Project does not work properly.

      Usually it should open a window with "Java EE Module Dependencies", where I would like to add the Apache JARs, but this is not available anymore. I tested it with an old and new NWDS version. See a screenshot of a new WDS version below, on the right side you see the lacking options from the popup when choosing "Add/Remove".

      Do you have an Idea how I can get the Apache JARs into the EAR file? I tried copying the JARs manually, which is no good solution, but even that didn't work. For deployment I use the deployment view (not sure if this is linked with NWDI, but we use NWDI).

      Thanks
      Elias 

      Author's profile photo Eng Swee Yeoh
      Eng Swee Yeoh
      Blog Post Author

      Hi Elias

       

      I haven't tried out the newer NWDS version, so I can't comment. But looking from your screenshots, it looks like you are trying to add directly to the EAR project's library. Please refer again to step 3, where you need to do this in the general Eclipse preference as classpath variables.

       

      Regards

      Eng Swee

      Author's profile photo Former Member
      Former Member

      Hi Eng Swee,

      thanks for your answer. I should have explained my problem a bit more.

      First off, I didn’t get it working with the Classpath, and was searching for an alternative. I entered the Classpath (1) but didn’t get the popup you mentioned in your blog. Nontheless I cleaned and built the project manually. But this didn’t work (2). The Classpath Variable points to a folder where all Apache JARs are situated, in the root folder as well as in a subfolder Apache_POI (3).

      If I added the JARs manually to the EJB project as external JARs, it works as far as that I am able to resolve all errors in the project. But they are still missing in the EAR file I want to deploy, so that’s no solution.

      Am I doing something wrong? How do I get the apache JARs being recognized by the project, and have them in the deployed EAR as well?

       

      The second strange thing I encountered, if I deploy the EAR without the Apache JARs I (certainly) get the error message that an Apache class is missing (4). But if I add them manually to the EAR (5), I am getting an error that the AuditLogHelper is not found (6), although it is in the according jar in the ear (5).

      I thought about messing with the application-j2ee-engine.xml, but as far as I know this is only for referencing other globally available libraries.

      Do you have any ideas on that?

      Thanks for your support!

      Elias

      Author's profile photo Eng Swee Yeoh
      Eng Swee Yeoh
      Blog Post Author

      Hi Elias

       

      Can you show me the full screenshot from 1? There should be a few buttons (New, Edit, Remove) on the right side of the defined classpath variables. If it's there, can you show me the screenshot when you click on Edit?

       

      Regards

      Eng Swee

      Author's profile photo Former Member
      Former Member

      Hi Eng Swee,

      sure, see below.

      Best Regards

      Elias

      Author's profile photo Eng Swee Yeoh
      Eng Swee Yeoh
      Blog Post Author

      Hi Elias

       

      Your classpath setup looks fine. I'm not sure why it's not working for you. I would suggest you do a full rebuild of the project in your workspace.

       

      Regards

      Eng Swee

      Author's profile photo Former Member
      Former Member

      Hi Eng Swee,

      I tried that several times, but unfortunately it makes no difference.

      Lets assume I can't solve the problem with the classpath, do you have an idea why I get the error (4), although all JARs seem to be in the EAR file (5)?

       

      Thanks

      Elias

      Author's profile photo Eng Swee Yeoh
      Eng Swee Yeoh
      Blog Post Author

       

      Hi Elias

       

      The only thing I can think of is to check if your deployment was done correctly. Did you make sure to export it as an SAP EAR file?

       

      You can check in Java Class Loader Viewer (under NWA), to see if the external libraries were included during deployment (under Resources tab of the selected component).

       

      Regards

      Eng Swee

      Author's profile photo Former Member
      Former Member

       

      Hi Eng Swee,

      thanks, the Java Class Loder View did the trick. There was a second EAR library visible, with a slightly different name, which I deployed beforehand while testing. Although I undeployed that one, it was still present in the classloader view. This EAR lacked the necessary Apache libraries.

      I checked the deployment view again, it was not there. To get rid of the library, we restarted the system, now it works.

      I still have to add the Apache libraries manually, but I can live with that.

      Thanks again for your support!
      Elias

      Author's profile photo Eng Swee Yeoh
      Eng Swee Yeoh
      Blog Post Author

      Great to hear at least you found a workaround! 😉

       

      Author's profile photo Rajesh Aravapalli
      Rajesh Aravapalli

      Hi Eng Swee,

       

      We got the below error while installing  the com.equalize.xpi.af.modules.app.ear file directly   using SUM.

      Are we missing anything?

      Error:

      Component equalize.com/com.equalize.xpi.af.modules.app cannot be installed. Component com.equalize.xpi.af.modules.app is not part of any existing software components.

       

       

      Regards,

      Rajesh.A