IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  How to Throw a Custom Exception in java Services

    Posted Thu May 11, 2006 02:56 PM

    Hi ,

    Couls anyone please tell me if the java service in webMethods support handling of a Custom Exception (other than a ServiceException) . i have encountered a problem wherein i want to close a JMS QueConnection in a java service in finally block . The close connection is throwing an exception ‘javax.jms.JMSException’ . But the throws part(currently only ServiceException) in service signature of the java service cant be edited with
    JMS Exception .

    IS there any other way out here ?


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 2.  RE: How to Throw a Custom Exception in java Services

    Posted Thu May 11, 2006 03:12 PM

    You cannot change the service signature of a Java Service to throw a specific type of Java Runtime Exception. The Java Service is always designed to throw a ServiceException. However you can handle your own error scenarios within the java service by putting the code in a try catch block. In your case to close the JMS QueueConnection in the finally block, have a try and catch block within the finally block which actually close connections to the JMS Queues and have the catch block throw the specific Runtime Exception.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 3.  RE: How to Throw a Custom Exception in java Services

    Posted Thu May 11, 2006 04:04 PM

    In addition, you can create your own static classes in the “shared source” area of the java service. Those classes can throw custom exceptions which must be caught by the code in your java service.

    Mark


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 4.  RE: How to Throw a Custom Exception in java Services

    Posted Thu May 11, 2006 05:36 PM

    What about this? Will this work for you?

    finally
    {
    try
    {
    if(connection != null)
    connection.close();
    }
    catch (javax.jms.JMSException jmse) { } // ignore
    }

    Or instead of ignoring the exception completely, you could write to the debug log.


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 5.  RE: How to Throw a Custom Exception in java Services

    Posted Fri May 12, 2006 06:20 AM

    Thankx Rob, Mark and Sivaram .The Info was pretty helpful . I guess i will hae to handle the JMS Exception in a seperate try catch block. Thanks once again for timely reply


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods