Topic
  • 4 replies
  • Latest Post - ‏2012-11-21T15:44:09Z by kolban
SystemAdmin
SystemAdmin
7615 Posts

Pinned topic IBM BPMv8 AIS java component and exception / error handling

‏2012-11-19T17:03:42Z |
Hi, when I generate an AIS Java component in Process Designer and I define for this component an error parameter (which is potentienally defined as a BO), this parameter is afterwards well defined in the IID advanced component wsdl file (ie the interface) as a fault. But I can't see nothing of an exception handling in the java implementation that I generate afterwards (advanced service implement in IID). Did I miss something? I don't know how to send any excpetion / fault from the java code. Pls see attachment for the example.
Updated on 2012-11-21T15:44:09Z at 2012-11-21T15:44:09Z by kolban
  • kolban
    kolban
    3316 Posts

    Re: IBM BPMv8 AIS java component and exception / error handling

    ‏2012-11-19T21:19:18Z  
    Hi there Kenza, welcome to the forum. Well posted question ... especially the screen shot. It made me want to test and research. I think I have found the answer. In your Java code, you want to throw an exception ... so what kind of exception shall it be? The answer is:

    ServiceBusinessException

    Google on that in the IBM InfoCenter. Basically, ServiceBusinessException extends RuntimeException. Its constructor (as I have tested it) has two parameters:

    Data - a JavaObject
    Name - a String

    The first parameter is the payload data you may want to send back with the exception
    The second parameter is the name of the exception being returned

    Once you have created an instance of a ServiceBusinessException, throw it in your Java code. This will then be passed up/back to the caller of the AIS and propagate as an error as desired.

    Neil
  • SystemAdmin
    SystemAdmin
    7615 Posts

    Re: IBM BPMv8 AIS java component and exception / error handling

    ‏2012-11-20T16:55:20Z  
    • kolban
    • ‏2012-11-19T21:19:18Z
    Hi there Kenza, welcome to the forum. Well posted question ... especially the screen shot. It made me want to test and research. I think I have found the answer. In your Java code, you want to throw an exception ... so what kind of exception shall it be? The answer is:

    ServiceBusinessException

    Google on that in the IBM InfoCenter. Basically, ServiceBusinessException extends RuntimeException. Its constructor (as I have tested it) has two parameters:

    Data - a JavaObject
    Name - a String

    The first parameter is the payload data you may want to send back with the exception
    The second parameter is the name of the exception being returned

    Once you have created an instance of a ServiceBusinessException, throw it in your Java code. This will then be passed up/back to the caller of the AIS and propagate as an error as desired.

    Neil
    Hi Kolban, thanks for your answer, tested today but does not seem to work :(
    My exception handling is as follow
    com.ibm.websphere.bo.BOFactory boFactory = (com.ibm.websphere.bo.BOFactory) ServiceManager.INSTANCE.locateService("com/ibm/websphere/bo/BOFactory");
    DataObject ex = boFactory.create("http://DAC", "AdvancedServiceException");
    ex.setString("Name", "Compte non trouvé");
    ex.setString("Description", "Compte non trouvé stack");
    ex.setString("Code", "1");
    System.out.println("Throw biz exc");
    throw new ServiceBusinessException(ex, "Compte non trouvé");

    And the error intermediate event is never fired in the BPD (see screenshot). Also when I unit test in IID I never
    have an exception as a return type.

    I can see in the logs the exception trace(*) but it seems it's not handled

    (*)
    20.11.12 17:49:15:161 CET] 00000082 SystemErr R com.ibm.websphere.sca.ServiceBusinessExceptionCompte non trouvé: BusinessObject@1f6fe2ec | Name= {http://DAC}AdvancedServiceException | XSTypeDefinition= {http://DAC}AdvancedServiceException] | Internal Information =[ element {http://DAC}AdvancedServiceException (: state:STATE_{ALL_PRECEDING_RESOLVED|ATTRIBUTES_RESOLVED|FOLLOWING_RESOLVED|NAMESPACE_NODES_RESOLVED|DIRTY|STATE_NODES_REORDERED|ALLOW_FAST_ACCESS} bitset=4332259 :) (: user data:com.ibm.xml.sdo.model.mediator.FastAccessDataFactory$FastAccessData{No original node | com.ibm.xml.sdo.model.mediator.FastAccessMediator@1f6fe2f7} :) | nodeID=-2 | subtreeID=null | CacheManager=com.ibm.xml.sdo.model.SDOCacheManager@1f6fe2c4 | JVM Object info=com.ibm.ws.box.bomodel.impl.BusinessObjectImpl@1f6fe2ec
  • SystemAdmin
    SystemAdmin
    7615 Posts

    Re: IBM BPMv8 AIS java component and exception / error handling

    ‏2012-11-21T12:50:43Z  
    • kolban
    • ‏2012-11-19T21:19:18Z
    Hi there Kenza, welcome to the forum. Well posted question ... especially the screen shot. It made me want to test and research. I think I have found the answer. In your Java code, you want to throw an exception ... so what kind of exception shall it be? The answer is:

    ServiceBusinessException

    Google on that in the IBM InfoCenter. Basically, ServiceBusinessException extends RuntimeException. Its constructor (as I have tested it) has two parameters:

    Data - a JavaObject
    Name - a String

    The first parameter is the payload data you may want to send back with the exception
    The second parameter is the name of the exception being returned

    Once you have created an instance of a ServiceBusinessException, throw it in your Java code. This will then be passed up/back to the caller of the AIS and propagate as an error as desired.

    Neil
    Hi Kolban,

    Just found out the issue, it was in my java code. Your answer was correct and helped me to solve my issue, thanks.
    Additionaly I found that the name of the ServiceBusinessException should be the name of the exception declared in the wsdl.
  • kolban
    kolban
    3316 Posts

    Re: IBM BPMv8 AIS java component and exception / error handling

    ‏2012-11-21T15:44:09Z  
    Hi Kolban,

    Just found out the issue, it was in my java code. Your answer was correct and helped me to solve my issue, thanks.
    Additionaly I found that the name of the ServiceBusinessException should be the name of the exception declared in the wsdl.
    Hi Kenza,

    That is great news and many thanks for taking the time to post the outcome. I simply hadn't gotten back to this question yet but would have sooner than later. By you taking the time to post you have proved yourself to be a great community member and saved time for other questions. Awesome. Good tip on the ServiceBusinessException!! Nice!!

    Neil