# Use apm agent for java springboot noerrordata

**URL:** <https://discuss.elastic.co/t/use-apm-agent-for-java-springboot-noerrordata/164970>\
**Category:** APM\
**Created:** [January 21, 2019, 2:13am UTC](https://discuss.elastic.co/t/use-apm-agent-for-java-springboot-noerrordata/164970 "2019-01-21T02:13:15Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![fangfhm](https://avatars.discourse-cdn.com/v4/letter/f/96bed5/32.png) [@fangfhm](https://discuss.elastic.co/u/fangfhm)\
**Post date:** [January 21, 2019, 2:13am UTC](https://discuss.elastic.co/t/use-apm-agent-for-java-springboot-noerrordata/164970/1 "2019-01-21T02:13:15Z")

</div>

hello  
I have a problem  
no error data  
Hope to help me thank you!!!

this apm-agent-config  
nohup /usr/local/jdk1.8.0\_161/bin/java -jar -javaagent:/home/ydbs/socialbureau/elastic-apm-agent-1.3.0.jar   
-Delastic.apm.service\_name=socialBureau  
-Delastic.apm.server\_url=http://172.18.108.109:8200   
-Delastic.apm.capture\_body=all   
-Delastic.apm.log\_level=TRACE   
-Delastic.apm.transaction\_sample\_rate=1   
-Delastic.apm.enable\_log\_correlation=true   
-Delastic.apm.unnest\_exceptions=\*   
-Delastic.apm.log\_file=/home/ydbs/socialbureau/elastic-apm.log   
-Delastic.apm.application\_packages=com.socialBureau.site.socialBureau   
-jar /home/ydbs/socialbureau/socialBureau-2.0.0-PRO.jar \>\> /home/ydbs/socialbureau/logs/log.log 2\>&1 &

############################################

cat /home/ydbs/socialbureau/logs/log.log

```auto
2019-01-21 09:50:22.910 [http-nio-9014-exec-6] INFO com.socialBureau.common.filter.UserInfoFilter -===========userValue===============>null
java.lang.NullPointerException
	at com.socialBureau.site.socialBureau.personnel.controller.CertificateController.findFile(CertificateController.java:33)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess

#######################################################
cat /home/ydbs/socialbureau/elastic-apm.log

2019-01-21 09:50:22.908 [http-nio-9014-exec-6] DEBUG co.elastic.apm.agent.impl.ElasticApmTracer - Activating '' 00-ccbdfb750157b9dcf3f4a64183d9b8f8-6978f04a5c35bce7-01 on thread 41
2019-01-21 09:50:22.914 [http-nio-9014-exec-6] DEBUG co.elastic.apm.agent.impl.ElasticApmTracer - Deactivating 'CertificateController#findFile' 00-ccbdfb750157b9dcf3f4a64183d9b8f8-6978f041
2019-01-21 09:50:22.914 [http-nio-9014-exec-6] DEBUG co.elastic.apm.agent.impl.ElasticApmTracer - } endTransaction 'CertificateController#findFile' 00-ccbdfb750157b9dcf3f4a64183d9b8f8-6971
2019-01-21 09:50:22.914 [http-nio-9014-exec-6] TRACE co.elastic.apm.agent.impl.ElasticApmTracer - ending transaction at
java.lang.RuntimeException: this exception is just used to record where the transaction has been ended from
	at co.elastic.apm.agent.impl.ElasticApmTracer.endTransaction(ElasticApmTracer.java:272)
	at co.elastic.apm.agent.impl.transaction.Transaction.doEnd(Transaction.java:146)
	at co.elastic.apm.agent.impl.transaction.AbstractSpan.end(AbstractSpan.java:210)
	at co.elastic.apm.agent.impl.transaction.AbstractSpan.end(AbstractSpan.java:197)
	at co.elastic.apm.agent.servlet.ServletTransactionHelper.onAfter(ServletTransactionHelper.java:155)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:168)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)

```

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [January 21, 2019, 5:02am UTC](https://discuss.elastic.co/t/use-apm-agent-for-java-springboot-noerrordata/164970/2 "2019-01-21T05:02:52Z")

</div>

Hi and thanks for trying out our APM solution!

> [@fangfhm](#):
>
> 2019-01-21 09:50:22.910 [http-nio-9014-exec-6] INFO com.socialBureau.common.filter.UserInfoFilter -===========userValue===============\>null

Looks like `com.socialBureau.common.filter.UserInfoFilter` is catching the NPE and prints an INFO message. Is that a ServletFilter?  
The Java agent reports errors for Transactions/Spans that end with an Exception. A ServletFilter is invoked within a FilterChain, which we instrument to capture transactions so if the Exception is caught without being rethrown within the chain, we don't have visibility to it.

I hope this makes sense.  
Eyal.

---

<div class="post-metadata">

**Author:** ![fangfhm](https://avatars.discourse-cdn.com/v4/letter/f/96bed5/32.png) [@fangfhm](https://discuss.elastic.co/u/fangfhm)\
**Post date:** [January 21, 2019, 6:53am UTC](https://discuss.elastic.co/t/use-apm-agent-for-java-springboot-noerrordata/164970/3 "2019-01-21T06:53:45Z")

</div>

hello,Thank you very much for your answer  
I don't quite follow you  
Can you give me a case

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [January 21, 2019, 7:37am UTC](https://discuss.elastic.co/t/use-apm-agent-for-java-springboot-noerrordata/164970/4 "2019-01-21T07:37:52Z")

</div>

The Java agent is instrumenting methods in order to trace them. One of things we instrument in order to trace transactions is `javax.servlet.FilterChain#doFilter`. This method runs all registered servlet Filters as a chain, then runs the actual servlet (eg Spring's `FrameworkServlet` or `DispatherServlet`), which delegates execution to the relevant controller. If the controller is throwing an Exception and this Exception is caught quietly before the `FilterChain#doFilter` method execution finishes, we don't report this as error.  
The rationale is that only unhandled Exceptions are reported, but maybe we need to rethink this. What would you expect to get? All errors in controllers being reported?

---

<div class="post-metadata">

**Author:** ![fangfhm](https://avatars.discourse-cdn.com/v4/letter/f/96bed5/32.png) [@fangfhm](https://discuss.elastic.co/u/fangfhm)\
**Post date:** [January 21, 2019, 7:46am UTC](https://discuss.elastic.co/t/use-apm-agent-for-java-springboot-noerrordata/164970/5 "2019-01-21T07:46:00Z")

</div>

Exceptions handled by try are not considered false?  
 ![%E5%9B%BE%E7%89%87](https://us1.discourse-cdn.com/elastic/original/3X/e/e/ee63861736260be7a9e3c376eb7000bae80dd133.png)

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [January 21, 2019, 7:56am UTC](https://discuss.elastic.co/t/use-apm-agent-for-java-springboot-noerrordata/164970/6 "2019-01-21T07:56:23Z")

</div>

We can't see handled Exceptions. For something like that, we may decide to add instrumentation to APIs such as the `R.error` from the above. However, you don't need to wait for something like that, you can [capture such errors programatically using our public API](https://www.elastic.co/guide/en/apm/agent/java/master/public-api.html#api-span-capture-exception) 🙂 .  
I hope this helps.  
Eyal.

---

<div class="post-metadata">

**Author:** ![fangfhm](https://avatars.discourse-cdn.com/v4/letter/f/96bed5/32.png) [@fangfhm](https://discuss.elastic.co/u/fangfhm)\
**Post date:** [January 21, 2019, 8:07am UTC](https://discuss.elastic.co/t/use-apm-agent-for-java-springboot-noerrordata/164970/7 "2019-01-21T08:07:08Z")

</div>

I want to get all the error information. Is it ok

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 11, 2019, 4:07am UTC](https://discuss.elastic.co/t/use-apm-agent-for-java-springboot-noerrordata/164970/8 "2019-02-11T04:07:14Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
