Java SDK Plugin Crash Reporting

Hello,

Actually i'm trying to implement Countly 19.09-sdk2-rc for backend service, i try Feature like Event, segment etc,

but when i trying CrashReporting, i got some error Null pointer when i hit Countly.session().addCrashReport(e, true). how i must do..?Thank's

 

note: in Config i already enabled Config.Feature.CrashReporting

0

Comments

6 comments
  • Official comment

    Hello Hendra,
    Could you please share the SDK initialization code? Please share the null pointer exception as well when you call "Countly.session().addCrashReport(e, true)" to report crash.

    Thanks,

    Comment actions Permalink
  • Hello Zahid, 

    i'm using maven, i use this dependency

    <dependency>
    <groupId>ly.count.sdk</groupId>
    <artifactId>java</artifactId>
    <version>19.09-sdk2-rc</version>
    </dependency>
    <dependency>
    <groupId>ly.count.sdk</groupId>
    <artifactId>core</artifactId>
    <version>19.09-sdk2-rc</version>
    </dependency>

    this is the sdk initialization code :

    String COUNTLY_SERVER_URL = "";
    String COUNTLY_APP_KEY = "";
    Config config = new Config(COUNTLY_SERVER_URL, COUNTLY_APP_KEY).setLoggingLevel(Config.LoggingLevel.DEBUG)
    .setDeviceIdStrategy(Config.DeviceIdStrategy.UUID)
    .enableFeatures(Config.Feature.Events, Config.Feature.Sessions, Config.Feature.CrashReporting,
    Config.Feature.Views, Config.Feature.UserProfiles, Config.Feature.Location)
    .setRequiresConsent(false).setEventsBufferSize(2);
    File targetFolder = new File("D:\\trying\\");
    Countly.init(targetFolder, config);
    Countly.onConsent(Config.Feature.Events, Config.Feature.Sessions, Config.Feature.CrashReporting,
    Config.Feature.Views, Config.Feature.UserProfiles, Config.Feature.Location);
    Countly.session().begin();

    and  the log when i try to call addCrashReport 

    Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
    java.lang.NullPointerException: null
    at java.base/java.lang.Class.isAssignableFrom(Native Method)
    at ly.count.sdk.internal.SDKModules.module(SDKModules.java:301)
    at ly.count.sdk.internal.SDKModules.module(SDKModules.java:289)
    at ly.count.sdk.internal.SDKCore.onCrash(SDKCore.java:170)
    at ly.count.sdk.internal.SessionImpl.addCrashReport(SessionImpl.java:312)
    at ly.count.sdk.internal.SessionImpl.addCrashReport(SessionImpl.java:303)
    at ly.count.sdk.internal.SessionImpl.addCrashReport(SessionImpl.java:31)
    at com.hendra.springbootcountly.api.ApiTest.recordCrash(ApiTest.java:105)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:892)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1039)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:88)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:114)
    at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:104)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:853)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1587)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.base/java.lang.Thread.run(Thread.java:834)

    Thank you 

    0
    Comment actions Permalink
  • Hello Hendra,
    This is a known issue for the version '19.09-sdk2-rc'. Due to a bug it's not possible to use crash related functionality. It is fixed in the latest Java SDK release. We would recommend you to use that version as it also fixed other issues. The latest release maven dependency.
    <!-- https://mvnrepository.com/artifact/ly.count.sdk/java -->
    <dependency>
    <groupId>ly.count.sdk</groupId>
    <artifactId>java</artifactId>
    <version>20.11.0</version>
    </dependency>

    Thank you

    1
    Comment actions Permalink
  • Thank's, 

    but when i Countly Sdk 20.11.0 

    [DEBUG]	Countly	[Cly] addCrashReport: t = null fatal = true name = Divided by zero segments = {Tester} logs = [Ljava.lang.String;@2e73a58b
    [WTF] Countly [CrashImpl] Throwable cannot be null
    [ERROR] Countly [Device] Cannot read meminfo / java.io.FileNotFoundException: \proc\meminfo (The system cannot find the path specified)

    what should i do..by the way i'm running on Windows 10, is there missing configuration. Thank you

    0
    Comment actions Permalink
  • While recording crash 'Thorwable t' is mandatory field. If it is 'null' sever will reject the crash request.
    In our sample app we are using 'e.getCause()' and it returns 'null'.
    If you are using 'e.getCause()' then replace it with 'e'.
    For example
     Countly.api().addCrashReport(e, false, "Divided by zero", null, "sample app");
    You can ignore the
    [ERROR]	Countly	[Device] Cannot read meminfo / java.io.FileNotFoundException: \proc\meminfo (The system cannot find the path specified)
    This situation it is being handled by SDK properly. That err is thrown because the platform does not support a specific targeted functionality.
    Thank you
    0
    Comment actions Permalink
  • Thank you very much for your help Zahid.

    0
    Comment actions Permalink

Please sign in to leave a comment.