My code refers to an interface and stub in the servlet's own directory(At the top, in 'WEB-INF/classes'. Stubs are created during the RMI compilation, and I can view them being present in the same folder where the servlet resides. However, when running the servlet, the stubs cannot be referred. I am starting the registry from inside the servlet itself.
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println("test3");
    try {
        try {
            LocateRegistry.createRegistry(5002);
            TestController obj = new TestController();
            Naming.rebind("CerberusServer", obj);
        } catch(Exception e) {
            System.out.println("EXCEPTION::::: New Servlet2:: 2:: " + e);
            System.out.println(e.getMessage());
        }
    } catch(Exception e) {
        System.out.println("unable to run RMI: " + e);
    }
}
Test Controller:
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
public class TestController extends UnicastRemoteObject implements ITestController {
protected TestController() throws RemoteException {
}
@Override
public String test(String text) throws RemoteException, Exception {
    return text;
 }
}
ITestController:
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface ITestController extends Remote {
    String test(String text) throws RemoteException, Exception;
}
The exact exception that I get when trying to bind is
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: java.lang.ClassNotFoundException: TestController_Stub (no security manager: RMI class loader disabled)
Edit: It is different from running rmi server, classnotfound because this error is coming in a Tomcat servlet application. Without the servlet part, this error does not appear.
