Bean exception handling

Hello,
I have a question concerning the bean exception handling. If I'd like to use a DB-connection inside a bean, how to handle the SqlException to display a nice error message to the user (perhaps next to the submit-button or redirect to another site).
Thx
Stefan

Thank you for the reply. That works fine but I wanted
to avoid using Faces-code inside of the bean because
of portability. Is there a possibility to throw an
exception inside of a setter and catch it somewhere
else to generate the FacesMessage there ?There are at least two ways to look at this.
First, I've found that you often need one or more beans that ties the UI to the backend. For instance, my backend bean may have a method for saving itself to a database, but that method most likely doesn't return a String, as an "action method" must. I also often need a bean to hold UI values that are pure UI artifacts rather than backend values, say a filter criteria for a database search. In this type of bean (I call them "glue beans", others call them "backing bean" or "code behind file") I don't mind having JSF code, so my original suggestion applies to this type of bean rather than to the real backend beans.
Second, in an application where you can bind the JSF components directly to backend bean properties and methods, you can set up an error handler in the web.xml file that displays a nice error message and logs details about the problem for further analysis.
Hans Bergsten (EG member)

Similar Messages

  • A Question About Message Driven Bean Exception Handling

    "Your onMessage method should handle all exceptions. It must not throw checked exceptions, and throwing a RuntimeException is considered a programming error."
    The above sentence is from the JMS documentation.
    I will use a message driven bean for guarenteeing to send an email with some critical info in case of an unexpected system failure. Say I was not able to save into db some critical info, therefore I want to send that info to myself with a mail to be able to handle that situation manually. Now in case of failure I will send a message to a queue which contains the critical info, and a message driven bean will listen for the message and send email to me. But what if the message driven bean fails ? If I am to handle any exceptions on my onMessage method, how will the messaging system be able to redeliver that message ? It seems to me the message will not remain in the queue anymore(I have consumed it) ?
    Any help appreciated, thanks in advance.

    Fatih.Karakoc wrote:
    "Your onMessage method should handle all exceptions. It must not throw checked exceptions, and throwing a RuntimeException is considered a programming error."
    The above sentence is from the JMS documentation.
    I will use a message driven bean for guarenteeing to send an email with some critical info in case of an unexpected system failure. Say I was not able to save into db some critical info, therefore I want to send that info to myself with a mail to be able to handle that situation manually. Now in case of failure I will send a message to a queue which contains the critical info, and a message driven bean will listen for the message and send email to me. But what if the message driven bean fails ? If I am to handle any exceptions on my onMessage method, how will the messaging system be able to redeliver that message ? It seems to me the message will not remain in the queue anymore(I have consumed it) ?
    You can configure your queue to guarantee delivery. If you use JTA you can also make it transational, so the message is put back on the queue in the event of failure. Your configuration should also include max retries and a failure queue to make sure you don't get stuck in an infinite loop where a message can never be processed.
    Which app server are you using? WebLogic makes it pretty easy to set these config parameters.
    %

  • Bounded Taskflow Exception Handler not working with Page Fragements

    I have one bounded - taskflow task-flow-definition
    <?xml version="1.0" encoding="windows-1252" ?>
    <adfc-config xmlns="http://xmlns.oracle.com/adf/controller" version="1.2">
      <task-flow-definition id="task-flow-definition">
        <default-activity>view1</default-activity>
        <managed-bean>
          <managed-bean-name>backing_main</managed-bean-name>
          <managed-bean-class>view.backing.Main</managed-bean-class>
          <managed-bean-scope>pageFlow</managed-bean-scope>
        </managed-bean>
        <managed-bean>
          <managed-bean-name>backing_view1</managed-bean-name>
          <managed-bean-class>view.backing.View1</managed-bean-class>
          <managed-bean-scope>pageFlow</managed-bean-scope>
        </managed-bean>
        <managed-bean>
          <managed-bean-name>backing_view2</managed-bean-name>
          <managed-bean-class>view.backing.View2</managed-bean-class>
          <managed-bean-scope>pageFlow</managed-bean-scope>
        </managed-bean>
        <exception-handler>view2</exception-handler>
        <view id="view1">
          <page>/view1.jsff</page>
        </view>
        <view id="view2">
          <page>/view2.jsff</page>
        </view>
        <use-page-fragments/>
      </task-flow-definition>
    </adfc-config>view1.jsff contains one command button, which calls one ActionListener
    <?xml version='1.0' encoding='windows-1252'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
              xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
      <af:commandButton text="commandButton 1" actionListener="#{pageFlowScope.backing_view1.callMyFunction}"
                        binding="#{pageFlowScope.backing_view1.commandButton1}"
                        id="commandButton1"/>
      <!--oracle-jdev-comment:auto-binding-backing-bean-name:backing_view1-->
    </jsp:root>view1.java callMyFunction throws an Exception
        public void callMyFunction(ActionEvent event) throws Exception{
            throw new Exception();
        }view2.jsff is an exception handler
    <?xml version='1.0' encoding='windows-1252'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
              xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
      <af:activeOutputText value="Exception Occured"
                           binding="#{pageFlowScope.backing_view2.activeOutputText1}"
                           id="activeOutputText1"
                           inlineStyle="font-size:xx-large; color:red;"/>
      <!--oracle-jdev-comment:auto-binding-backing-bean-name:backing_view2-->
    </jsp:root>above taskflow is dragged-drop as a Region in one file main.jspx
    <?xml version='1.0' encoding='windows-1252'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
      <jsp:directive.page contentType="text/html;charset=windows-1252"/>
      <f:view>
        <af:document binding="#{pageFlowScope.backing_main.document1}"
                     id="document1">
          <af:form binding="#{pageFlowScope.backing_main.form1}" id="form1">
            <af:region value="#{bindings.taskflowdefinition1.regionModel}"
                       id="taskf1"
                       binding="#{pageFlowScope.backing_main.taskf1}"/>
          </af:form>
        </af:document>
      </f:view>
      <!--oracle-jdev-comment:auto-binding-backing-bean-name:backing_main-->
    </jsp:root>*pressing a commandButton on view1.jsff throws an Exception as expected but does not go to exceptionHandler [view2.jsff]*
    However, this does work with Bounded Task-Flow without page fragments , view1.jspx contains one button, calling one method which throws an Exception,
    view2.jspx is an Exception Handler, and in this case it redirects to the view2.jspx [error page]
    any ideas?
    thanks

    Hi,
    Pretty much. However, you got the event part wrong, which is mostly my fault here. First, let put down some general JSF facts about event handling.
    1. http://java.sun.com/javaee/5/docs/api/javax/faces/component/UIComponent.html#queueEvent(javax.faces.event.FacesEvent)
    2. So, basically, queuing an event on a component means queuing it on its parent until you reach the UIViewRoot that will really actually queue it. That strategy allows iterating components to intercept event queued on their children to record the row index as well so that the data model can be synchronized correctly during the broadcast phase (see http://java.sun.com/javaee/5/docs/api/javax/faces/component/UIData.html#queueEvent(javax.faces.event.FacesEvent) and http://java.sun.com/javaee/5/docs/api/javax/faces/component/UIData.html#broadcast(javax.faces.event.FacesEvent))
    3. Exceptions that aren't handled by the exception handler are thrown during broadcast or various process* methods.
    So, the catch component must leverage these facts to intercept events queued on its children (by overriding queueEvent method) wrapping the original event in a custom on that flag the catch component itself as the source of the event. The result will be that the broadcast method of the catch component will be called to handle the event. The broadcast method must then unwrap the event (to get the original event), gets the original source, then call originalSource.broadcast(originalEvent) within a try-catch block.
    Does it make any more sense put that way? Note that it's an obscure part of JSF so I cannot make it incredibly simple either.
    Regards,
    ~ Simon

  • Exception Handling for many bean objects of a container class in a JSP page

    Hello,
    I have on container bean class. In this container class, there are several others class objects and the getter methods to get these objects out to the JSP pages.
    I have one JSP page which will use different objects in the container class object through the getter methods of the container class.
    My question is how to implement the exception handler for all the objects in the container so that the JSP page can handle all exceptions if occurrs in any object in the container?
    Please give me some suggestions. Thanks
    Tu

    Thanks for your reply.
    Since the container is the accessor class, I have no other super class for this container class, I think I will try the try catch block in the getter methods.

  • ADF Task Flow Exception Handling

    Hi ,
    I tried a very simple thing for taskFlow exception handling.
    I created a bounded task flow with a page fragment (View1.jsff) and another view which is the TaskFlow ExceptionHandler (error.jsff).
    The view1.jsff has a button whose action is bound to the backing bean. In the backingBean method I deliberately do division by 0.
    Since this is an unHandled exception, I would have expected the control to come to error.jsff. But, instead I am shown a pop up box with the error message.
    Why is the control not getting redirected to error.jsff ?
    Thanks.
    S.Srivatsa Sivan

    Hi Frank , im having the same problem.
    I want to handle exceptions that occur while navigating task flows (example: A user navigates to a task flow that he/she does not have view permission)
    I tried using a view activity and method activity as the exception handler but none of them works, the exception is still not handles. It does not even navigate to the exception handler on the task flow.
    on the view page i have:
    <af:panelStretchLayout topHeight="50px" id="psl1">
    <f:facet name="top">
    <af:panelGroupLayout layout="scroll"
    xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
    id="pgl1">
    Error message:  
    <af:outputText value="#{controllerContext.currentRootViewPort.exceptionData.message}" id="ot2"/>
    </af:panelGroupLayout>
    </f:facet>
    <f:facet name="center">
    <af:outputText value="#{my_exception_Handler.stackTrace}" id="ot1"/>
    <!-- id="af_one_column_header_stretched" -->
    </f:facet>
    </af:panelStretchLayout>
    I tried getting the error message and stacktrace from the controllerContext via EL like this "#{controllerContext.currentRootViewPort.exceptionData.message}"
    and from the controllerContext class in functions that i have declared in my_exception_Handler class like this
    " ControllerContext ctx = ControllerContext.getInstance();
    ViewPortContext vCtx = ctx.getCurrentViewPort();
    if(vCtx.getExceptionData() != null){
    StringWriter stringWriter = new StringWriter();
    PrintWriter printWriter = new PrintWriter(stringWriter);
    vCtx.getExceptionData().printStackTrace(printWriter);
    return stringWriter.toString();"
    But all this dont even matter because when the exception occurs on the task flow it does not navigate to the default exception handler.
    thanks for your interest and help in advance.
    Cyborg_0912

  • How to display the 500-internal server error on the Exception Handler page

    Hello
    My situation is as follows : JDev 11.1.1.0.2, ADF fusion application, one unbounded task flow containing 2 view pages view1.jspx and error.jspx
    The error jspx is marked as the exception handler.
    When an error occurs (typically a 500-Internal Server Error) the error.jspx is correctly displayed and shows our message such as 'Don't panic, please call our tech support'
    What I would like to do is to display the actual error stack on this page along with our message.
    I've searched around and I can't find how to either get the error stack in a bean or what EL expression should be used to get the error stack.
    Can anybody help ?
    Best Regards
    Paul
    Switzerland

    The error will be the same, but the stack trace will be different, such as
    Error 500--Internal Server Error
    oracle.adf.controller.security.AuthorizationException: ADFC-0619: Echec de la vérification des autorisations : '/view1.jspx' 'VIEW'.
         at oracle.adf.controller.internal.security.AuthorizationEnforcer.handleFailure(AuthorizationEnforcer.java:145)
         at oracle.adf.controller.internal.security.AuthorizationEnforcer.checkPermission(AuthorizationEnforcer.java:124)
         at oracle.adfinternal.controller.state.ControllerState.initializeUrl(ControllerState.java:639)
         at oracle.adfinternal.controller.state.ControllerState.synchronizeStatePart2(ControllerState.java:449)
         at oracle.adfinternal.controller.application.SyncNavigationStateListener.afterPhase(SyncNavigationStateListener.java:44)
         at oracle.adfinternal.controller.lifecycle.ADFLifecycleImpl$PagePhaseListenerWrapper.afterPhase(ADFLifecycleImpl.java:529)
         at oracle.adfinternal.controller.lifecycle.LifecycleImpl.internalDispatchAfterEvent(LifecycleImpl.java:118)
         at oracle.adfinternal.controller.lifecycle.LifecycleImpl.dispatchAfterPagePhaseEvent(LifecycleImpl.java:166)
         at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener$PhaseInvokerImpl.dispatchAfterPagePhaseEvent
    What I would like is to display the above stack trace on the page marked as the exception handler....
    Regards
    Paul

  • Exception Handling in bounded taskflows - expected behaviour

    Hi,
    I'm currently reviewing exception handling in bounded task flows and some things does not seems to be very clear for me.
    (q1) Does it make sense that a bounded task flow calls a method (via a method activity) defined on the page definition of another page (outside of the BTF) by using a #{data.xxxmyPageDef.myMethodName.execute} EL expression?
    (q2) Is is correct to expect the application to execute the method marked as ExceptionHandler in the taskflow, whenever an exception occurs?
    (q3) I created 5 different scenarios where I call a service method which throws an exception, from within a page fragment of the BTF.
    (q3 – sc1) Call a service method through the binding layer of the current page (by using #{bindings.xxx.execute})
    Result: A dialog containing the exception message appears.
    This is what I expected. Althought, the exception handler method does not seems to be invoked.(q3 – sc2) Call a service method through a task flow method activity using #{bindings.xxx.execute}
    Result: A dialog containing the exception message appears.
    This is what I expected. Althought, the exception handler method does not seems to be invoked.(q3 – sc3) Call a service method through a task flow method activity using #{data.myPageFragementPagedef.xxx.execute} (accessing the pageDef of the page fragment)
    Result: Nothing happens.
    This is not what I expected. Although, the exception handler method does nog seems to be invoked, I expect the ADF Error Handler to create a FacesMessage.(q3 – sc4) Call a service method through a task flow method activity using #{data.myPageContainingThePageFragmentPageDef.xxx.execute} (accessing the page containing the BTF region)
    Result: Nothing happens.
    This is not what I expected. Although, the exception handler method does nog seems to be invoked, I expect the ADF Error Handler to create a FacesMessage. (q3 – sc5) Call a service method through a task flow method activity using #{data.aPageOutsideTheBTFPageDef.xxx.execute} (accessing a page outside the BTW)
    Result: Nothing happens.
    This is not what I expected. Although, the exception handler method does nog seems to be invoked, I expect the ADF Error Handler to create a FacesMessage. (q4) How can it be possible that – without an exception handler – exceptions occur when calling method activities, without the exceptions being translated to FacesMessages?
    Thanks in advance,
    Koen Verhulst
    JDeveloper 11.1.1.4

    Koen,
    +(q1) Does it make sense that a bounded task flow calls a method (via a method activity) defined on the page definition of another page (outside of the BTF) by using a #{data.xxxmyPageDef.myMethodName.execute} EL expression?+
    No. Exceptions should be handled locally.
    +(q2) Is is correct to expect the application to execute the method marked as ExceptionHandler in the taskflow, whenever an exception occurs?+
    Only for exceptions that are before Render Response. The Render Response Phase is not handled in ADFc. So exceptions that occur in managed beans may fall through
    +(q3) I created 5 different scenarios where I call a service method which throws an exception, from within a page fragment of the BTF.+
    +(q3 – sc1) Call a service method through the binding layer of the current page (by using #{bindings.xxx.execute}) Result: A dialog containing the exception message appears.+
    This is what I expected. Althought, the exception handler method does not seems to be invoked.
    The binding layer has an error handler you can override in the DataBinings.cpx file
    +(q3 – sc2) Call a service method through a task flow method activity using #{bindings.xxx.execute}+
    Result: A dialog containing the exception message appears.
    This is what I expected. Althought, the exception handler method does not seems to be invoked.
    Again, you use the binding layer to invoke the service
    +(q3 – sc3) Call a service method through a task flow method activity using #{data.myPageFragementPagedef.xxx.execute} (accessing the pageDef of the page fragment)+
    Result: Nothing happens.
    This is not what I expected. Although, the exception handler method does nog seems to be invoked, I expect the ADF Error Handler to create a FacesMessage.
    Never use such a call. Its bad practice as there is no guarantee the container you reference is active. Always have the method call activity have its own binding defined when accessing a method call activity. I know there are lots of example floating aroundthat you #{data ...} and many are from 10.1.3. This should be avoided alltogether though
    +(q3 – sc4) Call a service method through a task flow method activity using #{data.myPageContainingThePageFragmentPageDef.xxx.execute} (accessing the page containing the BTF region)+
    Result: Nothing happens.
    This is not what I expected. Although, the exception handler method does not seems to be invoked, I expect the ADF Error Handler to create a FacesMessage.
    Again, this is not a proper use of the ADF framework.
    +(q3 – sc5) Call a service method through a task flow method activity using #{data.aPageOutsideTheBTFPageDef.xxx.execute} (accessing a page outside the BTW)+
    Result: Nothing happens. This is not what I expected. Although, the exception handler method does nog seems to be invoked, I expect the ADF Error Handler to create a FacesMessage.
    accessing a page outside the BTW (!!!) This should ring a worst practices alarm on your laptop (obviously doesn't do it either)
    +(q4) How can it be possible that – without an exception handler – exceptions occur when calling method activities, without the exceptions being translated to FacesMessages?+
    Exceptions are not handled in a single place but stacked. The business service raises an exception and passes it to the binding layer if not handled. The binding layer handles the exception and if it can't passes it to ADFc. ADFc can handle this exception if it is not during Render Response.
    Bottom line: There is no single point of exception handling. So as a recommendation for best practices
    - Catch and handle exceptions as close as possible to their origins
    - If things can go wrong, thy will - use try/catch blocks in managed beans
    - Use an exception handling activity in all bounded task flows. In the case of task flow call activities being used exceptions can bubble up to the caller. However, this would take users out of their current application context
    - Exceptions not handled in ADFc can be intercepted by overriding the application task flow exception handler (used by the exception handler activities). This would give you a chance e.g. to handle issues during Render Response
    - Never fight the framework, never bend the framework: Don't use out of scope access to page definitions and resources. Exception handling is not a replacement for bad code practices (sorry for saying this, its not meant to be rude) :-)
    Though I don't have a qualified numbers of bugs open for exception handling in ADF between 11.1.1.4 and now (and some that are open), but there are issues reported in this area. If there is something that really feels wrong, please go ahead and file a bug and provide a test case for development to have a look. The Render Response issue, for example is something we are aware of and that is in discussion (afaik knows, there is a change in exception handling in JSF 2 that may have an impact to what we can do in ADFc).
    thanks
    Frank

  • Exception handling best practice

    whats the best practice for exception handling on ?
    - BC
    -controller
    -view layer (Managed beans)
    do we have to handle commit operations on BC so we can rollback like this code
    public void save()
    // create/update/delete ROW
    try
    this.getTransaction().commit();
    catch(JboException e ){this.getTransaction().rollBack();}
    thanks
    Edited by: user3674912 on 23/05/2011 05:18 ص

    Hi,
    IMO, best practices is to handle exceptions as close to their origin. If you can't handle it, you re-throw it as you would in Java so another handler gives it a try
    Frank

  • Integration Process exception handling & alerts, Java

    Hello,
    I would like to enhance my basic scenarios fool proof and with as much Java as possible.
    I have set up several asynchronous and synchronous File to SOAP transfers between systems A and B
    using PI70 including my own Java mapping classes and PI's AF_Modules beans. They work just fine.
    I have not designed my own Integration Processes yet, so execution is based on channel settings and availability timing.
    I have learned this aproach may be exposed to general faults resulting manual monitoring and repairing.
    For example server problems at receiver side can result data losses as sender channel just keeps removing source
    files like normally, as the process would be better to just stop right there and alert or something.
    My question is, is the "Enterprise services Builders" Integration Process & Graphical definition screen the one and only tool to 
    customize whole process exception handling and alerts in PI, and Java is not an option?
    Appreciate your advice on this.
    Kind regards m

    Hi m,
    Strange Name
    >>I have learned this aproach may be exposed to general faults resulting manual monitoring and repairing. For example server problems at receiver side can result data losses as sender channel just keeps removing source  files like normally, as the process would be better to just stop right there and alert or something.
    If you are looking to handle this particular scenario, then we have the alert mechanism and CCMS monitoring. There you will come to know whether the end system down or not.
    Also in addition to this you can write your own java (in message mapping, as modules, java mapping) /abap code (as abap mapping, user exit in standard functions etc) for providing more details in error scenarios. But you need to validate whether the maintenance/development cost for the code is justified in your scenarios
    Regards
    Suraj

  • Exception Handling in ADF

    Jdeveloper version 11.1.1.5.0
    Use Case :
    My application has :- 1 Jspx page ( testPage.jspx ) , 1 taskflow ( testExceptionFlow.xml ) , 1 pageFragment ( testOperation.jsff ).
    I have employee table dragged as table on testOperation.jsff with 4 buttons :
    1. Delete - Executes the VO's Delete action.
    2. Commit - AM's commit operation ( through datacontrol )
    3. CustomDeleteAndCommit - One method in VOImpl which deletes the currentRow and calls this.getDBTransaction().commit() method.
    4. CustomCommitThroughBean - Action listener in beans calls the commit through operation binding.
    I have secured my application and create two users in jazn.xml User1 and User2. Now both users are logged in to the application using different browser.
    Both users can see employee with empId 100.
    User1 selects a employee with empId 100 and clicks Delete button. Further clicks Commit button.
    User2 selects the same employee with empId 100 and clicks Delete button. Further he can choose to commit through different options :
    a) Commit
    b) CustomCommitThroughBean
    OR
    CustomDeleteAndCommit
    Obviously there will be jboException stating that row is already delete. When I am calling it through CustomCommitThroughBean operationBinding.getErrors() has errors, so I don't see error on UI.
    I see a couple of posts about different ways of handling Exception :
    [Using Exception Handler in an ADF Task Flow | https://blogs.oracle.com/ADFProgrammers/entry/using_exception_handler_in_an]
    [Extending the ADF Controller exception handler | https://blogs.oracle.com/jdevotnharvest/entry/extending_the_adf_controller_exception_handler]
    [Task Flow Exception Handler | http://adfpractice-fedor.blogspot.com/2011/12/task-flow-exception-handler-you-must.html]
    [Exception Handling in adf (Part 1) | http://adfwithejb.blogspot.com/2012/05/exception-handling-in-adf-part-1.html ]
    Which method of exception handling is applicable should be chosen ?
    I just want to notify user about exception through some custom message and table should get refreshed for further operation.
    My observations :
    I get an error dialog in case :
    Commit & CustomDeleteAndCommit
    whereas no default error in case : CustomCommitThroughBean
    I have uploaded my application [here | http://dl.dropbox.com/u/70986236/BlogApplication/OperationBindingExecuteErrorApp.zip ] . Want to implement exception handling in this application.
    Thanks,
    Rajdeep
    Edited by: Rajdeep on Jul 26, 2012 9:45 PM

    When you invoke an operation programmatically through an ADF OperationBinding, the eventual exception is not thrown to you but it is reported to the BindingContainer and the BindingContainer automatically adds a FacesMessage of ERROR severity to the FacesContext. If you have an <af:messages> tag in your ADF Faces page, this error message should be displayed automatically.
    Dimitar

  • Exception handling in jinitiator

    hallo,
    we are currently using jinitiator 1.3.1.9 and i have a little question concerning the exception handling in it. i don't think, that the handling differes to older version, so maybe one can help me out though he uses an "older" version.
    now the problem. we use java functionality either in webmode (jinitiator) and in client-server-mode (wrapper pl/sql unit) and want to pass the java exception trace to the forms, so that we can handle errors in user interaction. we found a way to da that by developing a printstream, which collects trace information in a string. this method works well in client-server-mode but not in webmode. in the first case all the normal trace information is written with the printstream-method println(String). in the webmode case, a different method is used, println(char[]). the strange thing about it is, that the character array contains address information for an object (maybe the string). i my opinion the behaviour is because of the jinitiator. does anyone know about the exception handling and collecting the trace information in jinitiator?? thanks very much in advance.
    regards
    steffen silberbach

    hi again,
    thanks for answering, but I think you got me wrong or I didn't make myself clearly. I don't want to pass a PL/SQL error to the bean to have it printed out on the console. I want it the other wa around. my problem was to get the stack trace of a java exception and make it accessible to the form to print it out as a message for instance. unfortunately this way is quite impossible to do, because jinitiator has a different exception handling to the sun VM. the jinitiator implements the printStackTrace(*) methods as native calls and obviously the underlying code handles the addresses of the passed trace objects and prints them out the a special console somehow. so if one overwrites the printStack() methods in his own Exception, he gets a problem because of the different exception trace handling in jinitiator.

  • Exception handling in JSF

    This question has been asked time and again, without any clear answers to it. I would appreciate if some one can help me on this.
    I am developing a web application with the following architecture:
    JSF page calls backing bean methods which calls the service methods. Now my service methods can throw different exceptions like ValidationException, BusinessException, SystemException etc.
    Now, what i want to do is : If Validation/Business Exceptions are thrown show the error messages to the user on the same page from which the action was called. And if a SystemException is thrown navigate to a default error page.
    How can i handle this thing? Any clues?

    Thanks for the reply BalusC,
    I checked the log files (application log as well as server log) also and there is no other stack trace besides of the exception which i am throwing. Let me elaborate on the exact issue:
    I am trying to handle concurrency issues in my application. For example, When two users simultaneously try to edit the same record, the user who first saves the changes successfully. Now when the second user tries to save the changes i want to show him a message that "This record has been modified after you opened it for edit. Please refresh your page and reapply the changes". To show this message i am throwing a BusinessException from my service, which in turn gets propagated to my saveAction method. The saveAction method needs to handle this exception and somehow should show the above message to the user.
    To achieve this,
    1. i tried catching the exception in my saveAction and added the necessary faces message to FacesContext object. But it does not work. Later i read the reason behind this too, that in the invoke application phase a new context will be created and the messages will not be available to it.
    2. I then added the throws clause to my saveAction method, so that my default exception handler will handle it.
    saveAction method signature :
    public String saveAction () throws BusinessException {
        //some code here for save
        return null;
    }This is my code for the ErrorHandler.jsp:
    <body>
            <h1 style="color: red">Error</h1><br/><%
                 // print stack trace.
                ExceptionHandler exceptionHandler = new ExceptionHandler();
                 // unwrap ServletExceptions.
                while (exception instanceof ServletException || exception instanceof FacesException ||
                        exception instanceof ApplicationException) {
                    if(exception instanceof ServletException) {
                        exception = ((ServletException) exception).getRootCause();
                    } else if(exception instanceof FacesException) {
                        exception = ((FacesException) exception).getCause();
                    } else if(exception instanceof ApplicationException) {
                        exception = ((ApplicationException) exception).getCause();
      %><font color="red"><%=exceptionHandler.handleException(exception)%></font><br/></body>and this is my code for the handleException method defined in the ExceptionHandler.java:
    public static String getMessage(final String msgKey, final Object args[]) {
            String message = messages.getProperty(msgKey);
            if(args != null) {
                final String replaceArgs[] = (String[]) args;
                for(int i = 0; i < replaceArgs.length; i++)
                    message = message.replaceFirst("{" + i + "}", replaceArgs);
    return message;
    public String handleException(final Throwable exception) {
    logger.debug("handleException called..");
    String errorMessage = "Unknown error occured.";
    String stackTrace = "Stacktrace can not be found. Please check the logs for more details.";
    String errorString = null;
    final StringWriter stringWriter = new StringWriter();
    if(exception != null) {
    exception.printStackTrace (new PrintWriter (stringWriter));
    stackTrace = stringWriter.toString();
    errorMessage = getMessage(exception.getMessage(), null);
    errorString = "<b>" + errorMessage + "</b> <br> </br> <br> <input id=\"show\" type=\"button\" value=\"Show Details >>\" onClick=\"toggle();\" /> <div id=\"errorStackTrace\" style=\"display:none;\" > <pre>" + stackTrace + "</pre> </div>";
    return errorString;
    With the help of this code, i am simply trying to navigate to the error page if an exception occurs and display the appropriate error message with the stacktrace.
    The strange thing is, the ErrorHandler.jsp page correctly gets called, which in turn calls the handleException method which returns the formatted error string. (I checked this by adding log statements everywhere). But the system does not actually navigates to the ErrorHandler.jsp page and shows an alert with the following message : "Request error, status : 500 Internal Server Error message : "
    Can someone help me figure out what exactly the problem is?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Task flow exception handler

    Hi all,
    I'm trying to specify a method activity as an exception handler in the adfc-config. The problem is if I specify a view activity or a bounded task flow as the exception handler then it works fine, but if the exception handler is a method activity then it is not recognized. What could be the cause?. I need to execute a method when an exception occurs.
    Version: 11.1.2.0
    Edited by: NewBee on Apr 23, 2013 10:37 AM

    Hi,
    there should not be a problem with this and I recently did the same with JDeveloper 11g R2 (not sure which version of JDeveloper you use because you did not share this information). I assume you just marked the method activity as an exception handler without any other configuration? If so then set a break point to the managed bean method that you access from the method activity to see if it actually stops there. Also note that not all exceptions are handled by the controller exception handler. E.g an exception during render response phase (typically an exception in a managed bean) is not handled by the controller. Also you need to avoid the managed bean that handles the exception to itself throw one. This however you will see when debugging the bean.
    Frank

  • ADF Faces: Exception Handler activity ain't reraised

    Hi there!
    I'm using a Studio Edition Version 11.1.1.3.0 (Build JDEVADF_11.1.1.3.PS2_GENERIC_100408.2356.5660).
    I've done this:
    1. created a bounded task flow flow1 and added to it:
    1.1 a vew activity view1 (the default activity) - shows an inputText field for a db column, for which there is a constraint;
    1.2 a method call activity method1 - calls commit;
    1.3 a view activity view2 - has an ouputText depicting an attribute's value for the same collection as that of inputText in view1;
    1.4 a view activity errorView (marked as an exception handler) - displays a localizedMessage from the currentViewPort;
    1.5 created for the view activities page fragments (with necessary fields and buttons).
    2. linked them as follows:
    2.1 view1 -*-> method1 -*-> view2;
    2.2 errorView -*-> view1.
    3. in the default unbounded task flow created a view activity main, a page file for it, and dropped onto the latter the flow1 as a region;
    4. launched the app (as the table contains some data, the view1 displays first row in a row set);
    5. entered into the view1 's field a non-violating value;
    6. pressed a button (which has just an action property set to move to the method1 ) - everything's fine, we get to the view2;
    6. rerun the app;
    7. entered incorrect value, pressed the button - flow goes, as expected, to the errorView, which informs us the exception's details (JBO-...);
    8. on the errorView page fragment pressed a button - we are now on the view1 page again;
    9. left the wrong (violating) value (or changed it to another incorrect value, doesn't matter) and pressed the button again;
    10. wow, we reached the view2, but, I guess, we hadn't to. Why so?
    One must note, that in clauses 7 and 9, after pressing the button, there apears a popup, which advises us about an ORA-... error, that is, in step 9 the ADF Faces does receive the exception, but why it doesn't reraise the errorView, that's the question.
    Though, when I change the method1 so, that it calls a bean's method, which always throws an IllegalArgumentException, then everything works as should to - we get to the infinite loop - view1 -> method1 -> errorView -> view1.
    Or, when I extract view2 from flow1, and instead of the former insert return activity with End Transaction set to commit, and then wrap (i.e call) flow1 from a newly created bounded task flow flow2, and in main 's page replace flow1 with flow2 region, the result is quite different. The aforesaid popup with ORA- error arises, until one enters a non-violating value. That is in this case everything is good, except, that control never flows into the errorView.
    And there is one more thing to note yet. When I've, namely method1, been calling a bean with the ever exception throwing method, the Integrated WLS's log was silent, but when the method1 was calling commit, then in the log we can see this twice:
    <Utils><buildFacesMessage> ADF: Adding the following JSF error message: ORA-02290: check constraint CHECK(THE_USER.THE_CONSTRAINT) violated
    java.sql.SQLIntegrityConstraintViolationException: ORA-02290: check constraint CHECK(THE_USER.THE_CONSTRAINT) violated
         at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:85)
         at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:206)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
         at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1035)
         at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
         at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:953)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1224)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3386)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3467)
         at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1350)
         at oracle.jbo.server.OracleSQLBuilderImpl.doEntityDML(OracleSQLBuilderImpl.java:429)
         at oracle.jbo.server.EntityImpl.doDML(EntityImpl.java:8044)
         at oracle.jbo.server.EntityImpl.postChanges(EntityImpl.java:6373)
         at oracle.jbo.server.DBTransactionImpl.doPostTransactionListeners(DBTransactionImpl.java:3172)
         at oracle.jbo.server.DBTransactionImpl.postChanges(DBTransactionImpl.java:2980)
         at oracle.jbo.server.DBTransactionImpl.commitInternal(DBTransactionImpl.java:2018)
         at oracle.jbo.server.DBTransactionImpl.commit(DBTransactionImpl.java:2277)
         at oracle.adf.model.bc4j.DCJboDataControl.commitTransaction(DCJboDataControl.java:1577)
         at oracle.adf.model.binding.DCDataControl.callCommitTransaction(DCDataControl.java:1404)
         at oracle.jbo.uicli.binding.JUCtrlActionBinding.doIt(JUCtrlActionBinding.java:1427)
         at oracle.adf.model.binding.DCDataControl.invokeOperation(DCDataControl.java:2141)
         at oracle.jbo.uicli.binding.JUCtrlActionBinding.invoke(JUCtrlActionBinding.java:730)
         at oracle.adf.controller.v2.lifecycle.PageLifecycleImpl.executeEvent(PageLifecycleImpl.java:394)
         at oracle.adfinternal.view.faces.model.binding.FacesCtrlActionBinding._execute(FacesCtrlActionBinding.java:252)
         at oracle.adfinternal.view.faces.model.binding.FacesCtrlActionBinding.execute(FacesCtrlActionBinding.java:210)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.sun.el.parser.AstValue.invoke(AstValue.java:157)
         at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
         at oracle.adf.controller.internal.util.ELInterfaceImpl.invokeMethod(ELInterfaceImpl.java:168)
         at oracle.adfinternal.controller.activity.MethodCallActivityLogic.execute(MethodCallActivityLogic.java:161)
         at oracle.adfinternal.controller.engine.ControlFlowEngine.executeActivity(ControlFlowEngine.java:989)
         at oracle.adfinternal.controller.engine.ControlFlowEngine.doRouting(ControlFlowEngine.java:878)
         at oracle.adfinternal.controller.engine.ControlFlowEngine.doRouting(ControlFlowEngine.java:777)
         at oracle.adfinternal.controller.engine.ControlFlowEngine.routeFromActivity(ControlFlowEngine.java:551)
         at oracle.adfinternal.controller.engine.ControlFlowEngine.performControlFlow(ControlFlowEngine.java:147)
         at oracle.adfinternal.controller.application.NavigationHandlerImpl.handleAdfcNavigation(NavigationHandlerImpl.java:109)
         at oracle.adfinternal.controller.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:78)
         at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:130)
         at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:190)
         at oracle.adf.view.rich.component.fragment.UIXRegion.broadcast(UIXRegion.java:148)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.broadcastEvents(LifecycleImpl.java:812)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:292)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:177)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:191)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:97)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:420)
         at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:420)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:247)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:157)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:94)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
         at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:414)
         at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:138)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:159)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.dms.wls.DMSServletFilter.doFilter(DMSServletFilter.java:330)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.doIt(WebAppServletContext.java:3684)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3650)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2268)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2174)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1446)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)What I'm doing wrong? And how can I dismiss that popup, as it duplicates errorView and does not get messages from a custom message bundle?
    Thanks in advance for any comments.
    Yerzhan.

    Hi there!
    I'm using a Studio Edition Version 11.1.1.3.0 (Build JDEVADF_11.1.1.3.PS2_GENERIC_100408.2356.5660).
    I've done this:
    1. created a bounded task flow flow1 and added to it:
    1.1 a vew activity view1 (the default activity) - shows an inputText field for a db column, for which there is a constraint;
    1.2 a method call activity method1 - calls commit;
    1.3 a view activity view2 - has an ouputText depicting an attribute's value for the same collection as that of inputText in view1;
    1.4 a view activity errorView (marked as an exception handler) - displays a localizedMessage from the currentViewPort;
    1.5 created for the view activities page fragments (with necessary fields and buttons).
    2. linked them as follows:
    2.1 view1 -*-> method1 -*-> view2;
    2.2 errorView -*-> view1.
    3. in the default unbounded task flow created a view activity main, a page file for it, and dropped onto the latter the flow1 as a region;
    4. launched the app (as the table contains some data, the view1 displays first row in a row set);
    5. entered into the view1 's field a non-violating value;
    6. pressed a button (which has just an action property set to move to the method1 ) - everything's fine, we get to the view2;
    6. rerun the app;
    7. entered incorrect value, pressed the button - flow goes, as expected, to the errorView, which informs us the exception's details (JBO-...);
    8. on the errorView page fragment pressed a button - we are now on the view1 page again;
    9. left the wrong (violating) value (or changed it to another incorrect value, doesn't matter) and pressed the button again;
    10. wow, we reached the view2, but, I guess, we hadn't to. Why so?
    One must note, that in clauses 7 and 9, after pressing the button, there apears a popup, which advises us about an ORA-... error, that is, in step 9 the ADF Faces does receive the exception, but why it doesn't reraise the errorView, that's the question.
    Though, when I change the method1 so, that it calls a bean's method, which always throws an IllegalArgumentException, then everything works as should to - we get to the infinite loop - view1 -> method1 -> errorView -> view1.
    Or, when I extract view2 from flow1, and instead of the former insert return activity with End Transaction set to commit, and then wrap (i.e call) flow1 from a newly created bounded task flow flow2, and in main 's page replace flow1 with flow2 region, the result is quite different. The aforesaid popup with ORA- error arises, until one enters a non-violating value. That is in this case everything is good, except, that control never flows into the errorView.
    And there is one more thing to note yet. When I've, namely method1, been calling a bean with the ever exception throwing method, the Integrated WLS's log was silent, but when the method1 was calling commit, then in the log we can see this twice:
    <Utils><buildFacesMessage> ADF: Adding the following JSF error message: ORA-02290: check constraint CHECK(THE_USER.THE_CONSTRAINT) violated
    java.sql.SQLIntegrityConstraintViolationException: ORA-02290: check constraint CHECK(THE_USER.THE_CONSTRAINT) violated
         at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:85)
         at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:206)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
         at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1035)
         at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
         at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:953)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1224)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3386)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3467)
         at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1350)
         at oracle.jbo.server.OracleSQLBuilderImpl.doEntityDML(OracleSQLBuilderImpl.java:429)
         at oracle.jbo.server.EntityImpl.doDML(EntityImpl.java:8044)
         at oracle.jbo.server.EntityImpl.postChanges(EntityImpl.java:6373)
         at oracle.jbo.server.DBTransactionImpl.doPostTransactionListeners(DBTransactionImpl.java:3172)
         at oracle.jbo.server.DBTransactionImpl.postChanges(DBTransactionImpl.java:2980)
         at oracle.jbo.server.DBTransactionImpl.commitInternal(DBTransactionImpl.java:2018)
         at oracle.jbo.server.DBTransactionImpl.commit(DBTransactionImpl.java:2277)
         at oracle.adf.model.bc4j.DCJboDataControl.commitTransaction(DCJboDataControl.java:1577)
         at oracle.adf.model.binding.DCDataControl.callCommitTransaction(DCDataControl.java:1404)
         at oracle.jbo.uicli.binding.JUCtrlActionBinding.doIt(JUCtrlActionBinding.java:1427)
         at oracle.adf.model.binding.DCDataControl.invokeOperation(DCDataControl.java:2141)
         at oracle.jbo.uicli.binding.JUCtrlActionBinding.invoke(JUCtrlActionBinding.java:730)
         at oracle.adf.controller.v2.lifecycle.PageLifecycleImpl.executeEvent(PageLifecycleImpl.java:394)
         at oracle.adfinternal.view.faces.model.binding.FacesCtrlActionBinding._execute(FacesCtrlActionBinding.java:252)
         at oracle.adfinternal.view.faces.model.binding.FacesCtrlActionBinding.execute(FacesCtrlActionBinding.java:210)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.sun.el.parser.AstValue.invoke(AstValue.java:157)
         at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
         at oracle.adf.controller.internal.util.ELInterfaceImpl.invokeMethod(ELInterfaceImpl.java:168)
         at oracle.adfinternal.controller.activity.MethodCallActivityLogic.execute(MethodCallActivityLogic.java:161)
         at oracle.adfinternal.controller.engine.ControlFlowEngine.executeActivity(ControlFlowEngine.java:989)
         at oracle.adfinternal.controller.engine.ControlFlowEngine.doRouting(ControlFlowEngine.java:878)
         at oracle.adfinternal.controller.engine.ControlFlowEngine.doRouting(ControlFlowEngine.java:777)
         at oracle.adfinternal.controller.engine.ControlFlowEngine.routeFromActivity(ControlFlowEngine.java:551)
         at oracle.adfinternal.controller.engine.ControlFlowEngine.performControlFlow(ControlFlowEngine.java:147)
         at oracle.adfinternal.controller.application.NavigationHandlerImpl.handleAdfcNavigation(NavigationHandlerImpl.java:109)
         at oracle.adfinternal.controller.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:78)
         at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:130)
         at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:190)
         at oracle.adf.view.rich.component.fragment.UIXRegion.broadcast(UIXRegion.java:148)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.broadcastEvents(LifecycleImpl.java:812)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:292)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:177)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:191)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:97)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:420)
         at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:420)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:247)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:157)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:94)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
         at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:414)
         at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:138)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:159)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.dms.wls.DMSServletFilter.doFilter(DMSServletFilter.java:330)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.doIt(WebAppServletContext.java:3684)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3650)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2268)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2174)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1446)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)What I'm doing wrong? And how can I dismiss that popup, as it duplicates errorView and does not get messages from a custom message bundle?
    Thanks in advance for any comments.
    Yerzhan.

  • JSF Exception Handling Example

    Here is an example of catching a backend exception and displaying it on the UI. It seems like most of the examples in books and such concern themselves with Validators and Converters. If you are trying to catch a backend exception, and you just want to display a UI message for it, see if this will work for you:
    JSF tags:
    <h:commandLink id="myActionLink" value="#{msgs.myLinkText}" binding="#{MyFormBean.uiComponentLink}" action="#{MyFormBean.linkProcessingMethod}"></h:commandLink>
    <h:messages layout="table" errorClass="Errors" styleClass="AlignLeft"/>
    ...And now the exception handling and message creation inside of the managed bean:
    private HtmlCommandLink uiComponentLink;
    * Method that processes the link action
    * @return String (action ID)
    public String linkProcessingMethod()
         try
              // BEGIN: TEST ONLY
              if(1 == 1)     // Always true
                   throw new Exception("TEST ERROR MESSAGE DISPLAY");
              // END: TEST ONLY
         return "dummyPageReference";     // No reference for this in faces-config.xml. Redisplays same page.
         catch (Exception e)
             addFacesMessageForUI("Exception detected. Message: " +e.getMessage());
             return "dummyPageReference";
    * Add faces message for display on the UI
    * @param String uiMessage
    private void addFacesMessageForUI(String uiMessage)
         FacesMessage facesMessage = new FacesMessage(uiMessage);
         FacesContext facesContext = FacesContext.getCurrentInstance();
         // Passing null for the client ID argument to the FacesContext
         // addMessage() method specifies the message as not belonging
         // to any particular UI component. This will cause the message
         // to be displayed as a general message on the UI
         facesContext.addMessage(null,facesMessage);
    }

    chrisjohn wrote:
    Following link would be helpful
    [http://technologicalbrainstorm.wordpress.com/2009/09/19/exception-handling-in-jsf/]
    Thanks!!Please, don't resurrect old threads, and especially not to post link-spam. Your account will get blocked if you continue with it. I'm locking this thread.
    Kaj

Maybe you are looking for