Skip to Content

Since I had a lot of trouble using external libraries in the SAP component world, I decided to share the knowledge in this weblogs. This blog shows you the neccessary steps to use an external library DC in your Java application using SAP NW CE 7.1. Part I gives you the necessary background and Part II really shows you how to do it in the NW Dev. Studio.

External Libraries can be deployed on the AS Java in two different ways.

  • As standalone library. In this case, the application is deployed as an EAR archive and other  applications on the AS Java can use this external library too.
  • As bundled library. The external library is packaged and deployed with your own application.

 

Bundled case: You have your own application consisting of 3 DC’s. A web module DC (Web DC), a EJB module (EJB DC) and the EAR project (EAR 1 DC). Your external library is packed in the extLib DC, which is packaged into the EAR 1 DC and also deployed with the EAR 1 DC. 

image

The EAR 1 DC must have dependencies (build time) to the assembly public part of the EJB DC and the assembly public part of the Web DC. This dependencies are created automatically, when you assign your Web and EJB modules to your EAR project. Public parts of type assembly can be packaged into the build result of the EAR file for deployment reasons. This means that the WAR archive (from the Web Module), the EJB.jar archive (from the EJB module) and the external library jar file are added to the EAR 1 DC.

If you want to bundle an external library with your EAR 1 DC, you must first create a DC of type external library and also create a dependency from your EAR 1 DC to the assembly public part of your external library DC. After you have defined this dependency the external library files are automatically added to the EAR 1 archive and finally deployed with the application.
In order to use the external library classes for example in your Web DC, you must additionally add a dependency from your Web DC to the compilation public part of your external library DC.

 

 

Standalone case: You have your own application consisting of 3 DC’s. A web module DC (Web DC), a EJB module (EJB DC) and the EAR project (EAR 1 DC). Your external library is packed in the extLib DC, which is packaged in the corresponding EAR 2 DC. You can now deploy your external library (EAR 2 DC) like any other application. To use the external library from your application, you have to set a runtime dependency from your EAR 1 DC to the EAR 2 DC.

image 

If you want to deploy your external library standalone, you must create a external library DC and a new EAR 2 DC, which references the assembly public part of your external library DC. After you have defined this dependency the external library files (jar files) are automatically added to the EAR 2 archive. The EAR 2 DC can now be deployed like a normal application.
If you want to use the external library in your own application (EAR 1 DC), you must add a runtime dependency between your EAR 1 DC and the EAR 2 DC.
To be able to use the library classes for example in your Web DC, you also must add a dependency from your Web DC to the compilation public part of your external library DC.  

In the next blog, I willl show you step by step how to do this in NW Dev. Studio

To report this post you need to login first.

4 Comments

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

  1. Samuel Valis
    Nice summary. Would it be possible to extend the ‘standalone’ case so that the external library EAR is build in another track? The runtime reference could be done, but the compilation seems to be a problem, as we cannot reference components from another track. Do you know if it’s possible to ‘import’ this lib into the track similar to standard SAP libraries?
    (0) 
    1. Timo Renner
      Hi,

      the only thing you have to do when developing the DCs in different tracks is to:
      – create an SC dependency from your SC to the SC containing the library DCs (I assume they are in different SCs)
      – create a track connection between the two tracks forwarding at least the SC containing the library DCs

      That’s all. 🙂

      Best regards,
      Timo

      (0) 
  2. VINCENZO TURCO
    Hi, thanks for sharing
    I am spending lots of time on having DC working at runtime, could you  please point out if this procedure might work also for nw70 sp13 on?
    Thanks and best regards
    Vincenzo
    (0) 
  3. VINCENZO TURCO
    Hi, thanks for sharing
    I am spending lots of time on having DC working at runtime, could you  please point out if this procedure might work also for nw70 sp13 on?
    Thanks and best regards
    Vincenzo
    (0) 

Leave a Reply