WebSphere interview question · Most asked
Explain class loading in WebSphere: parent-first versus parent-last, and shared libraries.
How it works
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,ClassCastExceptionorLinkageErrorwhen 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"/>andcommonLibraryRef/privateLibraryRefinside<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:classto 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
- Explain the traditional WebSphere Network Deployment architecture: cell, Deployment Manager, nodes, node agents, servers and clusters.
- How would you migrate an application from traditional WebSphere to Liberty?
- How does Liberty's server.xml and feature model work?
- How do you configure a JDBC data source and connection pool in Liberty and in traditional WAS?
- What is WebSphere Application Server, and how do Liberty and traditional WAS differ?
- Users see errors and the logs show J2CA0045E: connection not available. How do you investigate?
- WSVR0605W hung thread warnings appear and the application stops responding. What do you do?
- What is JNDI, and how do applications look up resources in WebSphere?