我有一个方法被定义为:
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
;
当我尝试在try中包装调用时...捕获错误仍然存在并且它会引发另一个错误,指出异常永远不会在try的主体中抛出。我该如何解决这个问题?我使用的是javase7和netneans 8
答案 0 :(得分:1)
由于您没有向我们展示实际的编译错误等,我无法确定,但我怀疑有多个名为PolicyException
的类,并且您声明错误的类:< / p>
检查编译错误的准确措辞
检查import
声明。