Skip to main content

Best Practice: Classpath structure for WebSphere Application Server

This best practice was written by the WebSphere Best Practices team.

Summary:  This best practice recommends classes that are stable and do not frequently change should be placed in the static classpath, whereas classes that are frequently changed should be placed in the dynamic classpath.

Date:  08 Aug 2001
Level:  Intermediate
Activity:  920 views

Introduction

The WebSphere® Application Server static system classpath structure is designed for stable packages that the application server uses frequently. The static system classpaths are searched first, followed by the dynamic classpaths. There are two different types of dynamic classpaths: Web Application classpath and Node Dependent classpath. The dynamic classpaths are structured to reflect packages that are subject to change. Classes that are stable and do not frequently change should be placed in the static classpath, whereas classes that are frequently changed should be placed in the dynamic classpath.

This best practice applies to the following product, version, and platform:

  • WebSphere Application Server Base, all platforms, V3.5

Recommendation

There is one application server (static) classpath for each application server in the IBM WebSphere Application Server environment. This classpath is visible to all enterprise beans, servlets, and JSP files contained by an application server. After the application server has started, any changes to this classpath will not take effect until the application server is restarted. Therefore, you should place the following types of classes in the application classpath: classes referenced from servlets whose objects are added to sessions; common classes; classes that call Java Native Interface (JNI) methods; and EJB client JAR files. All of the class types noted have the common characteristic of changing infrequently. If a change is made to any of these classes, the application server has to be stopped and restarted to reflect those changes.

Dynamic classpaths are made up of the Node Dependent and Web Application classpaths. The Node Dependent classpath is visible to all enterprise beans, servlets, and JSP files contained by an application server. The Node Dependent classpath is used to locate EJB JAR classes and their dependent classes while the application server is running. It is checked during run time to locate any helper classes for an enterprise bean that are not contained in the EJB JAR file of the enterprise bean. The Node Dependent classpath is also used during the EJB JAR deployment process for the same purpose.

Additionally, it is important to note that the dependent classpath is used by all application servers in a node. Therefore, it should not contain any common classes requiring different implementations for each application server on the same node. These common classes should be placed in the application server (static) classpath. Classes are not reloaded if they are changed while the application server is running. However, new JAR files or directories can be added to this classpath by using the EJB JAR deployment process even while the application server is running. EJB dependent classes, or classes that are referenced by EJBs in their interfaces, are really the only classes that should be placed on the node dependent classpath.

The second component to the dynamic classpaths are the Web Application classpaths. This classpath is visible to all servlets and JSP files in the Web application. The classpath is monitored and all components (classes or JAR files) are reloaded whenever an update has been automatically detected. All application components must be on the machine containing the application server hosting the application. The Web Application classpath has the following contents: directories or JAR files with servlet classes; directories of JAR files with helper classes that are not included in the servlet JAR file that are expected to be reloadable; and directories or JAR files with Access Bean classes that are referenced from servlet classes and that refer to enterprise beans. A new JAR file is automatically loaded upon detection in any directory already contained in this classpath.


Figure 1. WebSphere Classpath summary table
WebSphere Classpath summary table

System Classpath additional information

The static classpath is made up of three elements:

  • System (Application) classpath.
  • List of JDBC drivers installed on the node.
  • Classpath, which is formed by the administrative server process.

To set the system classpath for an application server:

  1. In the administrative client, select the Topology View and click the application server name.
  2. Select the General tab, select command line arguments, and enter the classpath identifier, -classpath, followed by the classpath entries.
  3. Click the Apply button to save the classpath.

Dynamic classpath additional information

The node classpath applies to all application servers on the same node. This classpath is useful when you want the same packages,for example a third-party application, to be available on any server on the node.

  1. In the administrative client, go to the Topology View and select the node name.
  2. In the General tab, enter the classpath information in the Dependent classpath: field.

The Web Application classpath is limited in scope to the servlets and JSPs within a single Web application. This isolates the individual Web application so that changes impact it alone.

To set the Web application classpath:

  1. In the administrative client, go to the Topology View and select the application server name.
  2. Expand the server.
  3. Expand the Servlet Engine.
  4. Select the Web application by name and verify on the General tab that you are working with the correct Web application.
  5. Select the Advanced tab and examine the Document Root field. It should contain the path to the HTML and JSPs for this Web application. The classpath field should contain the directory to where the Servlets and Class/Jar files are located.

After changes are made, click Apply to save them.


Alternative

You could place all of your classes or JAR files in the static application classpath and experience no class reloading when a class is updated. Likewise, you could place all of your classes in one of the dynamic classpaths and incur the overhead of monitoring for updates to the static classes.


Resources

About the author

This best practice was written by the WebSphere Best Practices team.

Comments (Undergoing maintenance)



Trademarks  |  My developerWorks terms and conditions

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere
ArticleID=13898
ArticleTitle=Best Practice: Classpath structure for WebSphere Application Server
publish-date=08082001
author1-email=WebSphere_Best_Practices@us.ibm.com
author1-email-cc=

My developerWorks community

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Rate a product. Write a review.

Special offers