IBM Support

webMethods Knowlegebase : Java Services NullException Service.Invoke() 2nd thread (1790892)

Troubleshooting


Problem

There seems to be an IS issue when invoking a Flow Service from a Java Service, when user is in a different thread.

This is important as one of the libraries does async programming, so the event handler receives notification in a different thread.

Using Designer "Generate Code" to generate this stub for invoking a Flow Service from Java Service:

/****/

// input

IData input = IDataFactory.create();

// output

IData output = IDataFactory.create();

try{

output = Service.doInvoke( "Default", "simple", input );

}catch( Exception e){

System.out.println("CANNOT CALL SVC");

e.printStackTrace();

}

/****/

That works, but when you wrap the Service.doInvoke in a different thread:

/****/

// input

IData input = IDataFactory.create();

// output

IData output = IDataFactory.create();

try{

output = Service.doInvoke( "Default", "simple", input );

}catch( Exception e){

System.out.println("CANNOT CALL SVC");

e.printStackTrace();

}

/****/

Stack Trace using above code:

jvm 1 | CANNOT CALL SVC

jvm 1 | java.lang.NullPointerException

jvm 1 | at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:487)

jvm 1 | at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:441)

jvm 1 | at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:397)

jvm 1 | at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:252)

jvm 1 | at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:93)

jvm 1 | at com.wm.app.b2b.server.Service.doInvoke(Service.java:713)

jvm 1 | at com.wm.app.b2b.server.Service.doInvoke(Service.java:604)

jvm 1 | at STC_INT_EWS.java.lambda$testInvokeFlow$0(java.java:523)

jvm 1 | at java.lang.Thread.run(Thread.java:748)

Stack Trace of using a customer library:

jvm 1 | CANNOT CALL SVC

jvm 1 | java.lang.NullPointerException

jvm 1 | at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:487)

jvm 1 | at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:441)

jvm 1 | at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:397)

jvm 1 | at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:252)

jvm 1 | at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:93)

jvm 1 | at com.wm.app.b2b.server.Service.doInvoke(Service.java:713)

jvm 1 | at com.wm.app.b2b.server.Service.doInvoke(Service.java:604)

jvm 1 | at STC_INT_EWS.java$3.notificationEventDelegate(java.java:331)

jvm 1 | at microsoft.exchange.webservices.data.notification.StreamingSubscriptionConnection.issueNotificationEvents(StreamingSubscriptionConnection.java:524)

jvm 1 | at microsoft.exchange.webservices.data.notification.StreamingSubscriptionConnection.handleServiceResponseObject(StreamingSubscriptionConnection.java:418)

jvm 1 | at microsoft.exchange.webservices.data.notification.StreamingSubscriptionConnection.handleResponseObject(StreamingSubscriptionConnection.java:562)

jvm 1 | at microsoft.exchange.webservices.data.core.request.HangingServiceRequestBase.parseResponses(HangingServiceRequestBase.java:218)

jvm 1 | at microsoft.exchange.webservices.data.core.request.HangingServiceRequestBase.access$000(HangingServiceRequestBase.java:60)

jvm 1 | at microsoft.exchange.webservices.data.core.request.HangingServiceRequestBase$1.run(HangingServiceRequestBase.java:330)

jvm 1 | at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

jvm 1 | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

jvm 1 | at java.lang.Thread.run(Thread.java:748)

Reproducible code:

Typo in body -- below is the code to reproduce:

/****/

// input

IData input = IDataFactory.create();

// output

IData output = IDataFactory.create();

try{

new Thread( () -> {

try {

Service.doInvoke( "Default", "simple", input );

} catch( Exception e) {

System.out.println("CANNOT CALL SVC");

e.printStackTrace();

}

}).start();

} catch( Exception e){

System.out.println("CANNOT CALL SVC OUTTER");

e.printStackTrace();

}

/****/

Document Location

Worldwide

[{"Line of Business":{"code":"LOB77","label":"Automation Platform"},"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SSVYEV","label":"IBM webMethods Integration"},"ARM Category":[{"code":"a8mKe00000000AQIAY","label":"webMethods Integration Server (PIE)"}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Windows 10 Professional Edts"}],"Version":"10.1"},{"Line of Business":{"code":"LOB77","label":"Automation Platform"},"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SSFIWYE","label":"IBM webMethods B2B"},"ARM Category":[{"code":"a8mKe00000000AQIAY","label":"webMethods Integration Server (PIE)"}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Windows 10 Professional Edts"}],"Version":"10.1"},{"Line of Business":{"code":"LOB77","label":"Automation Platform"},"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SSQG2X","label":"IBM webMethods Managed File Transfer"},"ARM Category":[{"code":"a8mKe00000000AQIAY","label":"webMethods Integration Server (PIE)"}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Windows 10 Professional Edts"}],"Version":"10.1"}]

Log InLog in to view more of this document

This document has the abstract of a technical article that is available to authorized users once you have logged on. Please use Log in button above to access the full document. After log in, if you do not have the right authorization for this document, there will be instructions on what to do next.

Document Information

Modified date:
20 March 2025

UID

ibm17226614