@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException {
String reqURI = req.getRequestURI();
reqURI = reqURI.replace(req.getContextPath(), "");
try {
ServiceFactory factory = ServiceFactory.getInstance();
Service service = factory.getService(reqURI);
service.doPost(req, resp);
} catch (Exception e ) {
ROOT_LOGGER.error(e.getMessage(), e);
throw new ServletException(e);
}
}
Когда я пытаюсь получить экземпляр ServiceFactory, я получаю NoClassDefFoundError.
Это происходит только после развертывания приложения. Если я запускаю его через IntelliJ, то ничего плохого не происходит.
В чем проблема?
public class ServiceFactory {
private static final Map<String, Service> SERVICE_MAP = new HashMap<>();
private static final ServiceFactory SERVICE_FACTORY = new ServiceFactory();
private ServiceFactory() {
init();
}
private static void init() {
SERVICE_MAP.put(LOGIN_PAGE_URI, new LoginService());
SERVICE_MAP.put(LOGOUT_PAGE_URI, new LogoutService());
SERVICE_MAP.put(SWITCH_LANGUAGE_URI, new SwitchLanguageService());
SERVICE_MAP.put(USERS_PAGE_URI, new AllUsersService());
SERVICE_MAP.put(REGISTRATION_PAGE_URI, new RegistrationService());
SERVICE_MAP.put(DELETE_USER_PAGE_URI, new DeleteUserService());
SERVICE_MAP.put(NEW_DOCUMENT_PAGE_URI, new NewDocumentService());
SERVICE_MAP.put(GET_FORM_AJAX_PAGE_URI, new GetFormAJAX());
}
public static ServiceFactory getInstance() {
return SERVICE_FACTORY;
}
public Service getService(String request) {
return SERVICE_MAP.get(request);
}