Hi,
I too encountered the same issue, when I used the following code as stated
in the sample[1]:
public static void main(String[] args) {
new MicroservicesRunner()
.addInterceptor(new MetricsInterceptor())
.deploy(new HelloService())
.deploy(new DemoService())
.start();
}
It seems the "addInterceptor()" method is deprecated.
The workaround to this was as follows:
*No need to pass an instance of "MetricsInterceptor"
public static void main(String[] args) {
new MicroservicesRunner()
.addGlobalRequestInterceptor()
.addGlobalResponseInterceptor()
.deploy(new HelloService())
.deploy(new DemoService())
.start();
}
This worked out for me.
Hope this helps!
[1] https://github.com/wso2/msf4j/tree/master/samples/metrics
Thanks,
Viduranga.
On Thu, Oct 26, 2017 at 9:40 AM, Chanaka Fernando <[email protected]> wrote:
> Hi Devs,
>
> When I try to run metrics sample[1] in MSF4J, I'm getting the below NPE
> during the invocation of the service.
>
> [msf4j.executor.workerpool-1] INFO org.wso2.msf4j.analytics.metrics.Metrics
> - Initializing Metrics Services
> [msf4j.executor.workerpool-1] ERROR
> org.wso2.msf4j.analytics.metrics.MetricsInterceptor
> - Exception while executing request interceptor class
> org.wso2.msf4j.analytics.metrics.MetricsInterceptor
> java.lang.NullPointerException
> at org.wso2.carbon.metrics.core.Metrics.<init>(Metrics.java:78)
> at org.wso2.msf4j.analytics.metrics.Metrics.initializeServices(Metrics.
> java:62)
> at org.wso2.msf4j.analytics.metrics.Metrics.getMetricService(Metrics.java:
> 83)
> at org.wso2.msf4j.analytics.metrics.MetricsInterceptor.
> preCall(MetricsInterceptor.java:96)
> at org.wso2.msf4j.Interceptor.interceptRequest(Interceptor.java:65)
> at org.wso2.msf4j.interceptor.InterceptorExecutor.
> executeRequestInterceptor(InterceptorExecutor.java:321)
> at org.wso2.msf4j.interceptor.InterceptorExecutor.
> executeGlobalRequestInterceptors(InterceptorExecutor.java:206)
> at org.wso2.msf4j.interceptor.InterceptorExecutor.
> executeGlobalRequestInterceptors(InterceptorExecutor.java:52)
> at org.wso2.msf4j.internal.router.HttpMethodInfo.
> invokeResource(HttpMethodInfo.java:179)
> at org.wso2.msf4j.internal.router.HttpMethodInfo.invoke(
> HttpMethodInfo.java:143)
> at org.wso2.msf4j.internal.MSF4JMessageProcessor.dispatchMethod(
> MSF4JMessageProcessor.java:248)
> at org.wso2.msf4j.internal.MSF4JMessageProcessor.lambda$receive$0(
> MSF4JMessageProcessor.java:160)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(
> ThreadPoolExecutor.java:1142)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(
> ThreadPoolExecutor.java:617)
> at java.lang.Thread.run(Thread.java:745)
>
> Did anyone encounter such an issue?
>
> [1] https://github.com/wso2/msf4j/tree/master/samples/metrics
>
> Thanks,
> Chanaka
> --
> Thank you and Best Regards,
> Chanaka Fernando
> Senior Technical Lead
> m: +94 773337238 <+94%2077%20333%207238>
> https://wso2.com <https://wso2.com/signature>
>
>
>
>
>
>
>
> _______________________________________________
> Dev mailing list
> [email protected]
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>
--
Regards,
*Viduranga Gunarathne*
*Software Engineer Intern*
*WSO2*
Email : [email protected]
Mobile : +94712437484
Web : http://wso2.com
[image: https://wso2.com/signature] <https://wso2.com/signature>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev