4
EJB의 예외 처리를 위해 다음 코드를 작성했습니다.EJB에서 예외가 처리되는 방법은 무엇입니까?
1)
`@WebService(serviceName = "Module")
@Stateless()
public class Module {
/**
* This is a sample web service operation
*/
@WebMethod(operationName = "hello")
public int hello(@WebParam(name = "name") String txt) throws Exception {
int re=0;
try{
re=(6/0);
}catch(Exception e){
throw (EJBException) new EJBException(se).initCause(e);
}
return re;;
}
}
}`
2 Module.java
) Client.jsp`<%
try{
selec.Module_Service service = new selec.Module_Service();
selec.Module port = service.getModulePort();
java.lang.String name = "";
int result = port.hello(name);
out.println("Result = "+result);
}catch(EJBException e){
Exception ee=(Exception)e.getCause();
if(ee.getClass().getName().equals("Exception")){
System.out.println("Database error: "+ e.getMessage());
}
}
%>`
내부 캐치 블록 예외 객체는 EE가 null로 저를 얻는다. null 값을주는 문제점은 무엇입니까
의 Throwable의 캐스트가 너무 너무 내 생각 –
중복이지만, 어떤 이유로 문서는 어떻게 든 바람직하다고 판단. 나는 완벽을 위해서만 옵션을 추가했다. @SteveC – kolossus