Bootstrap FreeKB - IBM WebSphere - Resolve NoClassDefFoundError
IBM WebSphere - Resolve NoClassDefFoundError

Updated:   |  IBM WebSphere articles

NoClassDefFoundError will be returned when an application is unable to load a class. In this example, the application is unable to load the "People" class in the "com.sample.main" package.


Let's take a simple example where the "People" class in the "com.sample.main" package and the JSP using the class exist in a single application. For example, here is the People class in the application.

package com.sample.main;

public class People {
  public String name = "John Doe";

  public String getName(){
    return name;


And here is the JSP page in the same application using the People class.

<%@page import="com.sample.main.People"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  People foo = new People();


In this scenario, when the application is deployed to a WebSphere application server, NoClassDefFoundError should not be returned.


And the grep command (on a Linux server) should show that the applications JSP is indeed importing the com.sample.main.People class.

grep People ${WAS_INSTALL_ROOT}/profiles/your_profile/installedApps/your_cell/your.ear/your.war/index.jsp

<%@page import="com.sample.main.People"%>


And you also should be able to locate the People.class file below com/sample/main.

ls ${WAS_INSTALL_ROOT}/profiles/your_profile/installedApps/your_cell/your.ear/your.war/WEB-INF/classes/com/sample/main/People.class


JAR file

Another common implementation is to create a JAR file that contains the class. In this example, a JAR file that contains the com.sample.main.People class could be created. You would then export the project to a JAR file and create a dynamic web project. There are a few options on how to get the dynamic web project to use the JAR file.

  • Place the JAR file in the applications WEB-INF/lib folder
  • Place the JAR file in the application servers classpath
  • Place the JAR in a shared library

Each of these options are described in more depth in this article. As long as you properly implement any of these options, NoClassDefFoundError should not be returned.




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee


Add a Comment

Please enter 663e59 in the box below so that we can be sure you are a human.