webMethods

webMethods

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.  Throw exception from shared source in a java service

    Posted Mon July 11, 2016 05:19 AM

    Hi,

    Does any one have an idea how to throw service Exception from shared source in a java service in a catch block. When I use “throw new ServiceException” inside the catch block of shared source I am getting error like “unhandled Exception type ServiceException”.

    Thanks in advance,
    vinodkumar.


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


  • 2.  RE: Throw exception from shared source in a java service

    Posted Mon July 11, 2016 05:35 AM

    I assume, this shared rsource is a java method which is called from a java service. Hence you have to add the “throws ServiceException” clause to the method in the shared resource. Java services have it by default.


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


  • 3.  RE: Throw exception from shared source in a java service

    Posted Mon July 11, 2016 05:50 AM

    Hi fml2,

    Thanks for the reply. Just posting a pseudo code.

    main class code:

    public static final void invokeFilePullImpSrv(IData pipeline)
    throws ServiceException {

    try
    {
    doCalculation() // Call method in shared resource
    }
    catch
    {
    throw new ServiceException(e);
    }

    shared resource code:

    static class sub class
    {
    public void doCalculation()
    {
    try
    {
    }
    catch(Exception e)
    {
    throw new ServiceException(e); // getting error here
    }
    }
    }

    Please let me know how can I throw exception back to main class from shared resource code so that the main class in-turn throws the service exception.

    thanks,
    vinodkumar.


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


  • 4.  RE: Throw exception from shared source in a java service

    Posted Mon July 11, 2016 11:06 AM

    As I said: add the throws clause to the throwing method:

    public void doCalculation() throws ServiceException

    This is basic java.


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