How can I fix 'No exception of type SomeException can be thrown; an exception type must be a subclass of Throwable'

妖精的绣舞 提交于 2019-12-24 02:08:27

问题


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).


回答1:


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.




回答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



来源:https://stackoverflow.com/questions/27277008/how-can-i-fix-no-exception-of-type-someexception-can-be-thrown-an-exception-ty

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!