What kind of class-loading error do you see when you develop an application or start an installed application?
ClassCastException
A class cast exception results when the following conditions exist and can be corrected by the following actions:
System.out.println( source.getClass().getName() + “:” + target.getClass().getName() );Or use a javap command. For example:
javap java.util.HashMap Compiled from "HashMap.java" public class java.util.HashMap extends java.util.AbstractMap implements java.util.Map,java.lang.Cloneable,java.io.Serializable {
If there is more than one class loader listed, then the class loader that loads the source object is different from the class loader that loads the target object.
A class cast exception can occur because, when the application is caching a resolved enterprise bean (EJB) object, the application code does not perform a narrow operation as required. The code must perform a narrow operation after looking up a remote object. Examine your code to determine if it looks up a remote object and, if so, a narrow operation follows.
A class cast exception also can occur because the code attempts to override a class provided by WebSphere Application Server. To correct this problem, use the Search and Search by Class Name console pages:
Class-loader modes provides information on the Parent First and Parent Last values for Class loader mode.
To correct this problem, check your class-loader settings on a console enterprise application settings page. Set the application Class loader mode to Parent Last and WAR class loader policy to Application . Class-loader modes provides information on the Parent First and Parent Last values for Class loader mode. WAR class-loader policy provides information on the Application and Module values for WAR class-loader policy.
Class-loader modes provides information on the Parent First and Parent Last values for Class loader mode.
ClassNotFoundException
A class not found exception results when the following conditions exist and can be corrected by the following actions:
If the JAR file is not in the list, the class likely is not in the logical class path, not readable or an alternate class is already loaded. Move the class to a location that enables it to be loaded.
To correct this problem, determine whether the class exists and whether the proper API is used. Follow the steps in The class not found is not the path of the current class loader to determine whether the class is loaded. If the class has not been loaded, attempt to correct the application and see if the class loads. If the class is in the class path with proper permission and is not being overridden by another factory class, examine the API used to load the class.
To correct this problem:
NoClassDefFoundException
A no class definition found exception results when the following conditions exist and can be corrected by the following actions:
UnsatisfiedLinkError
A linkage error results when the following conditions exist and can be corrected by the following actions:
Several user actions can result in a linkage error:
A library has the dynamic link library name library_name.dll.
A library has the name library_name.so or library_name.a.
To load a dynamic link library named Name.dll, Name has
to be passed to a loadLibrary call.
To load a library
named libName.so or libName.a, libName is passed
to the load library.
The Java virtual machine invokes findLibrary() on the class loader xxx that loads the class that calls System.loadLibrary(). If xxx.findLibrary() fails, the Java virtual machine attempts to find the library using the JVM class loader, which searches the JVM library path. If the library cannot be found, the Java virtual machine throws an UnsatisfiedLinkError.
Ensure that the correct WebSphere class loader loads the class that calls System.loadLibrary() and that the native library is visible on the Native Library Path setting.
public class LibLoader { static {System.loadLibrary(MyNativeLib);} public LibLoader(); }
Classes within server-scoped libraries are loaded once for each server lifecycle, ensuring that the native library required by the application is loaded once for each Java virtual machine, regardless of the application’s lifecycle.
Modify the java.library.path system property, or the platform-specific environment variable, to include the path containing the unresolved native library.
Related concepts
Class loaders
Related tasks
Class loading
Troubleshooting class loaders
Related reference
Class loader viewer settings
Enterprise application topology
Search settings
A web resource does not display
Errors starting an application