• No results found

Understanding class paths in Java EE projects with Rational Application Developer Version 8.0

N/A
N/A
Protected

Academic year: 2021

Share "Understanding class paths in Java EE projects with Rational Application Developer Version 8.0"

Copied!
9
0
0

Loading.... (view fulltext now)

Full text

(1)

Understanding class paths in Java EE

projects with Rational Application

Developer Version 8.0

by Neeraj Agrawal, IBM

This article describes a variety of class path scenarios for Java™ EE 1.4 projects and Java EE 5.0 and above projects using IBM ® Rational ®Application Developer Version 8.0.

From a runtime perspective, in Java EE modules until version 1.4 :

a. The modules of an EAR file access other modules by specifying an entry in the MANIFEST.MF file.

b. Web modules also have access to JAR files inside its \WEB-INF\lib folder.

In Java EE 5.0 and above modules, the JAR files in the lib folder of an EAR file are also available in the class path of the modules without an explicit MANIFEST.MF entry.

Common classpath scenarios

Let us understand how to configure the class path in the module projects of a sample EAR file : Figure 1: Java EE 1.4 projects

(2)

Page 2 of 9

Figure 2: Web project Java Build Path

This approach might appear to work well in Rational Application Developer since you do not see any compilation errors. However, as soon as you deploy the application to WebSphere®

Application Server, you will start seeing ClassNotFound exceptions. The reason for these exceptions is that you did not put an entry in the manifest of the Web project.

The correct way of configuring the class path is to open the deployment assembly page of the Web project. Right-click your Web project and select Properties > Deployment Assembly. On the Deployment Assembly page, add a reference to the EJB project as shown below on the Manifest Entries tab.

(3)

Figure 3: Deployment Assembly Page

Once you add a reference, you will notice that the EAR Libraries are updated with the EJB project.

(4)

Page 4 of 9

EAR Libraries: is a container which provides the JAR file from your manifest into the project class path so that you do not need to perform an additional step to configure the Java Build path yourself as covered in Figure 2. The User library scenario is covered later which automatically populates EAR Libraries.

Web App Libraries: If you pay close attention in Figure 4 you will notice that there is an empty folder called Web App Libraries. This folder is also a container which provides JAR files placed in the WEB-INF\lib folder into the project class path of the Web project.

There are two common ways to put a JAR file inside WEB-INF\lib:

a. By physically dropping inside the folder which is typically found under \WebContent\WEB-INF\lib or

b. Logically mapping a JAR file to \WEB-INF\lib which is achieved using the deployment assembly properties page (refer to Figure 3). On the deployment assembly properties page, click the Deployment Assembly tab and select Add.

Figure 5: Deployment assembly reference wizard

You can choose Archive, External Archive and Variable to configure the JAR file. This JAR file is deployed properly on WebSphere Application Server when you choose to run your EAR file, likewise, if you export the EAR file you will see the JAR file being bundled in the archive.

(5)

In the example below, I have added log4j.jar which is placed somewhere in my disk. You will notice that the Web App Libraries container is updated.

Figure 6: External JAR file configured in a Web project

You can also make another project in your workspace available to the class path by simply selecting the Project option in Figure 5 and selecting an available project there.

User Library Support for Web Projects

Consider the case where you have a number of JAR files residing in a folder in your disk and you want to use them in your Web project. One approach would be to add each JAR file one by one as discussed under the Web App Libraries section. However, this approach is not only time consuming but not ideal for working in a team environment.

Fortunately, there is a better way to accomplish this task by using User Library support. To use this feature, select Classpath Container as displayed in Figure 5 which opens the Add Library wizard.

(6)

Page 6 of 9

Figure 7: Add Library

Clicking Next opens another wizard page which lets you select User Libraries. The User Library page is also found on the Java >Build Path > User Libraries preference page.

(7)
(8)

Page 8 of 9

Figure 9: Web Project after adding User Library

As mentioned earlier in respect to external archives, user libraries are also logically mapped to \WEB-INF\lib and are deployed properly on WebSphere Application Server.

User Library Support for EAR 5.0/6.0 Projects

In EAR 5.0/6.0 you can use a similar mechanism as discussed under “User Library Support for Web Projects” to configure user defined JAR files. For an EAR file, it is mapped by default to \lib and all the modules of the EAR have visibility of those jars in their class path by means of EAR Libraries.

In the example below I have selected a previously created user library in a 6.0 EAR file. The module of EAR, EAR60EJB automatically finds all the JAR files in its EAR Libraries container. Figure 10: EJB 3.1 project with EAR user libraries configured

(9)

Neeraj Agrawal architects and develops Java EE tools for Rational Application Developer. He is also a contributor to the Eclipse Web Tools Platform. He can be reached at

[email protected]

References

Related documents

(B) the adsorption at a single site on the surface may involve multiple molecules at the same time.. (C) the mass of gas striking a given area of surface is proportional to the

Judith Kates is Professor of Jewish Women's Studies at Hebrew College, currently teaching Bible and Jewish traditions of commentary for the new Rabbinical School

The Cisco MDS 9506 multilayer director provides an open platform that delivers the intelligence and advanced features required to make multilayer intelligent SANs a reality,

 Design advanced active systems (radar, lidar, sonar) for different applications (air traffic control, environmental monitoring, meteo nowcast and forecast,

Shan Foods position statement is “To the confident and convenience seeking woman of today, our wide range of Shan spice mixes offer premium quality products, made

Using the mean absorbance value for each sample, determine the corresponding concentration of CA125 in U/ml from the standard curve..

Contrast to capital one ppi complaint into consideration the salesperson aware of credit card disclosures of your behalf of comparative, as ppi policy, so before the bank.. Falls

Singapore, Singapore – April 28, 2016 – China Yuchai International Limited (NYSE: CYD) (“China Yuchai” or the “Company”), announced today that it will be releasing its