"No exception of type SomeException can be thrown; an Exception type must be a subclass of Throwable" in JBDS

Solution Verified - Updated -

Environment

  • JBoss Developer Studio (JBDS) 2.0

Issue

The EJB use apache email to send email, so I included the apache_common_mail.jar as referenced libraries in the Inventory EJB project.

JBDS shows the error: No exception of type EmailException can be thrown; an Exception type must be a subclass of Throwable

Resolution

Add commons-lang.jar to the project's build path.

Root Cause

Apache commons-mail depends on commons-lang, and has an exception class derived from commons-lang's NestedRuntimeException class. That jar was missing from the project's build path, so JBDS couldn't process the class heirarchy and it reports the somewhat confusing error that the exception isn't derived from Throwable.

Diagnostic Steps

Check whether there is the error "org.apache.commons.lang.exception.NestableException cannot be resolved, it is indirectly referenced from a required .class file" reported at the top of the file.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments