JDK Versions for MI  |  Import a .war file into a new project

 

Mobile Infrastructure Class Loader

MI Client has its own class loader (that is, a class that implement a java.lang.ClassLoader). This class loader takes precedence over Tomcat's class loaders. This chapter describes

What is a Class Loader?

A class loader is an object that is responsible for loading classes. Given the name of a class, it should attempt to locate or generate data that constitutes a definition for the class. A typical strategy is to transform the name into a file name and then read a "class file" of that name from a file system.

Applications (like MI or Tomcat) implement subclasses of java.lang.ClassLoader in order to extend the manner in which the Java virtual machine dynamically loads classes.

For more information on class loaders, please consult the Java doc for java.lang.Classloader at http://java.sun.com.

 

Why Is MI Using its own Class Loader ?

Order for Loading Classes

MI's class loader loads classes in the following sequence:

  1. All Java archives (.jar) described in file <ME_HOME>/listOfJars.txt are loaded in the order in which they appear in that file. If SSL is enabled, these classes are loaded also. The SDK tools from <JDK root>/lib/tools.jar are also loaded.
  2. The class loader then loops through all applications under <ME_HOME>/webapps and loads for each application
    1. the classes in /WEB-INF/classes and then
    2. the libraries in /WEB-INF/lib/*.jar.


    The order in which the applications appear in above loop is not defined.

This load sequence has very important implications:

The MI classloader is only used, if MI is using JDK 1.3.*. If MI is using JDK 1.1.8, Tomcat's class loader will be used by MI for JSP. MI for AWT will use the JVM default class loader. This implies that inbound containers of applications that have not yet been started will not be processed. They will be discarded and automatically be resent by the WebAS on next synchronization. A corresponding error message will appear in the trace file.
MI for AWT is also using the MI class loader (if MI is running on 1.3.*). As there is no webapps folder for AWT, all archives are loaded in the order in which they appear in file <ME_HOME>/listOfJars.txt. In MI for AWT, this file contains the libraries for framework and applications.
The MI class loader does not only load classes, but any file that can be loaded via method getResourceAsStream(), as property files, images etc.

 

Consequences for Application Development

Application developers need to be aware of the implications of the class load sequence described above: