我有一個方法被定義爲:未報告的異常......必須被捕獲或聲明爲拋出;儘管*拋出*關鍵字
private void startUSSDNotification(SimpleReference reference,
String ussdServiceActivationNumber,
String criteria)
throws PolicyException {
// Note that the injected javax.xml.ws.Service reference as well as port objects are not thread safe.
// If the calling of port operations may lead to race condition some synchronization is required.
USSDNotificationManager port = service.getUSSDNotificationManager();
port.startUSSDNotification(reference, ussdServiceActivationNumber,
criteria);
}
說,「沒有報告異常PolicyException編譯器抱怨道,必須捕獲或聲明拋出我不知道爲什麼我建議可能會引發又「拋出」是正確的,在方法簽名
startUSSDNotification
被定義爲:
public void startUSSDNotification(
@WebParam(name = "reference", targetNamespace = "http://www.csapi.org/schema/osg/ussd/notification_manager/v1_0/local")
SimpleReference reference,
@WebParam(name = "ussdServiceActivationNumber", targetNamespace = "http://www.csapi.org/schema/osg/ussd/notification_manager/v1_0/local")
String ussdServiceActivationNumber,
@WebParam(name = "criteria", targetNamespace = "http://www.csapi.org/schema/osg/ussd/notification_manager/v1_0/local")
String criteria)
throws PolicyException, ServiceException
;
當我嘗試來包裝嘗試呼叫...捕獲錯誤逗留和它帶來了肛這個錯誤說明了Exception從來沒有被拋出。我該如何補救?我使用javase7和netneans 8
可能是你在方法級拋出的異常包與預期的包不同。廣泛關注PolicyException類的包名稱! – hemanth 2014-11-24 08:00:45
是的,我從錯誤的包中導入。現在修復它,謝謝。 – Lym 2014-11-24 08:11:54