当前位置: 首页 > 知识库问答 >
问题:

未报告的异常......必须被捕获或声明为被抛出;尽管*抛出*关键字

龚威
2023-03-14

我有一个方法被定义为:

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);
}

编译器抱怨说,“未报告的异常政策异常;必须被捕获或声明为被抛出。我不知道为什么它建议我可以抛出,但“抛出”就在方法签名中。

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
;

当我尝试在try…catch中封装调用时,错误会保留,并会引发另一个错误,该错误表示try主体中从未抛出异常。我该如何补救?Am使用javase7和netneans 8

共有1个答案

张宣
2023-03-14

由于您没有向我们展示实际的编译错误等,我不能确定,但我怀疑有多个名为PoleyException的类,并且您声明了错误的类:

>

  • 检查编译错误的精确措辞

    检查<code>导入

  •  类似资料: