During a project, we usually integrate third-party libraries to perform various tasks, for example, calculating the digest value or connecting to the credit card gateway. This recipe will explain how to add third-party libraries into JDeveloper projects. Since the book scope aims at BPEL and Java, we will be most interested in how to include third-party libraries to be utilized in BPEL processes. When we use third-party libraries only in one BPEL process, then we can deploy a third-party library in the BPEL process deployment package. When multiple BPEL processes are using the same third-party libraries, then we can deploy them as described in the Adding third-party libraries to the SOA Suite server recipe to avoid unnecessary redundancy.
We will add the same third-party library to JDeveloper as we did in the Adding third-party libraries to the SOA Suite server recipe; that is, Apache Commons Codec
.
To add third-party libraries to the JDeveloper project, we need to copy the libraries to the SCA-INF/lib
directory. That way, the libraries are included in the build phase and deployment phase of the project.
The SOA projects in JDeveloper have a placeholder (SCA-INF/lib
) where we put the libraries. This also ensures that libraries are picked by the make process that packs the libraries into the deployment package.
The procedure we described in this recipe can be taken into account when we don't have the same set of libraries already deployed in the Oracle SOA Suite server. In cases where the libraries already exist in the Oracle SOA Suite server, we have other options with which to add libraries to the JDeveloper projects. The following two procedures describe the user-defined libraries in JDeveloper and reference the libraries from the JDeveloper project properties. In these scenarios, we reference the third-party libraries and use them inside the BPEL process; however, we don't pack them into the BPEL process deployment package.
The user libraries in JDeveloper present a group of JARs packed into contextually similar definitions, for example, BPEL Runtime, SOA Runtime, and so on:
This procedure is useful in cases where we don't have multiple JARs to be references and defining a user-defined library presents a work overhead. We are referencing the third-party library directly from the project. Right-click on the project and navigate to Project Properties. From the tree in the dialog, select Libraries and Classpath and then click on Add JAR/Directory... At the opened dialog, search for the library and click on the Select button as shown in the following screenshot:
New library now appears under the classpath entries in the project properties dialog.