Chapter 30: Configuring Custom Java Class Lists
Since system loaded classes require a server restart to update, use system loading only for classes that never change. For classes that might be refreshed with a component or Web application, add the classes to the custom list. The following sections give more specific guidelines for each entity type.
The standard locations for deploying Java and EJB component class files is the java/classes directory. EAServer also generates the component’s stubs and skeleton classes under this directory.
A Java component’s implementation class and stub classes are automatically part of the custom class list for the component. Add the following additional classes to the custom list:
Stub classes used for intercomponent calls. For EJB local interface calls, you must also configure sharing of the class instances as specified in “Calling local interface methods”.
Other classes that your component loads and passes as parameters or return values for intercomponent calls, or passes to clients as method return values and output parameter values.
For EJB components, classes that extend javax.naming.InitialContext or other javax.naming classes and that are called by your component.
Additional classes that must be reloaded when the component is refreshed. For example, if you are debugging utility classes used by the component, add these classes to the custom list.
Component-specific JAR files should be deployed in the EAServer java/classes subdirectory and added to the custom class list.
To configure the custom list, follow the instructions in “Configuring an entity’s custom class list”.
In EAServer 4.0 and later, these classes and interfaces are ignored when listed in the custom class list.
When loading classes listed in a Java or EJB component custom list, the component class loader searches for classes in this order:
Any JAR file that is listed in the component’s custom class list property and deployed in the EAServer java/classes subdirectory.
Classes listed in the component’s custom class list and deployed under the EAServer java/classes subdirectory.
Classes listed in the component’s custom class list and deployed under the EAServer html/classes subdirectory.
Any JAR file that is listed in the component’s custom class list property and deployed in the EAServer java/lib subdirectory.
If the class is not loaded at this point, it is loaded by the system loader using the search order specified in the server class path—see “The system class loader”.
A Web application’s custom class list must include any classes that must be reloaded when the Web application is refreshed. For example, servlet implementation classes, utility classes called by servlets and JSPs, and stub classes for component invocations should be in the custom class list.
If you deploy classes and JAR files that the standard Web application deployment locations, you do not need to explicitly list them in the custom class list. The standard Web application deployment locations are under your Web application’s context root, the EAServer subdirectory:
Where WebApp is the Web application name. Deploy classes and JAR files to these subdirectories of the context root:
WEB-INF/classes for class files.
WEB-INF/lib for JAR files that contain archived class files.
EAServer automatically adds classes and JAR files that are deployed in the standard locations to the custom class list. Use these locations to deploy classes and JAR files that are specific to your Web application. These directories are equivalent to the like-named directories in a J2EE WAR file.
For classes that are also used in EJB or Java components or other Web applications, you can deploy classes or JAR files in one of the locations below. For example, if your servlet calls an EJB component, you may want the servlet and component to use the same copies of the component stub classes. You must explicitly list these classes or JAR files in your Web application’s custom class list:
The EAServer java/classes or html/classes directory, for class files that are also used by components.
The EAServer java/classes or java/lib directory, for JAR files that are also used by components.
The EAServer extensions subdirectory for JAR files used by multiple Web applications, as described in “Using Java extensions”. These JAR files can be used by any Web application that lists the JAR file name in the custom class list.
Though a component and Web application may custom load the same classes, to enable sharing of one copy of each class, you must configure the same custom class list entries in parent entities up to a common ancestor entity, as described in “Custom class lists for packages, applications, or servers”.
EAServer loads classes listed in the Web application custom class list by searching the following code bases, in the order specified. All of these locations are subdirectories of your EAServer installation directory, app_name represents the name of your Web application, and server is the server where the Web application is installed. If the custom class loader cannot locate a class file, the server attempts to load it using the system class loader.
Class files in work/server/Servlet/WebApp-app_name
This directory contains generated servlet classes for compiled JSPs.
Class files in Repository/WebApplication/app_name/WEB-INF/classes
This is the standard directory for servlet, filter, tag-library, and utility classes used by the Web application. If utility classes are shared with Java components running on the same server, you may wish to move them to the EAServer java/classes subdirectory and add them to the custom class list for your application or server.
JAR files in Repository/WebApplication/app_name/WEB-INF/lib
This is the standard location for JAR files that contain classes to be used only by this Web application. EAServer searches the JAR files in the order specified by the com.sybase.jaguar.webapplication.jarlist property. If you do not JAR files in this property, EAServer searches in directory order; that is, the order that would be returned in a directory listing.
JAR files in extensions
This directory contains JAR files that have been installed as Web application extensions—see “Using Java extensions”. EAServer places these JAR files in the Web application’s default custom class list, in directory order.
JAR files in the java/classes directory that are listed in the custom class list for the servlet, JSP, or Web application.
Class files in the java/classes and html/classes directory that are specified in the custom class list for the servlet, JSP, or Web application.
JAR files in the java/lib directory that are listed in the custom class list for the servlet, JSP, or Web application.
If the class has not been found, the server attempts to load the class using the system class loader, using the search order in the server class path—see “The system class loader”.
For servlets that are installed directly in a server, and not in a Web application, you must define the custom class list in the servlet properties or the properties of the host server. Classes and JAR files for these servlets should be deployed in the EAServer java/classes subdirectory.
You can configure the package, application, or server level class lists to configure sharing of class instances between child entities installed in the package, application, or server. Doing so can decrease server memory use by eliminating copies of custom loaded classes. However, you must also refresh the classes at the level where they are loaded. For example, classes loaded at the server level require a refresh of the entire server.
To configure sharing of custom-loaded classes, first configure the class lists for the Web applications and components that use the class directly, then configure the same entries in the parent entries up to a common ancestor. Make sure the class loader delegation policy is Parent First for entities below this common ancestor. For example, Figure 30-2 shows the entries required to share classes in the JAR file widget.jar and the Java package com.sybase.widgets, loading one copy of the classes at the application level.
Figure 30-2: Example of sharing custom loaded classes
Deploy classes that are shared by multiple entities in one of these common locations:
The java/classes subdirectory, for JAR files that are always custom-loaded (unless you have added the JAR file to the server CLASSPATH setting by listing it in the com.sybase.jaguar.server.jvm.classpath or com.sybase.jaguar.server.jvm.bootclasspath server property).
The java/lib subdirectory, for JAR files that may be system loaded or custom loaded. If an entity’s custom class list contains the JAR file name, the classes are custom loaded. Otherwise, the classes are system loaded, because EAServer adds JAR files in this location to the default server class path at server start-up time.
The class tree rooted in the java/classes or html/classes subdirectory, for class files such as generated EJB stub classes. Use java/classes for server-side code. Use html/classes if the classes are shared with applet clients that load class files directly rather than using a JAR file.
To configure the server, application, or package class list, follow the instructions in “Configuring an entity’s custom class list”.
|Copyright © 2005. Sybase Inc. All rights reserved.|