2

I have java webstart app and want to use app API for testing purposes. So I get required (as I assumed) library from webserver and install it to maven repository. And all is fine except custom exception which received

No exception of type SomeException can be thrown; an exception type must be a subclass of Throwable

As I understand from similar topics - some jar library is missing, is there some way to know which one? or maybe there is other way to fix this? (of course I can install all jars which used for app, but there are over 90 jar's).

Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724
user3535807
  • 248
  • 2
  • 3
  • 15

3 Answers3

3

If you want to define a custom exception, it MUST subclass Throwable; but in practice you'll never subclass this directly. Subclass either of:

  • Exception if you want to create a checked exception class;
  • RuntimeException if you want to create an unchecked exception class.

You may also want to subclass another exception already defined by the JDK, which defines a good number of exceptions which may fit what you want to "say" with your exception.

fge
  • 119,121
  • 33
  • 254
  • 329
  • Correct. The only way it could be a jar file problem is if SomeException sublasses SpecialEror, and in one jar file SpecialError subclasses Throwable (directly or indirectly) while in another jar file SpecialError does not subclass Throwable. – Hot Licks Dec 03 '14 at 16:47
2

I used JadClipse Eclipse plug-in for decompiling my jar and found that my SomeException extends FaultInfoException (org.codehaus.xfire.fault.FaultInfoException),and then added xfire-all dependency to my pom.xml

user3535807
  • 248
  • 2
  • 3
  • 15
0

You can resolve this by simply inheriting the exception class with a built-in Exception class. Wherever you have created the exception class just add extends Exception there.

Mureinik
  • 297,002
  • 52
  • 306
  • 350