Is there a way to handle custom java exception in OSB?

For example, i created a exception that extends RuntimeException.
My exception has a new field called "code".
I want to handle this exception in Oracle Service Bus process and retrieve this code to throws another exception with a XML structure that includes the code.
Is there a way to do that ?
<con:fault xmlns:con="http://www.bea.com/wli/sb/context">
     <con:errorCode>BEA-382515</con:errorCode>
     <con:reason>Callout to java method "public static org.apache.xmlbeans.XmlObject ...</con:reason>
     <con:java-exception xmlns:con="http://www.bea.com/wli/sb/context">
         <con:java-content ref="jcid:33a6c126:14006f3df18:-7fd9"/>
     </con:java-exception>
     <con:location xmlns:con="http://www.bea.com/wli/sb/context">
         <con:node>optmusPipeline</con:node>                    
         <con:pipeline>optmusPipeline_request</con:pipeline>
         <con:stage>processStage</con:stage>
         <con:path>request-pipeline</con:path>   
     </con:location>
</con:fault>
it is not enough to recover the information i needed.

Hi Sandro,
I've got the same situation. I agree that returning xml from function is not a best choice as you have to manually check if return status is an error or not. Processing exception in error handler is better and this is how I do it:
I am doing a java callout to a function that can throw exception. Then I add ErrorHandler to stage containing this callout (all the exception are caught here).
In the error handler I check if $fault/ctx:java-exception is not null. If not then I pass thrown exception to my utility function that converts it to xml similar to yours:
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
public static XmlObject exceptionToXML(Throwable exception)
  throws XmlException {
  String xmlString = exceptionToString(exception);
  return XmlObject.Factory.parse(xmlString);
public static String exceptionToString(Throwable exception) {
  String cause = "";
  if (exception.getCause() != null) {
  cause = exceptionToString(exception.getCause());
  return String
  .format("<exception><name>%s</name><description>%s</description>%s</exception>",
  exception.getClass().getName(), exception.getMessage(),
  cause);
Calling exceptionToXML with $fault/ctx:java-exception/ctx:java-content returns:
<exception>
     <name>pl.app.MyException</name>
     <description>Exception message</description>
</exception>
Then you can check the exception class (IF action: $exception/name/text() = "pl.app.MyException") and handle it accordingly.
Good luck,
Krzysiek

Similar Messages

  • Is there any way to handle the navigation without defining it in faces-conf

    hi,
    I am new to JSF and I got lots of information from this forum. My new query is given below,
    Is there any way to handle the navigation without defining it in faces-config.xml file? That means i want to navigate to a destination page programatically from the java class rather than declaring it it faces-config.xml file.
    Your help and suggestions are hightly appreciated...
    Thanks and regards,
    Sudheesh K S

    JSF as defaault looks your *-config.xml files in your web.xml configuration or default faces-config.xml file. If do not use default look third party tools like seam or others....                                                                                                                                                                                                                                                                                                                                                                   

  • _Is there a way to make custom keyboard mapping a default?

    _Is there a way to make custom keyboard mapping a default?
    What I mean is, for example, I want to disable <command> S for saving (so I don't accidentally hit it).
    Thanks!
    Hugh

    Edit>Keyboard Shortcuts Make the changes you want to the shortcuts and save with a new name. In the dropdown at the top choose your new set and close. Quit and restart to seal the deal.

  • Is there a way to handle system exception ERROR_MESSAGE?

    Hi,
    I have a program executed in background, which produces a bunch of consecutive documents for a set of Bulk Shipments -> TD Loading and TD Delivery Confirmation. To create those documents I use function modules 'OIGI_LOADING_CREATE' and 'OIGI_DEL_CONF_CREATE'  - both from Industry-Solution Oil-and_Gas (IS-Oil).
    In some cases these FM-s produces error messages (E-type) which cancel execution of the program and broke my flow-logic.
    Below are few messages recorded in a job log for my task:
    18.08.2005 15:56:41 Job started                                                                         
    18.08.2005 15:56:41 Step 001 started (program /PTRL/TAS_POSTPONDED_SYNC, variant , user name IMUTAFCHIEV)
    18.08.2005 15:56:58 Shipment 180753 saved                                                               
    18.08.2005 15:57:06 The plant data of the material 177 is locked by the user BMINKOV                    
    18.08.2005 15:57:06 The plant data of the material 177 is locked by the user BMINKOV                    
    18.08.2005 15:57:06 The plant data of the material 177 is locked by the user BMINKOV                    
    18.08.2005 15:57:06 Job cancelled after system exception ERROR_MESSAGE                                  
    Both function modules are not designed to handle any exceptions, and in owr environment (4.6c) there is no documented system exception 'ERROR_MESSAGE' which to be handled in CATCH-ENDCATCH block.
    Is there a way to handle this exception and to track the list of error messages produced by some FM into an internal table, log, whatever, as it is done in the log of the background job. I need to find a way write these messages in my log-tables and to proceed further with my flow-logic.
    FYI: my program executes an RFC call to a remote system and retrieve a list of documents which need to be synchronized with R/3. I loose information, if the R/3 broke my flow-logic.
    Any help would be highly appresiated.
    Many thanks in advance.
    Ivaylo Mutafchiev

    Sven,
    I made few programs where we used business scenario:
    IS-Oil Shipment => IS-Oil Loading Confirmation => IS-Oil Delivery Confirmation.
    All of them are based on Function Module call:
    1. OIGI_LOADING_CREATE and
    2. OIGI_DEL_CONF_CREATE.
    To load shipment I call 1st FM in a way:
      CALL FUNCTION 'OIGI_LOADING_CREATE' DESTINATION 'NONE'
           EXPORTING
                I_SUBRC     = 9  "save and commit
                I_SHNUMBER  = shNumber
                I_VEHICLE   = vehicle
                I_LDPLT     = plant
                I_LDDATE    = loadDate
                I_LDTIME    = loadTime
                I_LDCDAT    = loadDate
                I_VEH_NR    = veh_nr
           TABLES
                T_OIGISVMQ  = quantity_items
                T_OIGISVMQ2 = hpm_append
                T_OIGISIQ   = doc_quan_items
           EXCEPTIONS
                COMMUNICATION_FAILURE = 1 MESSAGE p_error
                SYSTEM_FAILURE = 2 MESSAGE p_error.
    To confirm shipment (status 4) I call the same FM with:
      CALL FUNCTION 'OIGI_LOADING_CREATE' DESTINATION 'NONE'
           EXPORTING
                I_SUBRC    = 39  "confirm & commit 2nd step
                I_SHNUMBER = shNumber
                I_VEHICLE  = vehicle
                I_LDPLT    = werks
           EXCEPTIONS
                COMMUNICATION_FAILURE = 1 MESSAGE sh_error
                SYSTEM_FAILURE = 2 MESSAGE sh_error.
    And finaly to finish process (status = 6) I call 2nd FM in a way:
      CALL FUNCTION 'OIGI_DEL_CONF_CREATE' DESTINATION 'NONE'
           EXPORTING
                I_SUBRC         = 19  "save, confirm and commit
                I_SHNUMBER      = shNumber
                I_RAPID_CONFIRM = 'X'
                I_DDCDAT        = loadDate
                I_DLDATE        = loadDate
                I_DLTIME        = loadTime
           EXCEPTIONS
                COMMUNICATION_FAILURE = 1 MESSAGE p_error
                SYSTEM_FAILURE = 2 MESSAGE p_error.
    FYI: It tooks me some time to 'investigate' and find correct use of these function modules. And I worked VERY CLOSE with our SD consultant.
    For details (what the export parameters and tables consist of) and sample code, please contact me at:
    ivaylo dot mutafchiev at vbs dot bg
    I would be glad to share my knowlege.
    Regards,
    Ivaylo

  • Is there a way to show Custom message in Outlook Mail read Inspector Window same as When a File is opened in Protected View.

    Is there a way to show Custom message in Outlook Mail read Inspector Window same as When a File is opened in Protected View.
    If we open a Document from Untrusted location,the file is opened in Protected mode and a Red Message bar is shown below the ribbon for Excel,Word apps.
    Can we show this type of similar message bar with custom Message in Outlook or any other Office App.

    Are you displaying an MSG file? Keep in mind that Outlook creates a temporary copy in one of Outlook folders, so strictly speaking your are not looking at a file.
    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

  • How can I contact customer service because my registration number according to Adobe cannot be upgraded; and Adobe's message to me said that I was registered for CS4; I am currently registered for CS5.  Is there no way to contact customer service via emai

    How can I contact customer service because my registration number according to Adobe cannot be upgraded; and Adobe's message to me said that I was registered for CS4; I am currently registered for CS5.  Is there no way to contact customer service via email or phone re this problem?

    Problems with registration you can contact our support team at Contact Customer Care.  Please make sure you are signed in and selecting the proper selections from the pull down.  If you continue to not be able to contact our support team then I would strongly recommend the use of a different web browser, computer, smart phone, or tablet.

  • Is there a way to get custom JPEG album art to "stick" in iTunes 11.1.4?

    Is there any way to get custom jpeg album art to stick in iTunes 11.1.4?

    You can Right-Click too to bring up the Get Info dialog box. If you go to the artwork tab, (the last tab) then you can click the add button, and a standard Mac dialog box opens and you can navigate to the jpg file of your choice in a normal Mac fashion.

  • Is there any way to write a Java prg without main()

    I would like to know Is there any way to write a Java program without using main() function.

    > i am unable to execute the program ..............i
    think there must be a main method through with the
    program starts
    The program can be compiled and run. After running it, you'll see "They'll kill you for that" followed by something like "java.lang.NoSuchMethodError: main" and finally someone with a big Volvo will burst into your room and runs you over.

  • Handling apllication java.Exceptions

    I've developed an Weblogic WebService Application with several webservices inside.
    They are working fine but when a WebService throws a java Exception this exception is putted inside a SoapFaultException.
    After some research I figured that I should create my own Exceptions that inherits from SoapFaultException to best format the exception message
    my clients will receive, ok it is done and it's working. Now I need to handle all java Exceptions (witch were not throw by me) to put it in my own Exceptions witch inherits from soapFaultException. Does anybody know if I can implement an Exception handler that will capture all java Exceptions unhandled by my applicatio.
    I'm using WLS 9.2.

    Rethrow an exception and catch it in the call in JavaFX code?

  • Is there a way to create a Java class based on what's defined in a schema?

    I have a set of schemas that define what messages I will get as an XML stream (sent as UDP packets). Is there a way to parse the schemas into a set of java classes that match the fields in the schema? If so, next think would be to feed a string or byte array to instances of these objects and have a method that parses it and fills all the fields. But is the first part possible? Somebody linked http://www.cafeconleche.org/books/xmljava/chapters/ in another thread, but that seems to be for regular XML, not schema, unless I'm confused which is entirely possible, I'm new to XML and using it in Java in this way.

    For future reference, [Java API for XML Binding|http://www.dummies.com/WileyCDA/DummiesArticle/Building-Custom-Code-with-Java-API-for-XML-Binding-JAXB-.id-1489,subcat-BUILDING.html] (JAXB) allows for [generation of Java classes|http://www.oracle.com/technology/pub/articles/marx-jse6.html] from XML Schema (or even DTD) using its xjc compiler.

  • Is there any way to create custom views, like in Thunderbird & Evolution?

    Hi Folks,
    I have recently switched to Mac. Before this I was using Linux. For mail I used Thunderbird (TB) for many years, and then eventually switched to Evolution Mail (EM) for its smoother integration into Linux.
    On both TB and EM I revolved my work flow around custom folder views. As new email came in I would label it (on EM, or tag it on TB). I have numerous inboxes (email accounts) so I would generally be starting out in a smart folder that displays all mail in each inbox. I would most of the time view that smart folder with a Custom View filter in place. The filter would simply display ONLY mail with NO tags/labels.
    Once my filter inbox showed NO messages it meant I had labeled everything. I would them use other smart folders to display mail with certain labels AND NO "Completed" label. That way I could go to my "Reply ASAP" folder and see what needed my immediate attention. Each email I replied to I would then add the label COMPLETED and it would vanish from my view.
    I explain the above in case someone has specific suggestions on how to achieve a similar workflow on Mail.
    In short, what I am wondering is this:
    - Is there a built in way to filter a folder on the spot (with a drop down list of predefined and custom Views) --- I have looked and so far did not find this feature
    - Is there a way to do this with a script or add-on? I have looked at many and not found a suitable one yet.
    I am appealing to the knowledge of those with more experience in Mail. It is new to me.
    I am currently using TB on my Mac because it gives me the above feature. BUT it does not have the same degree of integration with the OS and other Mac specific apps that Mail has. Thus I am keen to stick with Mail.
    With thanks,
    Jonathan

    In addition to above:
    I have installed a trial of Mailtags. It certainly improves the tagging capability of Mail.
    I have also looked at the Smart Mailboxes and Smart Mailbox Folders.
    As far as I can tell, however, there is no option to set up a smart mailbox that ONLY shows message with NO LABEL or NO MAILTAG (as the case may be). I can display messages with particular TAGS but not NO tags.
    Is there any way to add more options to the Smart Mailbox filter system?
    Cheers,
    Jonathan

  • HT5429 is there a way to enter custom directions to locations on the maps app?

    I have directions I want to use to get to a location but they are not the same as the ones the maps app pulls up.  is there a way to edit the route on the maps app for custom directions?

    No.

  • Is there a way to compress using Java deflator & uncompress using UTL ?

    hi,
    I was wondering if there is a way to compress using Java deflator on the java side & then uncompress in the stored procedure. UTL_COMPRESS.LZ_UNCOMPRESS(BLOB) ?
    I tried that, but I'm currently getting Invalid data exceptions..
    The Other option is to use Java Inflator in the Java stored procedure. But I want to avoid java stored procedures.
    Thanks in advance.
    /// java side
    String inputString = loadXML (inputfile);
    byte[] input = inputString.getBytes("UTF-8");
    byte[] output = new byte[inputString.length()];
    Deflater compresser = new Deflater(Deflater.BEST_SPEED, true);
    compresser.setInput(input);
    OracleCallableStatement insertALLStatement = (OracleCallableStatement) con.prepareCall(insertALLSQL);
    InputStream stream = new ByteArrayInputStream(data);
    insertALLStatement.setBinaryStream(1, stream, (int)data.length);
    insertALLStatement.execute();
    // pl sql
    create or replace PROCEDURE INSERTBYTES
    ( compressed IN BLOB
    ) AS
    uncompressed:=UTL_COMPRESS.lz_uncompress (compressed);
    ...

    That depends.
    Does Java Deflator use the same compression technique as UTL_COMPRESS.LZ_UNCOMPRESS? i.e. is it using Lempel Ziff compression algorithms. If so, then, yes, there's a possibility it could work, however it also depends if the Java Deflator stores header information about the compressed data differently to how LZ_UNCOMPRESS expects it, or even if header information is included or it's just raw compressed data.
    It sounds a bit like compressing a file with Yoshi compression and then trying to use PKZIP to uncompress it methinks, in which case you're going to be out of luck. You have to ensure the compression algorithms and file formats are compatible.

  • Is there any way to check another Java program running status?

    HI. I want to write a Java program on hand-set but my program seems needs lots of resources and if there is another Java program running on the same hand-set simultaneously, my program will slow down. So, I want to check if there is another Java program is running on the hand-set, my program will show a message to user reminding user to close another program first.
    Is there any way to do so?

    On most recent devices, the application is not terminated but paused by using phone functions, and can be reactivated from the aplication management software. The javax.microedition.midlet package documentation is quite specific, if a tad obscure, about the MIDlet lifecycle and the role of the MIDelt methods vis-a-vis the AMS.
    {color:#0000ff}http://java.sun.com/javame/reference/apis/jsr037/javax/microedition/midlet/package-summary.html{color}
    Parenthetically, I've never been able to figure out how resumeApp should be used, nor have I seen this method invoked in any of the samples that come with the WTK, but I haven't gone through all of them.
    I believe the still-in-progress MIDP3 will make it possible to have MIDlets that share the screen with native apps and which can be minimized and restored.
    db

  • Is there a way to create customer smart controls?

    I use Mainstage to play worship music in a few different church venues and love the flexibility that Mainstage brings. I'm using an external instrument, Omnisphere on my Akai MPK88. I have each channel mapped to sliders on my keyboard, which is great for Omnisphere, however, if I want to switch insturments, for example to the Hammond B3, I would like be able to use the new smart controls feature and be able to see the controls for this instrument. Is there a way to keep my sliders on screen for Omnisphere, but have them change when I am using a native patch? Right now, the controls just get greyed out and go dead. Thanks!

    You can pick any Smartcontrol for any patch, but you can not create your own Smartcontrol from scratch.

Maybe you are looking for

  • Work path of 'hollow' characters?

    How do I make a work path of a character that consists of a loop (letters O, O, and P in LOOP for example) so that i get the inner and outer walls of a character, take O for example, instead of a solid O? O (the black area of the O should be filled w

  • Nokia N8 Belle - Wi-Fi Problems

    Hello, This problem is starting to be super annoying with the Wireless Connection on Nokia N8-00 with Belle ! Everytime when I'm connection the phone on my wireless router, and I am trying to download something in OVI Store or other application, conn

  • Using a chart as a template

    In Excel, I can easily take an existing chart/graph, copy and paste it into the current worksheet or even another worksheet and then open the menu for chart data to easily change the series data. This allowed all the attributes (scale, legend, font,

  • Exchange 2013 CU 6 update fails on transport service

    i ran the update and it keeps getting the following error and i cannot find any info on the error Exchange Server component Mailbox role: Transport service failed. Error: Error: The following error was generated when "$error.Clear();           $feVdi

  • Adobe Premiere Elements 9 AIDE-HELP (menus)

    I have the  IMac 2013  i5. When I'm working on Adobe Premiere ELements 9, the program is opening a message which is telling me that there's an error. Then the program closes. It ALWAYS happens when I'm trying to put a menu in my video. It is related