WebSphere interview question · Most asked

Explain class loading in WebSphere: parent-first versus parent-last, and shared libraries.

How it works

Members can save this page, take notes and track progress. See membership · Sign in

Summary

Class loaders form a hierarchy: JVM and server classes at the top, then application (EAR) and module (WAR) class loaders. In parent-first mode (the default) a class is looked up in the parent first, so the server's copy of a library wins; in parent-last mode the application's own JARs win. Shared libraries let several applications use one copy of a library.

Longer Answer

  • Conflicts appear as NoSuchMethodError, ClassCastException or LinkageError when two versions of a library are visible.
  • Traditional WAS: class loader order per application and module, and WAR class loader policy (module or application); Liberty: <classloader delegation="parentLast"/> and commonLibraryRef/privateLibraryRef inside <application>.
  • Liberty hides most server internals from applications by default (only enabled features' APIs are visible), which avoids many conflicts traditional WAS suffers from.
  • Diagnose with the Class Loader Viewer (traditional) or -verbose:class to see where a class came from.

Key Points

  • Parent-first default: server copy wins.
  • Parent-last: application JARs win.
  • Shared libraries avoid duplicate copies.
  • Conflicts show as NoSuchMethodError or ClassCastException.

Explanation

What interviewers look for

Diagnosing classpath conflicts methodically, not flipping to parent-last blindly.

More WebSphere questions

← All WebSphere questions

Last reviewed · By the ByteCamel team · How we write content

Was this page helpful?

Report a mistake