I currently have this issue I can't resolve. I have a project in JDeveloper, using ADF. When an exception (Throwable) occur somewhere in Model tier, I can't catch it in View tier. Let me explain it better:
In View, I have Transaction.java where
public void save(){
try{
Boolean res= (Boolean) context.get("res"); //value obtained from front-end
OperationBinding op = this.getBindings().getOperationBinding("methodThatThrowsException");
op.getParamsMap().put("res", res);
op.execute();//line that should throw exception
}catch(ClassCastException cce){
showMessage(cce.getMessage()); //pop up with a description of the exception
}
Then, in Model tier:
public void methodThatThrowsException(Boolean res) throws ClassCastException {
try{
Object obj = res;
Integer badCoding = (Integer) obj; //line that throws exception
}catch(ClassCastException e){
//clean-up code
}
}
methodThatThrowsException
will throw a ClassCastException
but it is not caught in save
method.
I don't know what's wrong. I even tried and failed adding in save
after op.execute();
if(!op.getErrors().isEmpty()){
for(Throwable t : op.getErrors()){
if (t instanceof Exception){
Exception e = (Exception) t;
if (e instanceof RuntimeException)
RuntimeException re = (RuntimeException) e;
if(re instanceof ClassCastException)
throw t;
}
}
But with this horrible workaround, t is never thrown because it's a JBOException
, not a ClassCastException
when it's on View tier.
What can I do? Any suggestion works for me right now. Thanks in advance.
Binding layer's exception handling is counter-intuitive for anyone familiar with java:
Boolean res= (Boolean) context.get("res"); //value obtained from front-end
perationBinding op = this.getBindings().getOperationBinding("methodThatThrowsException");
op.getParamsMap().put("res", res);
op.execute();//line that should throw exception
//grab the exception this way
op.getErrors()