Configuring the use of class loaders by an application

You can configure whether your application and web modules use their own class loaders to load classes or use different class loaders, as well as configure the reloading of classes when application files are updated. Class loaders enable an application to access repositories of available classes and resources.

Before you begin

This topic assumes that your application or module is already deployed on a server.

The following note applies to the xmi file references in this topic:
支援的配置 支援的配置: 對於 IBM® 延伸和連結檔而言,.xmi 或 .xml 副檔名取決於您是使用 Java EE 5 之前的應用程式或模組,或 Java™ EE 5 或更新版本的應用程式或模組。 IBM 延伸或連結檔稱為 ibm-*-ext.xmi 或 ibm-*-bnd.xmi,其中 * 是延伸或連結檔的類型,例如:app、application、ejb-jar 或 web。 適用的條件如下:
  • 如果應用程式或模組使用第 5 版之前的 Java EE,副檔名必須是 .xmi。
  • 如果應用程式或模組使用 Java EE 5 或更新的版本,副檔名必須是 .xml。 如果 .xmi 檔是隨附在應用程式或模組,則本產品會忽略 .xmi 檔。

不過,即使應用程式含有 Java EE 5 之前的檔案,且所用的副檔名是 .xmi,其中也可以有 Java EE 5 或更新版本的模組。

ibm-webservices-ext.xmiibm-webservices-bnd.xmiibm-webservicesclient-bnd.xmiibm-webservicesclient-ext.xmiibm-portlet-ext.xmi 檔會繼續使用 .xmi 副檔名。

sptcfg

About this task

Class loaders affect whether your application and its modules find the resources that they need to run effectively. You can select whether your application and web modules use their own class loaders to load classes, or use a parent class loader.

An application class loader groups Enterprise JavaBeans (EJB) modules, shared libraries, resource adapter archives (RAR files), and dependency Java archive (JAR) files associated to an application. Dependency JAR files are JAR files that contain code which can be used by both enterprise beans and servlets.

An application class loader is the parent of a web application archive (WAR) class loader. By default, a web module has its own WAR class loader to load the contents of the web module. The WAR class-loader policy value of an application class loader determines whether the WAR class loader or the application class loader is used to load the contents of the Web module.

You can also select whether classes are reloaded when application files are updated. For EJB modules or any non-web modules, enabling class reloading causes the application server run time to stop and start the application to reload application classes. For web modules such as servlets and JavaServer Pages (JSP) files, a web container reloads a web module only when the IBM extension reloadingEnabled in the ibm-web-ext.xmi file is set to true.

To configure use of class loaders by your application and web modules, use the Class loading and update detection page of the administrative console.

Attention: 如果應用程式在執行中,變更應用程式設定會使應用程式重新啟動。 在獨立式伺服器上,會在儲存變更之後重新啟動應用程式。 在多重伺服器產品上,會在儲存變更之後重新啟動應用程式,在安裝應用程式的節點上,檔案會同步化。 如果要控制多重伺服器產品上的同步化時機,請在「主控台」喜好設定頁面上取消選取與節點同步變更

Procedure

  1. Click Applications > Application Types > WebSphere enterprise applications > application_name > Class loading and update detection to access the Class loading and update detection page.
  2. Specify whether to reload application classes when the application or its files are updated.

    By default, class reloading is not enabled. Select Override class reloading settings for web and EJB modules to choose to reload application classes. You might specify different values for EJB modules and for web modules such as servlets and JSP files.

  3. Specify the number of seconds to scan the application's file system for updated files.

    The value specified for Polling interval for updated files takes effect only if class reloading is enabled. The default is the value of the reloading interval attribute in the IBM extension (META-INF/ibm-application-ext.xmi) file of the enterprise application (EAR file). You might specify different values for EJB modules and for web modules such as servlets and JSP files.

    To enable reloading, specify an integer value that is greater than zero (for example, 1 to 2147483647).

    To disable reloading, specify zero (0).

  4. Specify the class loader order for the application.

    The application class loader order specifies whether the class loader searches in the parent class loader or in the application class loader first to load a class. The default is to search in the parent class loader before searching in the application class loader to load a class.

    Select either of the following values for Class loader order:

    Option Description
    Classes loaded with parent class loader first Causes the class loader to search in the parent class loader first to load a class. This value is the standard for Development Kit class loaders and WebSphere® Application Server class loaders.
    Classes loaded with local class loader first (parent last) Causes the class loader to search in the application class loader first to load a class. By specifying Classes loaded with local class loader first (parent last), your application can override classes contained in the parent class loader.
    Attention: Specifying the Classes loaded with local class loader first (parent last) value might result in LinkageErrors or ClassCastException messages if you have mixed use of overridden classes and non-overridden classes.
  5. Specify whether to use a single or multiple class loaders to load web application archives (WAR files) of your application.

    By default, web modules have their own WAR class loader to load the contents of the WEB-INF/classes and WEB-INF/lib directories. The default WAR class loader value is Class loader for each WAR file in application, which uses a separate class loader to load each WAR file. Setting the value to Single class loader for application causes the application class loader to load the web module contents as well as the EJB modules, shared libraries, RAR files, and dependency JAR files associated to the application. The application class loader is the parent of the WAR class loader.

    Select either of the following values for WAR class loader policy:

    Option Description
    Class loader for each WAR file in application Uses a different class loader for each WAR file.
    Single class loader for application Uses a single class loader to load all of the WAR files in your application.
  6. Click OK.

Results

The application or module configuration is changed. The application or stand-alone web module is restarted so the changes take effect.

What to do next

If the application or module is deployed on a cluster and you have no more configuration changes to make, click Rollout Update on the Enterprise applications page to propagate the changed configuration on all cluster members of the cluster on which the application or module is deployed. Rollout Update sequentially updates the configuration on the nodes that contain cluster members.

Save changes to your administrative configuration.

On multiple-server products, the application binaries are transferred to nodes when the configuration changes on the deployment manager synchronize with configurations for individual nodes on which the application will run.


指出主題類型的圖示 作業主題



時間戳記圖示 前次更新: July 9, 2016 11:16
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=trun_app_classload
檔名:trun_app_classload.html