NullPointerException when executing java service

Hi

I wanted to time the execution of specific adapter services within a flow service so I wrote a three java services to start, end and calculate time differences. The start and end java services work fine. The service to calculate the difference between start and end compiles ok but when it executes within the flow service I get:
java.lang.NullPointerException
at Lbenton.javaServices.calculateTimeInterval(javaServices.java:111)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.wm.app.b2b.server.JavaService.baseInvoke(JavaService.java:322)
at com.wm.app.b2b.server.invoke.InvokeManager.process(InvokeManager.java:612)
at com.wm.app.b2b.server.invoke.StatisticsProcessor.process(StatisticsProcessor.java:44)
at com.wm.app.b2b.server.invoke.ServiceCompletionImpl.process(ServiceCompletionImpl.java:235)
at com.wm.app.b2b.server.invoke.ValidateProcessor.process(ValidateProcessor.java:49)
at com.wm.app.b2b.server.ACLManager.process(ACLManager.java:198)
at com.wm.app.b2b.server.invoke.DispatchProcessor.process(DispatchProcessor.java:39)
at com.wm.app.b2b.server.AuditLogManager.process(AuditLogManager.java:411)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:521)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:369)
at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:246)
at com.wm.app.b2b.server.BaseService.invoke(BaseService.java:168)
at com.wm.lang.flow.FlowInvoke.invoke(FlowInvoke.java:324)
at com.wm.lang.flow.FlowState.invokeNode(FlowState.java:581)
at com.wm.lang.flow.FlowState.stepIncremental(FlowState.java:489)
at com.wm.lang.flow.FlowState.invoke(FlowState.java:376)
at wm.server.flowimpl.stepFlow(flowimpl.java:183)
at sun.reflect.GeneratedMethodAccessor166.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.wm.app.b2b.server.JavaService.baseInvoke(JavaService.java:332)
at com.wm.app.b2b.server.invoke.InvokeManager.process(InvokeManager.java:612)
at com.wm.app.b2b.server.invoke.StatisticsProcessor.process(StatisticsProcessor.java:44)
at com.wm.app.b2b.server.invoke.ServiceCompletionImpl.process(ServiceCompletionImpl.java:235)
at com.wm.app.b2b.server.invoke.ValidateProcessor.process(ValidateProcessor.java:49)
at com.wm.app.b2b.server.ACLManager.process(ACLManager.java:198)
at com.wm.app.b2b.server.invoke.DispatchProcessor.process(DispatchProcessor.java:39)
at com.wm.app.b2b.server.AuditLogManager.process(AuditLogManager.java:411)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:521)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:369)
at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:246)
at com.wm.app.b2b.server.comm.DefaultServerRequestHandler.handleMessage(DefaultServerRequestHandler.java:129)
at com.wm.app.b2b.server.HTTPMessageHandler.process(HTTPMessageHandler.java:168)
at com.wm.app.b2b.server.Dispatch.run(Dispatch.java:312)
at com.wm.util.pool.PooledThread.run(PooledThread.java:105)
at java.lang.Thread.run(Thread.java:595)

I have searched but found nothing to explain why this happens. Any help would be appreciated.

tia
larry

Try using currentTimeinMillis built in function to get the current time before and after adapter service and try to see difference using math built in function.

Thanks, I finally figured it out using getTimeInMillis, StringToLong, subtractObjects and LongToString

Which of course is duplicating the facilities provided by the built-in services that itchandar mentioned. Why did you write new Java code when services that could do what you needed already existed?

I searched all the documentation (and google) but I couldn’t find a reference to a webMethods function named ‘currentTimeinMillis’, the closest I found was 'getTimeInMillis ’ and I wasn’t sure what built-in ‘math’ functions I would use and where to find them (other than wmPublic and Utilities)?
I would much prefer to use built-in functions as I don’t want to re-invent the wheel, so to speak, but as a beginner sometimes it’s hard to navigate the complex structure in Developer.

…did you try referring the wM Built In services guide dude??? :uhoh:

Cheers!!!

You’re right that finding available services can be challenging when new to the environment. The Built-in Services Reference is an excellent resource for browsing what’s available.

The ps.util.system:getTimeMillis is one possible approach. Call that at start. Then call it again for the end time. Then use pub.math:subtractInts (in WmPublic) to get the elapsed time in millis.

Note that the getTimeMillis service is from the PSUtilities package, and is not an out-of-the-box package installed by the Installer. It is a separately downloaded package you can get from Advantage.

Yes Xena I searched all the wm documentation installed with developer but as reamon mentions it is not an out of the box package. Thanks reamon I will download the PSUtilities package. I might mention that I have no peers at work to help and I’ve never had any formal training in wm and everything I’ve learnt so far is from reading the wm documentation, this forum, wm advantage site and mainly the customware and itToolbox web sites, oh and of course google. Thanks for your help.