diff --git a/java/code/src/com/redhat/rhn/domain/notification/UserNotificationFactory.java b/java/code/src/com/redhat/rhn/domain/notification/UserNotificationFactory.java index 148b5bf7ec19..4673a8240fff 100644 --- a/java/code/src/com/redhat/rhn/domain/notification/UserNotificationFactory.java +++ b/java/code/src/com/redhat/rhn/domain/notification/UserNotificationFactory.java @@ -77,7 +77,8 @@ private static void configureMailer() { Class cobj = Class.forName(clazz).asSubclass(Mail.class); mailer = cobj.getDeclaredConstructor().newInstance(); } - catch (Exception e) { + catch (Exception | LinkageError e) { + log.error("An exception was thrown while initializing custom mailer class", e); mailer = new SmtpMail(); } } diff --git a/java/code/src/com/redhat/rhn/frontend/events/BaseMailAction.java b/java/code/src/com/redhat/rhn/frontend/events/BaseMailAction.java index efa61a5c1e91..8a8c9f73f12c 100644 --- a/java/code/src/com/redhat/rhn/frontend/events/BaseMailAction.java +++ b/java/code/src/com/redhat/rhn/frontend/events/BaseMailAction.java @@ -52,16 +52,16 @@ public void execute(EventMessage msg) { * @return the mailer associated with this class */ protected Mail getMail() { - String clazz = Config.get().getString( - "web.mailer_class"); + String clazz = Config.get().getString("web.mailer_class"); if (clazz == null) { return new SmtpMail(); } try { - Class cobj = Class.forName(clazz); - return (Mail) cobj.newInstance(); + Class cobj = Class.forName(clazz).asSubclass(Mail.class); + return cobj.getDeclaredConstructor().newInstance(); } - catch (Exception e) { + catch (Exception | LinkageError e) { + getLogger().error("An exception was thrown while initializing custom mailer class", e); return new SmtpMail(); } } diff --git a/java/spacewalk-java.changes.houssemnasri.fix-notification-error b/java/spacewalk-java.changes.houssemnasri.fix-notification-error new file mode 100644 index 000000000000..8bf7f70b9b3d --- /dev/null +++ b/java/spacewalk-java.changes.houssemnasri.fix-notification-error @@ -0,0 +1 @@ +- Fix server error when visiting the notifications page